az vm
Manage Linux or Windows virtual machines.
Commands
az vm availability-set | Group resources into availability sets. |
az vm availability-set convert | Convert an Azure Availability Set to contain VMs with managed disks. |
az vm availability-set create | Create an Azure Availability Set. |
az vm availability-set delete | Delete an availability set. |
az vm availability-set list | List availability sets. |
az vm availability-set list-sizes | List VM sizes for an availability set. |
az vm availability-set show | Get information for an availability set. |
az vm availability-set update | Update an Azure Availability Set. |
az vm boot-diagnostics | Troubleshoot the startup of an Azure Virtual Machine. |
az vm boot-diagnostics disable | Disable the boot diagnostics on a VM. |
az vm boot-diagnostics enable | Enable the boot diagnostics on a VM. |
az vm boot-diagnostics get-boot-log | Get the boot diagnostics log from a VM. |
az vm capture | Capture information for a stopped VM. |
az vm convert | Convert a VM with unmanaged disks to use managed disks. |
az vm create | Create an Azure Virtual Machine. |
az vm deallocate | Deallocate a VM. |
az vm delete | Delete a VM. |
az vm diagnostics | Configure the Azure Virtual Machine diagnostics extension. |
az vm diagnostics get-default-config | Get the default configuration settings for a VM. |
az vm diagnostics set | Configure the Azure VM diagnostics extension. |
az vm disk | Manage the managed data disks attached to a VM. |
az vm disk attach | Attach a managed persistent disk to a VM. |
az vm disk detach | Detach a managed disk from a VM. |
az vm encryption | Manage encryption of VM disks. |
az vm encryption disable | Disable disk encryption on the OS disk and/or data disks. Decrypt mounted disks. |
az vm encryption enable | Enable disk encryption on the OS disk and/or data disks. Encrypt mounted disks. |
az vm encryption show | Show encryption status. |
az vm extension | Manage extensions on VMs. |
az vm extension delete | Remove an extension attached to a VM. |
az vm extension image | Find the available VM extensions for a subscription and region. |
az vm extension image list | List the information on available extensions. |
az vm extension image list-names | List the names of available extensions. |
az vm extension image list-versions | List the versions for available extensions. |
az vm extension image show | Display information for an extension. |
az vm extension list | List the extensions attached to a VM. |
az vm extension set | Set extensions for a VM. |
az vm extension show | Display information about extensions attached to a VM. |
az vm extension wait | Place the CLI in a waiting state until a condition of a virtual machine extension is met. |
az vm generalize | Mark a VM as generalized, allowing it to be imaged for multiple deployments. |
az vm get-instance-view | Get instance information about a VM. |
az vm host | Manage Dedicated Hosts for Virtual Machines. |
az vm host create | Create a dedicated host. |
az vm host delete | Delete a dedicated host. |
az vm host get-instance-view | Get instance information about a dedicated host. |
az vm host group | Manage Dedicated Host Groups. |
az vm host group create | Create a dedicated host group. |
az vm host group delete | Delete a dedicated host group. |
az vm host group list | List dedicated host groups. |
az vm host group show | Get the details of a dedicated host group. |
az vm host group update | Update a dedicated host group. |
az vm host list | List dedicated hosts. |
az vm host show | Get the details of a dedicated host. |
az vm host update | Update a dedicated host. |
az vm identity | Manage service identities of a VM. |
az vm identity assign | Enable managed service identity on a VM. |
az vm identity remove | Remove managed service identities from a VM. |
az vm identity show | Display VM's managed identity info. |
az vm image | Information on available virtual machine images. |
az vm image accept-terms | Accept Azure Marketplace term so that the image can be used to create VMs. |
az vm image list | List the VM/VMSS images available in the Azure Marketplace. |
az vm image list-offers | List the VM image offers available in the Azure Marketplace. |
az vm image list-publishers | List the VM image publishers available in the Azure Marketplace. |
az vm image list-skus | List the VM image SKUs available in the Azure Marketplace. |
az vm image show | Get the details for a VM image available in the Azure Marketplace. |
az vm image terms | Manage Azure Marketplace image terms. |
az vm image terms accept | Accept Azure Marketplace image terms so that the image can be used to create VMs. |
az vm image terms cancel | Cancel Azure Marketplace image terms. |
az vm image terms show | Get the details of Azure Marketplace image terms. |
az vm list | List details of Virtual Machines. |
az vm list-ip-addresses | List IP addresses associated with a VM. |
az vm list-sizes | List available sizes for VMs. |
az vm list-skus | Get details for compute-related resource SKUs. |
az vm list-usage | List available usage resources for VMs. |
az vm list-vm-resize-options | List available resizing options for VMs. |
az vm monitor | Manage monitor aspect for a vm. |
az vm monitor log | Manage log analytics workspace for a vm. |
az vm monitor log show | Executes a query against the Log Analytics workspace linked with a vm. |
az vm nic | Manage network interfaces. See also `az network nic`. |
az vm nic add | Add existing NICs to a VM. |
az vm nic list | List the NICs available on a VM. |
az vm nic remove | Remove NICs from a VM. |
az vm nic set | Configure settings of a NIC attached to a VM. |
az vm nic show | Display information for a NIC attached to a VM. |
az vm open-port | Opens a VM to inbound traffic on specified ports. |
az vm perform-maintenance | The operation to perform maintenance on a virtual machine. |
az vm redeploy | Redeploy an existing VM. |
az vm resize | Update a VM's size. |
az vm restart | Restart VMs. |
az vm run-command | Manage run commands on a Virtual Machine. |
az vm run-command invoke | Execute a specific run command on a vm. |
az vm run-command list | Lists all available run commands for a subscription in a location. |
az vm run-command show | Gets specific run command for a subscription in a location. |
az vm secret | Manage VM secrets. |
az vm secret add | Add a secret to a VM. |
az vm secret format | Transform secrets into a form that can be used by VMs and VMSSes. |
az vm secret list | List secrets on a VM. |
az vm secret remove | Remove a secret from a VM. |
az vm show | Get the details of a VM. |
az vm start | Start a stopped VM. |
az vm stop | Power off (stop) a running VM. |
az vm unmanaged-disk | Manage the unmanaged data disks attached to a VM. |
az vm unmanaged-disk attach | Attach an unmanaged persistent disk to a VM. |
az vm unmanaged-disk detach | Detach an unmanaged disk from a VM. |
az vm unmanaged-disk list | List unmanaged disks of a VM. |
az vm update | Update the properties of a VM. |
az vm user | Manage user accounts for a VM. |
az vm user delete | Delete a user account from a VM. |
az vm user reset-ssh | Reset the SSH configuration on a VM. |
az vm user update | Update a user account. |
az vm wait | Place the CLI in a waiting state until a condition of the VM is met. |
az vm capture
Capture information for a stopped VM.
az vm capture --vhd-name-prefix
[--ids]
[--name]
[--overwrite]
[--resource-group]
[--storage-container]
[--subscription]
Examples
Deallocate, generalize, and capture a stopped virtual machine.
az vm deallocate -g MyResourceGroup -n MyVm
az vm generalize -g MyResourceGroup -n MyVm
az vm capture -g MyResourceGroup -n MyVm --vhd-name-prefix MyPrefix
Deallocate, generalize, and capture multiple stopped virtual machines.
vms_ids=$(az vm list -g MyResourceGroup --query "[].id" -o tsv)
az vm deallocate --ids {vms_ids}
az vm generalize --ids {vms_ids}
az vm capture --ids {vms_ids} --vhd-name-prefix MyPrefix
Required Parameters
The VHD name prefix specify for the VM disks.
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Overwrite the existing disk file.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The storage account container name in which to save the disks.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm convert
Convert a VM with unmanaged disks to use managed disks.
az vm convert [--ids]
[--name]
[--resource-group]
[--subscription]
Examples
Convert a VM with unmanaged disks to use managed disks.
az vm convert -g MyResourceGroup -n MyVm
Convert all VMs with unmanaged disks in a resource group to use managed disks.
az vm convert --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm create
Create an Azure Virtual Machine.
az vm create --name
--resource-group
[--accelerated-networking {false, true}]
[--admin-password]
[--admin-username]
[--asgs]
[--assign-identity]
[--attach-data-disks]
[--attach-os-disk]
[--authentication-type {all, password, ssh}]
[--availability-set]
[--boot-diagnostics-storage]
[--computer-name]
[--custom-data]
[--data-disk-caching]
[--data-disk-sizes-gb]
[--enable-agent {false, true}]
[--ephemeral-os-disk {false, true}]
[--eviction-policy {Deallocate, Delete}]
[--generate-ssh-keys]
[--host]
[--host-group]
[--image]
[--license-type {None, Windows_Client, Windows_Server}]
[--location]
[--max-price]
[--nics]
[--no-wait]
[--nsg]
[--nsg-rule {RDP, SSH}]
[--os-disk-caching {None, ReadOnly, ReadWrite}]
[--os-disk-name]
[--os-disk-size-gb]
[--os-type {linux, windows}]
[--plan-name]
[--plan-product]
[--plan-promotion-code]
[--plan-publisher]
[--ppg]
[--priority {Low, Regular, Spot}]
[--private-ip-address]
[--public-ip-address]
[--public-ip-address-allocation {dynamic, static}]
[--public-ip-address-dns-name]
[--public-ip-sku {Basic, Standard}]
[--role]
[--scope]
[--secrets]
[--size]
[--ssh-dest-key-path]
[--ssh-key-values]
[--storage-account]
[--storage-container-name]
[--storage-sku]
[--subnet]
[--subnet-address-prefix]
[--subscription]
[--tags]
[--ultra-ssd-enabled {false, true}]
[--use-unmanaged-disk]
[--validate]
[--vmss]
[--vnet-address-prefix]
[--vnet-name]
[--workspace]
[--zone {1, 2, 3}]
Examples
Create a default Ubuntu VM with automatic SSH authentication.
az vm create -n MyVm -g MyResourceGroup --image UbuntuLTS
Create a default RedHat VM with automatic SSH authentication using an image URN.
az vm create -n MyVm -g MyResourceGroup --image RedHat:RHEL:7-RAW:7.4.2018010506
Create a default Windows Server VM with a private IP address.
az vm create -n MyVm -g MyResourceGroup --public-ip-address "" --image Win2012R2Datacenter
Create a VM from a custom managed image.
az vm create -g MyResourceGroup -n MyVm --image MyImage
Create a VM by attaching to a managed operating system disk.
az vm create -g MyResourceGroup -n MyVm --attach-os-disk MyOsDisk --os-type linux
Create an Ubuntu Linux VM using a cloud-init script for configuration. See: https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-using-cloud-init.
az vm create -g MyResourceGroup -n MyVm --image debian --custom-data MyCloudInitScript.yml
Create a Debian VM with SSH key authentication and a public DNS entry, located on an existing virtual network and availability set.
az vm create -n MyVm -g MyResourceGroup --image debian --vnet-name MyVnet --subnet subnet1 \
--availability-set MyAvailabilitySet --public-ip-address-dns-name MyUniqueDnsName \
--ssh-key-value @key-file
Create a simple Ubuntu Linux VM with a public IP address, DNS entry, two data disks (10GB and 20GB), and then generate ssh key pairs.
az vm create -n MyVm -g MyResourceGroup --public-ip-address-dns-name MyUniqueDnsName \
--image ubuntults --data-disk-sizes-gb 10 20 --size Standard_DS2_v2 \
--generate-ssh-keys
Create a Debian VM using Key Vault secrets.
az keyvault certificate create --vault-name vaultname -n cert1 \
-p "$(az keyvault certificate get-default-policy)"
secrets=$(az keyvault secret list-versions --vault-name vaultname \
-n cert1 --query "[?attributes.enabled].id" -o tsv)
vm_secrets=$(az vm secret format -s "$secrets")
az vm create -g group-name -n vm-name --admin-username deploy \
--image debian --secrets "$vm_secrets"
Create a CentOS VM with a system assigned identity. The VM will have a 'Contributor' role with access to a storage account.
az vm create -n MyVm -g rg1 --image centos --assign-identity --scope /subscriptions/99999999-1bf0-4dda-aec3-cb9272f09590/MyResourceGroup/myRG/providers/Microsoft.Storage/storageAccounts/storage1
Create a debian VM with a user assigned identity.
az vm create -n MyVm -g rg1 --image debian --assign-identity /subscriptions/99999999-1bf0-4dda-aec3-cb9272f09590/resourcegroups/myRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myID
Create a debian VM with both system and user assigned identity.
az vm create -n MyVm -g rg1 --image debian --assign-identity [system] /subscriptions/99999999-1bf0-4dda-aec3-cb9272f09590/resourcegroups/myRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myID
Create a VM in an availability zone in the current resource group's region
az vm create -n MyVm -g MyResourceGroup --image Centos --zone 1
Required Parameters
Name of the virtual machine.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Optional Parameters
Enable accelerated networking. Unless specified, CLI will enable it based on machine image and size.
Password for the VM if authentication type is 'Password'.
Username for the VM.
Space-separated list of existing application security groups to associate with the VM.
Accept system or user assigned identities separated by spaces. Use '[system]' to refer system assigned identity, or a resource id to refer user assigned identity. Check out help for more examples.
Attach existing data disks to the VM. Can use the name or ID of a managed disk or the URI to an unmanaged disk VHD.
Attach an existing OS disk to the VM. Can use the name or ID of a managed disk or the URI to an unmanaged disk VHD.
Type of authentication to use with the VM. Defaults to password for Windows and SSH public key for Linux. "all" enables both ssh and password authentication.
Name or ID of an existing availability set to add the VM to. None by default.
Pre-existing storage account name or its blob uri to capture boot diagnostics. Its sku should be one of Standard_GRS, Standard_LRS and Standard_RAGRS.
The host OS name of the virtual machine. Defaults to the name of the VM.
Custom init script file or text (cloud-init, cloud-config, etc..).
Storage caching type for data disk(s), including 'None', 'ReadOnly', 'ReadWrite', etc. Use a singular value to apply on all disks, or use '
Space-separated empty managed data disk sizes in GB to create.
Indicates whether virtual machine agent should be provisioned on the virtual machine. When this property is not specified, default behavior is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can be added to the VM later.
Allows you to create an OS disk directly on the host node, providing local disk performance and faster VM/VMSS reimage time.
The eviction policy for the low priority virtual machine.
Generate SSH public and private key files if missing. The keys will be stored in the ~/.ssh directory.
Name or ID of the dedicated host this VM will reside in. If a name is specified, a host group must be specified via --host-group
.
Name of the dedicated host group containing the dedicated host this VM will reside in.
The name of the operating system image as a URN alias, URN, custom image name or ID, or VHD blob URI. This parameter is required unless using --attach-os-disk.
Valid URN format: "Publisher:Offer:Sku:Version".
Specifies that the Windows image or disk was licensed on-premises. To enable Azure Hybrid Benefit for Windows Server, use 'Windows_Server'. To enable Multitenant Hosting Rights for Windows 10, use 'Windows_Client'. For more information see the Azure Windows VM online docs.
Location in which to create VM and related resources. If default location is not configured, will default to the resource group's location.
The maximum price (in US Dollars) you are willing to pay for a low priority VM/VMSS. -1 indicates that the low priority VM/VMSS should not be evicted for price reasons.
Names or IDs of existing NICs to attach to the VM. The first NIC will be designated as primary. If omitted, a new NIC will be created. If an existing NIC is specified, do not specify subnet, VNet, public IP or NSG.
Do not wait for the long-running operation to finish.
The name to use when creating a new Network Security Group (default) or referencing an existing one. Can also reference an existing NSG by ID or specify "" for none.
NSG rule to create when creating a new NSG. Defaults to open ports for allowing RDP on Windows and allowing SSH on Linux.
Storage caching type for the VM OS disk. Default: ReadWrite.
The name of the new VM OS disk.
The size of the os disk in GB.
Type of OS installed on a custom VHD. Do not use when specifying an URN or URN alias.
Plan name.
Plan product.
Plan promotion code.
Plan publisher.
The name or ID of the proximity placement group the VM should be associated with.
Priority. Use 'Low' to run short-lived workloads in a cost-effective way.
Static private IP address (e.g. 10.0.0.5).
Name of the public IP address when creating one (default) or referencing an existing one. Can also reference an existing public IP by ID or specify "" for None.
Globally unique DNS name for a newly created public IP.
Public IP SKU. It is set to Basic by default.
Role name or id the system assigned identity will have.
Scope that the system assigned identity can access.
One or many Key Vault secrets as JSON strings or files via @{path}
containing [{ "sourceVault": { "id": "value" }, "vaultCertificates": [{ "certificateUrl": "value", "certificateStore": "cert store name (only on windows)"}] }]
.
The VM size to be created. See https://azure.microsoft.com/pricing/details/virtual-machines/ for size info.
Destination file path on the VM for the SSH key. If the file already exists, the specified key(s) are appended to the file.
Space-separated list of SSH public keys or public key file paths.
Only applicable when used with --use-unmanaged-disk
. The name to use when creating a new storage account or referencing an existing one. If omitted, an appropriate storage account in the same resource group and location will be used, or a new one will be created.
Only applicable when used with --use-unmanaged-disk
. Name of the storage container for the VM OS disk. Default: vhds.
The SKU of the storage account with which to persist VM. Use a singular sku that would be applied across all disks, or specify individual disks. Usage: [--storage-sku SKU | --storage-sku ID=SKU ID=SKU ID=SKU...], where each ID is "os" or a 0-indexed lun. Allowed values: Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS.
The name of the subnet when creating a new VNet or referencing an existing one. Can also reference an existing subnet by ID. If omitted, an appropriate VNet and subnet will be selected automatically, or a new one will be created.
The subnet IP address prefix to use when creating a new VNet in CIDR format.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Space-separated tags in 'key[=value]' format. Use "" to clear existing tags.
Enables or disables the capability to have 1 or more managed data disks with UltraSSD_LRS storage account.
Do not use managed disk to persist VM.
Generate and validate the ARM template without creating any resources.
Name or ID of an existing virtual machine scale set that the virtual machine should be assigned to. None by default.
The IP address prefix to use when creating a new VNet in CIDR format.
Name of the virtual network when creating a new one or referencing an existing one.
Name or ID of Log Analytics Workspace. If you specify the workspace through its name, the workspace should be in the same resource group with the vm, otherwise a new workspace will be created.
Availability zone into which to provision the resource.
az vm deallocate
Deallocate a VM.
az vm deallocate [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
Examples
Deallocate, generalize, and capture a stopped virtual machine.
az vm deallocate -g MyResourceGroup -n MyVm
az vm generalize -g MyResourceGroup -n MyVm
az vm capture -g MyResourceGroup -n MyVm --vhd-name-prefix MyPrefix
Deallocate, generalize, and capture multiple stopped virtual machines.
vms_ids=$(az vm list -g MyResourceGroup --query "[].id" -o tsv)
az vm deallocate --ids {vms_ids}
az vm generalize --ids {vms_ids}
az vm capture --ids {vms_ids} --vhd-name-prefix MyPrefix
Deallocate a VM. (autogenerated)
az vm deallocate --name MyVm --no-wait --resource-group MyResourceGroup
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm delete
Delete a VM.
az vm delete [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
[--yes]
Examples
Delete a VM without a prompt for confirmation.
az vm delete -g MyResourceGroup -n MyVm --yes
Delete all VMs in a resource group.
az vm delete --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Do not prompt for confirmation.
az vm generalize
Mark a VM as generalized, allowing it to be imaged for multiple deployments.
az vm generalize [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
Examples
Deallocate, generalize, and capture a stopped virtual machine.
az vm deallocate -g MyResourceGroup -n MyVm
az vm generalize -g MyResourceGroup -n MyVm
az vm capture -g MyResourceGroup -n MyVm --vhd-name-prefix MyPrefix
Deallocate, generalize, and capture multiple stopped virtual machines.
vms_ids=$(az vm list -g MyResourceGroup --query "[].id" -o tsv)
az vm deallocate --ids {vms_ids}
az vm generalize --ids {vms_ids}
az vm capture --ids {vms_ids} --vhd-name-prefix MyPrefix
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm get-instance-view
Get instance information about a VM.
az vm get-instance-view [--ids]
[--name]
[--resource-group]
[--subscription]
Examples
Use a resource group and name to get instance view information of a VM.
az vm get-instance-view -g MyResourceGroup -n MyVm
Get instance views for all VMs in a resource group.
az vm get-instance-view --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm list
List details of Virtual Machines.
az vm list [--resource-group]
[--show-details]
[--subscription]
Examples
List all VMs.
az vm list
List all VMs by resource group.
az vm list -g MyResourceGroup
List all VMs by resource group with details.
az vm list -g MyResourceGroup -d
Optional Parameters
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Show public ip address, FQDN, and power states. command will run slow.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm list-ip-addresses
List IP addresses associated with a VM.
az vm list-ip-addresses [--ids]
[--name]
[--resource-group]
[--subscription]
Examples
Get the IP addresses for a VM.
az vm list-ip-addresses -g MyResourceGroup -n MyVm
Get IP addresses for all VMs in a resource group.
az vm list-ip-addresses --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm list-sizes
List available sizes for VMs.
az vm list-sizes --location
[--subscription]
Examples
List the available VM sizes in the West US region.
az vm list-sizes -l westus
Required Parameters
Location. Values from: az account list-locations
. You can configure the default location using az configure --defaults location=<location>
.
Optional Parameters
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm list-skus
Get details for compute-related resource SKUs.
az vm list-skus [--all {false, true}]
[--location]
[--resource-type]
[--size]
[--subscription]
[--zone {false, true}]
Examples
List all SKUs in the West US region.
az vm list-skus -l westus
List all available vm sizes in the East US2 region which support availability zone.
az vm list-skus -l eastus2 --zone
List all available vm sizes in the East US2 region which support availability zone with name like "standard_ds1...".
az vm list-skus -l eastus2 --zone --size standard_ds1
List availability set related sku information in The West US region.
az vm list-skus -l westus --resource-type availabilitySets
Optional Parameters
Show all information including vm sizes not available under the current subscription.
Location. Values from: az account list-locations
. You can configure the default location using az configure --defaults location=<location>
.
Resource types e.g. "availabilitySets", "snapshots", "disks", etc.
Size name, partial name is accepted.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Show all vm size supporting availability zones.
az vm list-usage
List available usage resources for VMs.
az vm list-usage --location
[--subscription]
Examples
Get the compute resource usage for the West US region.
az vm list-usage -l westus
Required Parameters
Location. Values from: az account list-locations
. You can configure the default location using az configure --defaults location=<location>
.
Optional Parameters
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm list-vm-resize-options
List available resizing options for VMs.
az vm list-vm-resize-options [--ids]
[--name]
[--resource-group]
[--subscription]
Examples
List all available VM sizes for resizing.
az vm list-vm-resize-options -g MyResourceGroup -n MyVm
List available sizes for all VMs in a resource group.
az vm list-vm-resize-options --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm open-port
Opens a VM to inbound traffic on specified ports.
az vm open-port --port
[--apply-to-subnet]
[--ids]
[--name]
[--nsg-name]
[--priority]
[--resource-group]
[--subscription]
Examples
Open all ports on a VM to inbound traffic.
az vm open-port -g MyResourceGroup -n MyVm --port '*'
Open a range of ports on a VM to inbound traffic with the highest priority.
az vm open-port -g MyResourceGroup -n MyVm --port 80-100 --priority 100
Open all ports for all VMs in a resource group.
az vm open-port --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv) --port '*'
Required Parameters
The port or port range (ex: 80-100) to open inbound traffic to. Use '*' to allow traffic to all ports.
Optional Parameters
Allow inbound traffic on the subnet instead of the NIC.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the virtual machine to open inbound traffic on.
The name of the network security group to create if one does not exist. Ignored if an NSG already exists.
Rule priority, between 100 (highest priority) and 4096 (lowest priority). Must be unique for each rule in the collection.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm perform-maintenance
The operation to perform maintenance on a virtual machine.
az vm perform-maintenance [--ids]
[--name]
[--resource-group]
[--subscription]
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm redeploy
Redeploy an existing VM.
az vm redeploy [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
Examples
Redeploy a VM.
az vm redeploy -g MyResourceGroup -n MyVm
Redeploy all VMs in a resource group.
az vm redeploy --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm resize
Update a VM's size.
az vm resize --size
[--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
Examples
Resize a VM.
az vm resize -g MyResourceGroup -n MyVm --size Standard_DS3_v2
Resize all VMs in a resource group.
az vm resize --size Standard_DS3_v2 --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Required Parameters
The VM size.
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm restart
Restart VMs.
az vm restart [--force]
[--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
Examples
Restart a VM.
az vm restart -g MyResourceGroup -n MyVm
Restart all VMs in a resource group.
az vm restart --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
Force the VM to restart by redeploying it. Use if the VM is unresponsive.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm show
Get the details of a VM.
az vm show [--ids]
[--name]
[--resource-group]
[--show-details]
[--subscription]
Examples
Show information about a VM.
az vm show -g MyResourceGroup -n MyVm -d
Get the details for all VMs in a resource group.
az vm show -d --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Show public ip address, FQDN, and power states. command will run slow.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm start
Start a stopped VM.
az vm start [--ids]
[--name]
[--no-wait]
[--resource-group]
[--subscription]
Examples
Start a stopped VM.
az vm start -g MyResourceGroup -n MyVm
Start all VMs in a resource group.
az vm start --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Start a stopped VM. (autogenerated)
az vm start --name MyVm --no-wait --resource-group MyResourceGroup
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm stop
Power off (stop) a running VM.
az vm stop [--ids]
[--name]
[--no-wait]
[--resource-group]
[--skip-shutdown]
[--subscription]
Examples
Power off (stop) a running VM.
az vm stop --resource-group MyResourceGroup --name MyVm
Power off a running VM without shutting down.
az vm stop --resource-group MyResourceGroup --name MyVm --skip-shutdown
Power off VMs in a resource group.
az vm stop --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Skip shutdown and power-off immediately.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
az vm update
Update the properties of a VM.
az vm update [--add]
[--disk-caching]
[--force-string]
[--ids]
[--license-type {None, Windows_Client, Windows_Server}]
[--name]
[--no-wait]
[--os-disk]
[--remove]
[--resource-group]
[--set]
[--subscription]
[--ultra-ssd-enabled {false, true}]
[--write-accelerator]
Examples
Add or update a tag.
az vm update -n name -g group --set tags.tagName=tagValue
Remove a tag.
az vm update -n name -g group --remove tags.tagName
Set the primary NIC of a VM.
az vm update -n name -g group --set networkProfile.networkInterfaces[1].primary=false networkProfile.networkInterfaces[0].primary=true
Add a new non-primary NIC to a VM.
az vm update -n name -g group --add networkProfile.networkInterfaces primary=false id={NIC_ID}
Remove the fourth NIC from a VM.
az vm update -n name -g group --remove networkProfile.networkInterfaces 3
Optional Parameters
Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.
Use singular value to apply across, or specify individual disks, e.g. 'os=ReadWrite 0=None 1=ReadOnly' should enable update os disk and 2 data disks.
When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
Specifies that the Windows image or disk was licensed on-premises. To enable Azure Hybrid Benefit for Windows Server, use 'Windows_Server'. To enable Multitenant Hosting Rights for Windows 10, use 'Windows_Client'. For more information see the Azure Windows VM online docs.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Do not wait for the long-running operation to finish.
Managed OS disk ID or name to swap to.
Remove a property or an element from a list. Example: --remove property.list
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Update an object by specifying a property path and value to set. Example: --set property1.property2=
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Enables or disables the capability to have 1 or more managed data disks with UltraSSD_LRS storage account.
Enable/disable disk write accelerator. Use singular value 'true/false' to apply across, or specify individual disks, e.g.'os=true 1=true 2=true' for os disk and data disks with lun of 1 & 2.
az vm wait
Place the CLI in a waiting state until a condition of the VM is met.
az vm wait [--created]
[--custom]
[--deleted]
[--exists]
[--ids]
[--interval]
[--name]
[--resource-group]
[--subscription]
[--timeout]
[--updated]
Examples
Wait until a VM is created.
az vm wait -g MyResourceGroup -n MyVm --created
Wait until all VMs in a resource group are deleted.
az vm wait --deleted --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
Optional Parameters
Wait until created with 'provisioningState' at 'Succeeded'.
Wait until the condition satisfies a custom JMESPath query. E.g. provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running'].
Wait until deleted.
Wait until the resource exists.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. If provided, no other 'Resource Id' arguments should be specified.
Polling interval in seconds.
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Maximum wait in seconds.
Wait until updated with provisioningState at 'Succeeded'.
Feedback
Loading feedback...