Just like any other resource, the Azure Serial Console can be enabled and disabled. Serial Console is enabled by default for all subscriptions in global Azure. Currently, disabling Serial Console will disable the service for your entire subscription. Disabling or re-enabling Serial Console for a subscription requires contributor-level access or above on the subscription.
You can also disable Serial Console for an individual VM or virtual machine scale set instance by disabling boot diagnostics. You will need contributor-level access or above on both the VM/virtual machine scale set and your boot diagnostics storage account.
VM-level disable
The serial console can be disabled for a specific VM or virtual machine scale set by disabling the boot diagnostics setting. Turn off boot diagnostics from the Azure portal to disable the serial console for the VM or the virtual machine scale set. If you are using Serial Console on a virtual machine scale set, ensure you upgrade your virtual machine scale set instances to the latest model.
Subscription-level enable/disable
Poznámka
Ensure you are in the right cloud (Azure Public Cloud, Azure US Government Cloud, and so on) before running this command. You can check with az cloud list and set your cloud with az cloud set -n <Name of cloud>.
Azure CLI
Serial Console can be disabled and re-enabled for an entire subscription by using the following commands in the Azure CLI (you may use the "Try it" button to launch an instance of the Azure Cloud Shell in which you can run the commands):
To disable Serial Console for a subscription, use the following commands:
Azure CLI
$subscriptionId=$(az account show --output=json | jq -r .id)
az resource invoke-action --action disableConsole --ids"/subscriptions/$subscriptionId/providers/Microsoft.SerialConsole/consoleServices/default"--api-version="2023-01-01"
To enable Serial Console for a subscription, use the following commands:
Azure CLI
$subscriptionId=$(az account show --output=json | jq -r .id)
az resource invoke-action --action enableConsole --ids"/subscriptions/$subscriptionId/providers/Microsoft.SerialConsole/consoleServices/default"--api-version="2023-01-01"
To get the current enabled/disabled status of Serial Console for a subscription, use the following commands:
Azure CLI
$subscriptionId=$(az account show --output=json | jq -r .id)
az resource show --ids"/subscriptions/$subscriptionId/providers/Microsoft.SerialConsole/consoleServices/default"--output=json --api-version="2023-01-01" | jq .properties
PowerShell
Serial Console can also be enabled and disabled using PowerShell.
To disable Serial Console for a subscription, use the following commands:
Enabling least privilege access to Serial console using RBAC
To enable least privilege access to Serial Console, you need to create an Azure role with the required permissions that has rights to the virtual machine's (the virtual machine you need to access Serial Console on) resource group or the subscription the VM is in. You can assign this Azure role to users that need to access Serial Console.
The role you create will need the following Azure Actions permissions:
The JSON below can be used to define a custom role with least privilege access to VMs in a subscription and VMs in a resource group in a subscription.
If you'd like to only assign access to VMs in a resource group, then delete the first value "/subscriptions/<subscriptionID>/" in the assignableScopes property below.
If you'd like to assign access to VMs in a subscription, then delete the second value "/subscriptions/<subscriptionID>/resourceGroups/<resourceGroup>" in the assignableScopes property below.
For Step 5: Assignable scopes, set the scope to be the VM's resource group if you only want the user with the role to have access to a particular VM's Serial Console. You can also set the scope to be the subscription if you want the user to have Serial Console access to any VM in the subscription.