az vm

Note

This command group has commands that are defined in both Azure CLI and at least one extension. Install each extension to benefit from its extended capabilities. Learn more about extensions.

Manage Linux or Windows virtual machines.

Commands

Name Description Type Status
az vm aem

Manage Azure Enhanced Monitoring Extension for SAP.

Extension GA
az vm aem delete

Remove Azure Enhanced Monitoring Extension.

Extension GA
az vm aem set

Configure Azure Enhanced Monitoring Extension.

Extension GA
az vm aem verify

Verify Azure Enhanced Monitoring Extensions configured correctly.

Extension GA
az vm application

Manage applications for VM.

Core GA
az vm application list

List applications for VM.

Core GA
az vm application set

Set applications for VM.

Core GA
az vm assess-patches

Assess patches on a VM.

Core GA
az vm auto-shutdown

Manage auto-shutdown for VM.

Core GA
az vm availability-set

Group resources into availability sets.

Core GA
az vm availability-set convert

Convert an Azure Availability Set to contain VMs with managed disks.

Core GA
az vm availability-set create

Create an Azure Availability Set.

Core GA
az vm availability-set delete

Delete an availability set.

Core GA
az vm availability-set list

List availability sets.

Core GA
az vm availability-set list-sizes

List all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set.

Core GA
az vm availability-set show

Get information about an availability set.

Core GA
az vm availability-set update

Update an Azure Availability Set.

Core GA
az vm boot-diagnostics

Troubleshoot the startup of an Azure Virtual Machine.

Core GA
az vm boot-diagnostics disable

Disable the boot diagnostics on a VM.

Core GA
az vm boot-diagnostics enable

Enable the boot diagnostics on a VM.

Core GA
az vm boot-diagnostics get-boot-log

Get the boot diagnostics log from a VM.

Core GA
az vm boot-diagnostics get-boot-log-uris

Get SAS URIs for a virtual machine's boot diagnostic logs.

Core GA
az vm capture

Capture information for a stopped VM.

Core GA
az vm convert

Convert a VM with unmanaged disks to use managed disks.

Core GA
az vm create

Create an Azure Virtual Machine.

Core GA
az vm deallocate

Deallocate a VM so that computing resources are no longer allocated (charges no longer apply). The status will change from 'Stopped' to 'Stopped (Deallocated)'.

Core GA
az vm delete

Delete a VM.

Core GA
az vm diagnostics

Configure the Azure Virtual Machine diagnostics extension.

Core GA
az vm diagnostics get-default-config

Get the default configuration settings for a VM.

Core GA
az vm diagnostics set

Configure the Azure VM diagnostics extension.

Core GA
az vm disk

Manage the managed data disks attached to a VM.

Core GA
az vm disk attach

Attach a managed persistent disk to a VM.

Core GA
az vm disk detach

Detach a managed disk from a VM.

Core GA
az vm encryption

Manage encryption of VM disks.

Core GA
az vm encryption disable

Disable disk encryption on the OS disk and/or data disks. Decrypt mounted disks.

Core GA
az vm encryption enable

Enable disk encryption on the OS disk and/or data disks. Encrypt mounted disks.

Core GA
az vm encryption show

Show encryption status.

Core GA
az vm extension

Manage extensions on VMs.

Core GA
az vm extension delete

Delete operation to delete the extension.

Core GA
az vm extension image

Find the available VM extensions for a subscription and region.

Core GA
az vm extension image list

List the information on available extensions.

Core GA
az vm extension image list-names

List the names of available extensions.

Core GA
az vm extension image list-versions

List the versions for available extensions.

Core GA
az vm extension image show

Display information for an extension.

Core GA
az vm extension list

List the extensions attached to a VM.

Core GA
az vm extension set

Set extensions for a VM.

Core GA
az vm extension show

Display information about extensions attached to a VM.

Core GA
az vm extension wait

Place the CLI in a waiting state until a condition of a virtual machine extension is met.

Core GA
az vm generalize

Mark a VM as generalized, allowing it to be imaged for multiple deployments.

Core GA
az vm get-instance-view

Get instance information about a VM.

Core GA
az vm host

Manage Dedicated Hosts for Virtual Machines.

Core GA
az vm host create

Create a dedicated host.

Core GA
az vm host delete

Delete a dedicated host.

Core GA
az vm host get-instance-view

Get instance information about a dedicated host.

Core GA
az vm host group

Manage Dedicated Host Groups.

Core GA
az vm host group create

Create a dedicated host group.

Core GA
az vm host group delete

Delete a dedicated host group.

Core GA
az vm host group get-instance-view

Get instance view of a dedicated host group.

Core GA
az vm host group list

List dedicated host groups.

Core GA
az vm host group show

Get the details of a dedicated host group.

Core GA
az vm host group update

Update a dedicated host group.

Core GA
az vm host list

List dedicated hosts.

Core GA
az vm host list-resize-options

List all available dedicated host sizes to which the specified dedicated host can be resized. NOTE: The dedicated host sizes provided can be used to only scale up the existing dedicated host.

Core GA
az vm host redeploy

Redeploy the dedicated host.

Core GA
az vm host resize

Resize a dedicated host.

Core GA
az vm host restart

Restart the dedicated host.

Core GA
az vm host show

Get the details of a dedicated host.

Core GA
az vm host update

Update a dedicated host.

Core GA
az vm host wait

Place the CLI in a waiting state until a condition is met.

Core GA
az vm identity

Manage service identities of a VM.

Core GA
az vm identity assign

Enable managed service identity on a VM.

Core GA
az vm identity remove

Remove managed service identities from a VM.

Core GA
az vm identity show

Display VM's managed identity info.

Core GA
az vm image

Information on available virtual machine images.

Core GA
az vm image accept-terms

Accept Azure Marketplace term so that the image can be used to create VMs.

Core Deprecated
az vm image list

List the VM/VMSS images available in the Azure Marketplace.

Core GA
az vm image list-offers

List the VM image offers available in the Azure Marketplace.

Core GA
az vm image list-publishers

List the VM image publishers available in the Azure Marketplace.

Core GA
az vm image list-skus

List the VM image SKUs available in the Azure Marketplace.

Core GA
az vm image show

Get the details for a VM image available in the Azure Marketplace.

Core GA
az vm image terms

Manage Azure Marketplace image terms.

Core GA
az vm image terms accept

Accept Azure Marketplace image terms so that the image can be used to create VMs.

Core GA
az vm image terms cancel

Cancel Azure Marketplace image terms.

Core GA
az vm image terms show

Get the details of Azure Marketplace image terms.

Core GA
az vm install-patches

Install patches on a VM.

Core GA
az vm list

List details of Virtual Machines.

Core GA
az vm list-ip-addresses

List IP addresses associated with a VM.

Core GA
az vm list-sizes

List available sizes for VMs.

Core GA
az vm list-skus

Get details for compute-related resource SKUs.

Core GA
az vm list-usage

List available usage resources for VMs.

Core GA
az vm list-vm-resize-options

List available resizing options for VMs.

Core GA
az vm monitor

Manage monitor aspect for a vm.

Core GA
az vm monitor log

Manage log analytics workspace for a vm.

Core GA
az vm monitor log show

Execute a query against the Log Analytics workspace linked with a VM.

Core GA
az vm monitor metrics

Manage metrics for a vm.

Core Preview
az vm monitor metrics list-definitions

List the metric definitions for a VM.

Core Preview
az vm monitor metrics tail

List the metric values for a VM.

Core Preview
az vm nic

Manage network interfaces. See also az network nic.

Core GA
az vm nic add

Add existing NICs to a VM.

Core GA
az vm nic list

List the NICs available on a VM.

Core GA
az vm nic remove

Remove NICs from a VM.

Core GA
az vm nic set

Configure settings of a NIC attached to a VM.

Core GA
az vm nic show

Display information for a NIC attached to a VM.

Core GA
az vm open-port

Opens a VM to inbound traffic on specified ports.

Core GA
az vm perform-maintenance

The operation to perform maintenance on a virtual machine.

Core GA
az vm reapply

Reapply VMs.

Core GA
az vm redeploy

Redeploy an existing VM.

Core GA
az vm reimage

Reimage (upgrade the operating system) a virtual machine.

Core GA
az vm repair

Auto repair commands to fix VMs.

Extension GA
az vm repair create

Create a new repair VM and attach the source VM's copied OS disk as a data disk.

Extension GA
az vm repair list-scripts

List available scripts. Located https://github.com/Azure/repair-script-library.

Extension GA
az vm repair repair-and-restore

Repair and restore the VM.

Extension Preview
az vm repair reset-nic

Reset the network interface stack on the VM guest OS. https://docs.microsoft.com/en-us/troubleshoot/azure/virtual-machines/reset-network-interface.

Extension Preview
az vm repair restore

Replace source VM's OS disk with data disk from repair VM.

Extension GA
az vm repair run

Run verified scripts from GitHub on a VM. 'az vm repair list-scripts' to view available scripts.

Extension GA
az vm resize

Update a VM's size.

Core GA
az vm restart

Restart VMs.

Core GA
az vm run-command

Manage run commands on a Virtual Machine.

Core GA
az vm run-command create

The operation to create the run command.

Core GA
az vm run-command delete

The operation to delete the run command.

Core GA
az vm run-command invoke

Execute a specific run command on a vm.

Core GA
az vm run-command list

List run commands from a VM or a location.

Core GA
az vm run-command show

Get specific run command.

Core GA
az vm run-command update

The operation to update the run command.

Core GA
az vm run-command wait

Place the CLI in a waiting state until a condition of the res virtual-machine-run-command is met.

Core GA
az vm secret

Manage VM secrets.

Core GA
az vm secret add

Add a secret to a VM.

Core GA
az vm secret format

Transform secrets into a form that can be used by VMs and VMSSes.

Core GA
az vm secret list

List secrets on a VM.

Core GA
az vm secret remove

Remove a secret from a VM.

Core GA
az vm show

Get the details of a VM.

Core GA
az vm simulate-eviction

Simulate the eviction of a Spot VM.

Core GA
az vm start

Start a stopped VM.

Core GA
az vm stop

Power off (stop) a running VM.

Core GA
az vm unmanaged-disk

Manage the unmanaged data disks attached to a VM.

Core GA
az vm unmanaged-disk attach

Attach an unmanaged persistent disk to a VM.

Core GA
az vm unmanaged-disk detach

Detach an unmanaged disk from a VM.

Core GA
az vm unmanaged-disk list

List unmanaged disks of a VM.

Core GA
az vm update

Update the properties of a VM.

Core GA
az vm user

Manage user accounts for a VM.

Core GA
az vm user delete

Delete a user account from a VM.

Core GA
az vm user reset-ssh

Reset the SSH configuration on a VM.

Core GA
az vm user update

Update a user account.

Core GA
az vm wait

Place the CLI in a waiting state until a condition of the VM is met.

Core GA

az vm assess-patches

Assess patches on a VM.

az vm assess-patches [--ids]
                     [--name]
                     [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                     [--resource-group]
                     [--subscription]

Examples

Assess patches on a VM.

az vm assess-patches -g MyResourceGroup -n MyVm

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm auto-shutdown

Manage auto-shutdown for VM.

az vm auto-shutdown [--email]
                    [--ids]
                    [--location]
                    [--name]
                    [--off]
                    [--resource-group]
                    [--subscription]
                    [--time]
                    [--webhook]

Examples

Create auto-shutdown schedule for a VM.

az vm auto-shutdown -g MyResourceGroup -n MyVm --time 1730 --email "foo@bar.com" --webhook "https://example.com/"

Delete auto-shutdown schedule for a VM.

az vm auto-shutdown -g MyResourceGroup -n MyVm --off

Optional Parameters

--email

The email recipient to send notifications to (can be a list of semi-colon separated email addresses).

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--location -l

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--off

Turn off auto-shutdown for VM. Configuration will be cleared.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--time

The UTC time of day the schedule will occur every day. Format: hhmm. Example: 1730.

--webhook

The webhook URL to which the notification will be sent.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

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

--vhd-name-prefix

The VHD name prefix specify for the VM disks.

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--overwrite

Overwrite the existing disk file.

default value: True
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--storage-container

The storage account container name in which to save the disks.

default value: vhds
--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm convert

Convert a VM with unmanaged disks to use managed disks.

az vm convert [--ids]
              [--name]
              [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
              [--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

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm create

Create an Azure Virtual Machine.

az vm create --name
             --resource-group
             [--accelerated-networking {false, true}]
             [--accept-term]
             [--admin-password]
             [--admin-username]
             [--asgs]
             [--assign-identity]
             [--attach-data-disks]
             [--attach-os-disk]
             [--authentication-type {all, password, ssh}]
             [--availability-set]
             [--boot-diagnostics-storage]
             [--capacity-reservation-group]
             [--computer-name]
             [--count]
             [--custom-data]
             [--data-disk-caching]
             [--data-disk-delete-option]
             [--data-disk-encryption-sets]
             [--data-disk-sizes-gb]
             [--disable-integrity-monitoring-autoupgrade]
             [--disk-controller-type {NVMe, SCSI}]
             [--edge-zone]
             [--enable-agent {false, true}]
             [--enable-auto-update {false, true}]
             [--enable-hibernation {false, true}]
             [--enable-hotpatching {false, true}]
             [--enable-integrity-monitoring]
             [--enable-proxy-agent {false, true}]
             [--enable-secure-boot {false, true}]
             [--enable-vtpm {false, true}]
             [--encryption-at-host {false, true}]
             [--ephemeral-os-disk {false, true}]
             [--ephemeral-os-disk-placement {CacheDisk, ResourceDisk}]
             [--eviction-policy {Deallocate, Delete}]
             [--generate-ssh-keys]
             [--host]
             [--host-group]
             [--image]
             [--license-type {None, RHEL_BASE, RHEL_BASESAPAPPS, RHEL_BASESAPHA, RHEL_BYOS, RHEL_ELS_6, RHEL_EUS, RHEL_SAPAPPS, RHEL_SAPHA, SLES, SLES_BYOS, SLES_HPC, SLES_SAP, SLES_STANDARD, UBUNTU, UBUNTU_PRO, Windows_Client, Windows_Server}]
             [--location]
             [--max-price]
             [--nic-delete-option]
             [--nics]
             [--no-wait]
             [--nsg]
             [--nsg-rule {NONE, RDP, SSH}]
             [--os-disk-caching {None, ReadOnly, ReadWrite}]
             [--os-disk-delete-option {Delete, Detach}]
             [--os-disk-encryption-set]
             [--os-disk-name]
             [--os-disk-secure-vm-disk-encryption-set]
             [--os-disk-security-encryption-type {DiskWithVMGuestState, NonPersistedTPM, VMGuestStateOnly}]
             [--os-disk-size-gb]
             [--os-type {linux, windows}]
             [--patch-mode {AutomaticByOS, AutomaticByPlatform, ImageDefault, Manual}]
             [--plan-name]
             [--plan-product]
             [--plan-promotion-code]
             [--plan-publisher]
             [--platform-fault-domain]
             [--ppg]
             [--priority {Low, Regular, Spot}]
             [--private-ip-address]
             [--proxy-agent-mode {Audit, Enforce}]
             [--public-ip-address]
             [--public-ip-address-allocation {dynamic, static}]
             [--public-ip-address-dns-name]
             [--public-ip-sku {Basic, Standard}]
             [--role]
             [--scope]
             [--secrets]
             [--security-type {ConfidentialVM, Standard, TrustedLaunch}]
             [--size]
             [--specialized {false, true}]
             [--ssh-dest-key-path]
             [--ssh-key-name]
             [--ssh-key-values]
             [--storage-account]
             [--storage-container-name]
             [--storage-sku]
             [--subnet]
             [--subnet-address-prefix]
             [--tags]
             [--ultra-ssd-enabled {false, true}]
             [--use-unmanaged-disk]
             [--user-data]
             [--v-cpus-available]
             [--v-cpus-per-core]
             [--validate]
             [--vmss]
             [--vnet-address-prefix]
             [--vnet-name]
             [--workspace]
             [--zone]

Examples

Create a default Ubuntu2204 VM with automatic SSH authentication.

az vm create -n MyVm -g MyResourceGroup --image Ubuntu2204

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 from a generalized gallery image version.

az vm create -g MyResourceGroup -n MyVm --image /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.Compute/galleries/myGallery/images/myImage/versions/1.0.0

Create a VM from a specialized gallery image version.

az vm create -g MyResourceGroup -n MyVm --image /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.Compute/galleries/myGallery/images/myImage/versions/1.0.0 --specialized

Create a VM from the latest version of a gallery image

az vm create -g MyResourceGroup -n MyVm --image /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.Compute/galleries/myGallery/images/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 a VM by attaching to an unmanaged operating system disk from a VHD blob uri.

az vm create -g MyResourceGroup -n MyVm --attach-os-disk https://vhd1234.blob.core.windows.net/vhds/osdisk1234.vhd --os-type linux --use-unmanaged-disk

Create an Debian11 VM using a cloud-init script for configuration. See: https://docs.microsoft.com/azure/virtual-machines/linux/using-cloud-init.

az vm create -g MyResourceGroup -n MyVm --image Debian11 --custom-data MyCloudInitScript.yml

Create a Debian11 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 Debian11 --vnet-name MyVnet --subnet subnet1 \
    --availability-set MyAvailabilitySet --public-ip-address-dns-name MyUniqueDnsName \
    --ssh-key-values @key-file

Create a simple Ubuntu Linux VM with a public IP address, DNS entry, two data disks (10GB and 20GB), and then generate RSA ssh key pairs.

az vm create -n MyVm -g MyResourceGroup --public-ip-address-dns-name MyUniqueDnsName \
    --image Ubuntu2204 --data-disk-sizes-gb 10 20 --size Standard_DS2_v2 \
    --generate-ssh-keys

Create a Debian11 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 debian11 --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 CentOS85Gen2 --assign-identity [system] --scope /subscriptions/99999999-1bf0-4dda-aec3-cb9272f09590/MyResourceGroup/myRG/providers/Microsoft.Storage/storageAccounts/storage1 --role Contributor

Create a Debian11 VM with a user assigned identity.

az vm create -n MyVm -g rg1 --image Debian11 --assign-identity /subscriptions/99999999-1bf0-4dda-aec3-cb9272f09590/resourcegroups/myRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myID

Create a Debian11 VM with both system and user assigned identity.

az vm create -n MyVm -g rg1 --image Debian11 --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 CentOS85Gen2 --zone 1

Create multiple VMs. In this example, 3 VMs are created. They are MyVm0, MyVm1, MyVm2.

az vm create -n MyVm -g MyResourceGroup --image CentOS85Gen2 --count 3

Create a VM from shared gallery image

az vm create -n MyVm -g MyResourceGroup --image /SharedGalleries/{gallery_unique_name}/Images/{image}/Versions/{version}

Create a VM from community gallery image

az vm create -n MyVm -g MyResourceGroup --image /CommunityGalleries/{gallery_unique_name}/Images/{image}/Versions/{version}

Required Parameters

--name -n

Name of the virtual machine.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--accelerated-networking

Enable accelerated networking. Unless specified, CLI will enable it based on machine image and size.

accepted values: false, true
--accept-term

Accept the license agreement and privacy statement.

--admin-password

Password for the VM if authentication type is 'Password'.

--admin-username

Username for the VM. Default value is current username of OS. If the default value is system reserved, then default value will be set to azureuser. Please refer to https://docs.microsoft.com/rest/api/compute/virtualmachines/createorupdate#osprofile to get a full list of reserved values.

--asgs

Space-separated list of existing application security groups to associate with the VM.

--assign-identity

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-data-disks

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-os-disk

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.

--authentication-type

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.

accepted values: all, password, ssh
--availability-set

Name or ID of an existing availability set to add the VM to. None by default.

--boot-diagnostics-storage

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.

--capacity-reservation-group --crg
Preview

The ID or name of the capacity reservation group that is used to allocate. Pass in "None" to disassociate the capacity reservation group. Please note that if you want to delete a VM/VMSS that has been associated with capacity reservation group, you need to disassociate the capacity reservation group first.

--computer-name

The host OS name of the virtual machine. Defaults to the name of the VM.

--count
Preview

Number of virtual machines to create. Value range is [2, 250], inclusive. Don't specify this parameter if you want to create a normal single VM. The VMs are created in parallel. The output of this command is an array of VMs instead of one single VM. Each VM has its own public IP, NIC. VNET and NSG are shared. It is recommended that no existing public IP, NIC, VNET and NSG are in resource group. When --count is specified, --attach-data-disks, --attach-os-disk, --boot-diagnostics-storage, --computer-name, --host, --host-group, --nics, --os-disk-name, --private-ip-address, --public-ip-address, --public-ip-address-dns-name, --storage-account, --storage-container-name, --subnet, --use-unmanaged-disk, --vnet-name are not allowed.

--custom-data

Custom init script file or text (cloud-init, cloud-config, etc..).

--data-disk-caching

Storage caching type for data disk(s), including 'None', 'ReadOnly', 'ReadWrite', etc. Use a singular value to apply on all disks, or use <lun>=<vaule1> <lun>=<value2> to configure individual disk.

--data-disk-delete-option

Specify whether data disk should be deleted or detached upon VM deletion. If a single data disk is attached, the allowed values are Delete and Detach. For multiple data disks are attached, please use "<data_disk>=Delete <data_disk2>=Detach" to configure each disk.

--data-disk-encryption-sets

Names or IDs (space delimited) of disk encryption sets for data disks.

--data-disk-sizes-gb

Space-separated empty managed data disk sizes in GB to create.

--disable-integrity-monitoring-autoupgrade

Disable auto upgrade of guest attestation extension for Trusted Launch enabled VMs and VMSS.

default value: False
--disk-controller-type
Preview

Specify the disk controller type configured for the VM or VMSS.

accepted values: NVMe, SCSI
--edge-zone

The name of edge zone.

--enable-agent

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.

accepted values: false, true
--enable-auto-update

Indicate whether Automatic Updates is enabled for the Windows virtual machine.

accepted values: false, true
--enable-hibernation

The flag that enable or disable hibernation capability on the VM.

accepted values: false, true
--enable-hotpatching

Patch VMs without requiring a reboot. --enable-agent must be set and --patch-mode must be set to AutomaticByPlatform.

accepted values: false, true
--enable-integrity-monitoring

Enable installing Microsoft propietary and not security supported guest attestation extension and enabling System Assigned Identity for Trusted Launch enabled VMs and VMSS.

default value: False
--enable-proxy-agent

Specify whether proxy agent feature should be enabled on the virtual machine or virtual machine scale set.

accepted values: false, true
--enable-secure-boot

Enable secure boot.

accepted values: false, true
--enable-vtpm

Enable vTPM.

accepted values: false, true
--encryption-at-host

Enable Host Encryption for the VM or VMSS. This will enable the encryption for all the disks including Resource/Temp disk at host itself.

accepted values: false, true
--ephemeral-os-disk

Allows you to create an OS disk directly on the host node, providing local disk performance and faster VM/VMSS reimage time.

accepted values: false, true
--ephemeral-os-disk-placement --ephemeral-placement

Only applicable when used with --ephemeral-os-disk. Allows you to choose the Ephemeral OS disk provisioning location.

accepted values: CacheDisk, ResourceDisk
--eviction-policy

The eviction policy for the Spot priority virtual machine. Default eviction policy is Deallocate for a Spot priority virtual machine.

accepted values: Deallocate, Delete
--generate-ssh-keys

Generate SSH public and private RSA key files if missing. The keys will be stored in the ~/.ssh directory.

default value: False
--host
Preview

Resource ID of the dedicated host that the VM will reside in. --host and --host-group can't be used together.

--host-group
Preview

Name or resource ID of the dedicated host group that the VM will reside in. --host and --host-group can't be used together.

--image

The name of the operating system image as a URN alias, URN, custom image name or ID, custom image version ID, or VHD blob URI. In addition, it also supports shared gallery image. Please use the image alias including the version of the distribution you want to use. For example: please use Debian11 instead of Debian.' This parameter is required unless using --attach-os-disk. Valid URN format: "Publisher:Offer:Sku:Version". For more information, see https://docs.microsoft.com/azure/virtual-machines/linux/cli-ps-findimage.

value from: az sig image-version show-shared, az vm image list, az vm image show
--license-type

Specifies that the Windows image or disk was licensed on-premises. To enable Azure Hybrid Benefit for Windows Server, use 'Windows_Server'. To enable Multi-tenant Hosting Rights for Windows 10, use 'Windows_Client'. For more information see the Azure Windows VM online docs.

accepted values: None, RHEL_BASE, RHEL_BASESAPAPPS, RHEL_BASESAPHA, RHEL_BYOS, RHEL_ELS_6, RHEL_EUS, RHEL_SAPAPPS, RHEL_SAPHA, SLES, SLES_BYOS, SLES_HPC, SLES_SAP, SLES_STANDARD, UBUNTU, UBUNTU_PRO, Windows_Client, Windows_Server
--location -l

Location in which to create VM and related resources. If default location is not configured, will default to the resource group's location.

--max-price
Preview

The maximum price (in US Dollars) you are willing to pay for a Spot VM/VMSS. -1 indicates that the Spot VM/VMSS should not be evicted for price reasons.

--nic-delete-option

Specify what happens to the network interface when the VM is deleted. Use a singular value to apply on all resources, or use = to configure the delete behavior for individual resources. Possible options are Delete and Detach.

--nics

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.

--no-wait

Do not wait for the long-running operation to finish.

default value: False
--nsg

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 ('""' in Azure CLI using PowerShell or --% operator).

--nsg-rule

NSG rule to create when creating a new NSG. Defaults to open ports for allowing RDP on Windows and allowing SSH on Linux. NONE represents no NSG rule.

accepted values: NONE, RDP, SSH
--os-disk-caching

Storage caching type for the VM OS disk. Default: ReadWrite.

accepted values: None, ReadOnly, ReadWrite
--os-disk-delete-option

Specify the behavior of the managed disk when the VM gets deleted i.e whether the managed disk is deleted or detached.

accepted values: Delete, Detach
--os-disk-encryption-set

Name or ID of disk encryption set for OS disk.

--os-disk-name

The name of the new VM OS disk.

--os-disk-secure-vm-disk-encryption-set

Specify the customer managed disk encryption set resource ID or name for the managed disk that is used for customer managed key encrypted Confidential VM OS disk and VM guest blob.

--os-disk-security-encryption-type

Specify the encryption type of the OS managed disk.

accepted values: DiskWithVMGuestState, NonPersistedTPM, VMGuestStateOnly
--os-disk-size-gb

OS disk size in GB to create.

--os-type

Type of OS installed on a custom VHD. Do not use when specifying an URN or URN alias.

accepted values: linux, windows
--patch-mode

Mode of in-guest patching to IaaS virtual machine. Allowed values for Windows VM: AutomaticByOS, AutomaticByPlatform, Manual. Allowed values for Linux VM: AutomaticByPlatform, ImageDefault. Manual - You control the application of patches to a virtual machine. You do this by applying patches manually inside the VM. In this mode, automatic updates are disabled; the paramater --enable-auto-update must be false. AutomaticByOS - The virtual machine will automatically be updated by the OS. The parameter --enable-auto-update must be true. AutomaticByPlatform - the virtual machine will automatically updated by the OS. ImageDefault - The virtual machine's default patching configuration is used. The parameter --enable-agent and --enable-auto-update must be true.

accepted values: AutomaticByOS, AutomaticByPlatform, ImageDefault, Manual
--plan-name

Plan name.

--plan-product

Plan product.

--plan-promotion-code

Plan promotion code.

--plan-publisher

Plan publisher.

--platform-fault-domain

Specify the scale set logical fault domain into which the virtual machine will be created. By default, the virtual machine will be automatically assigned to a fault domain that best maintains balance across available fault domains. This is applicable only if the virtualMachineScaleSet property of this virtual machine is set. The virtual machine scale set that is referenced, must have platform fault domain count. This property cannot be updated once the virtual machine is created. Fault domain assignment can be viewed in the virtual machine instance view.

--ppg

The name or ID of the proximity placement group the VM should be associated with.

--priority

Priority. Use 'Spot' to run short-lived workloads in a cost-effective way. 'Low' enum will be deprecated in the future. Please use 'Spot' to deploy Azure spot VM and/or VMSS. Default to Regular.

accepted values: Low, Regular, Spot
--private-ip-address

Static private IP address (e.g. 10.0.0.5).

--proxy-agent-mode

Specify the mode that proxy agent will execute on if the feature is enabled.

accepted values: Audit, Enforce
--public-ip-address

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 ('""' in Azure CLI using PowerShell or --% operator). For Azure CLI using powershell core edition 7.3.4, specify or "" (--public-ip-address or --public-ip-address "").

--public-ip-address-allocation
accepted values: dynamic, static
--public-ip-address-dns-name

Globally unique DNS name for a newly created public IP.

--public-ip-sku

Public IP SKU. The public IP is supported to be created on edge zone only when it is 'Standard'.

accepted values: Basic, Standard
default value: Standard
--role

Role name or id the system assigned identity will have.

--scope

Scope that the system assigned identity can access.

--secrets

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)"}] }].

--security-type

Specify the security type of the virtual machine.

accepted values: ConfidentialVM, Standard, TrustedLaunch
--size

The VM size to be created. See https://azure.microsoft.com/pricing/details/virtual-machines/ for size info.

default value: Standard_DS1_v2
value from: az vm list-sizes
--specialized

Indicate whether the source image is specialized.

accepted values: false, true
--ssh-dest-key-path

Destination file path on the VM for the SSH key. If the file already exists, the specified key(s) are appended to the file. Destination path for SSH public keys is currently limited to its default value "/home/username/.ssh/authorized_keys" due to a known issue in Linux provisioning agent.

--ssh-key-name

Use it as public key in virtual machine. It should be an existing SSH key resource in Azure.

--ssh-key-values

Space-separated list of SSH public keys or public key file paths.

--storage-account

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.

--storage-container-name

Only applicable when used with --use-unmanaged-disk. Name of the storage container for the VM OS disk. Default: vhds.

--storage-sku

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, Premium_ZRS, StandardSSD_ZRS, PremiumV2_LRS.

--subnet

The name of the subnet when creating a new VNet or referencing an existing one. Can also reference an existing subnet by ID. If both vnet-name and subnet are omitted, an appropriate VNet and subnet will be selected automatically, or a new one will be created.

--subnet-address-prefix

The subnet IP address prefix to use when creating a new VNet in CIDR format.

default value: 10.0.0.0/24
--tags

Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.

--ultra-ssd-enabled

Enables or disables the capability to have 1 or more managed data disks with UltraSSD_LRS storage account.

accepted values: false, true
--use-unmanaged-disk

Do not use managed disk to persist VM.

default value: False
--user-data

UserData for the VM. It can be passed in as file or string.

--v-cpus-available

Specify the number of vCPUs available.

--v-cpus-per-core

Specify the ratio of vCPU to physical core. Setting this property to 1 also means that hyper-threading is disabled.

--validate

Generate and validate the ARM template without creating any resources.

default value: False
--vmss

Name or ID of an existing virtual machine scale set that the virtual machine should be assigned to. None by default.

--vnet-address-prefix

The IP address prefix to use when creating a new VNet in CIDR format.

default value: 10.0.0.0/16
--vnet-name

Name of the virtual network when creating a new one or referencing an existing one.

--workspace
Preview

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.

--zone -z

Availability zone into which to provision the resource.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm deallocate

Deallocate a VM so that computing resources are no longer allocated (charges no longer apply). The status will change from 'Stopped' to 'Stopped (Deallocated)'.

az vm deallocate [--hibernate {0, 1, f, false, n, no, t, true, y, yes}]
                 [--ids]
                 [--name]
                 [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                 [--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.

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.

az vm deallocate --name MyVm --no-wait --resource-group MyResourceGroup

Optional Parameters

--hibernate

Optional parameter to hibernate a virtual machine. (Feature in Preview).

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm delete

Delete a VM.

az vm delete [--force-deletion]
             [--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

--force-deletion

Optional parameter to force delete virtual machines. Default value is None.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

default value: False
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--yes -y

Do not prompt for confirmation.

default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm generalize

Mark a VM as generalized, allowing it to be imaged for multiple deployments.

az vm generalize [--ids]
                 [--name]
                 [--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.

az vm deallocate --ids vms_ids
az vm generalize --ids vms_ids
az vm capture --ids vms_ids --vhd-name-prefix MyPrefix

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

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

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm install-patches

Install patches on a VM.

az vm install-patches --maximum-duration
                      --reboot-setting {Always, IfRequired, Never}
                      [--classifications-to-include-linux {Critical, Other, Security}]
                      [--classifications-to-include-win {Critical, Definition, FeaturePack, Security, ServicePack, Tools, UpdateRollUp, Updates}]
                      [--exclude-kbs-requiring-reboot {false, true}]
                      [--ids]
                      [--kb-numbers-to-exclude]
                      [--kb-numbers-to-include]
                      [--name]
                      [--no-wait]
                      [--package-name-masks-to-exclude]
                      [--package-name-masks-to-include]
                      [--resource-group]
                      [--subscription]

Examples

Install patches on a windows VM, allowing the maximum amount of time to be 4 hours, and the VM will reboot if required during the software update operation.

az vm install-patches -g MyResourceGroup -n MyVm --maximum-duration PT4H --reboot-setting IfRequired --classifications-to-include-win Critical Security --exclude-kbs-requiring-reboot true

Install patches on a linux VM, allowing the maximum amount of time to be 4 hours, and the VM will reboot if required during the software update operation.

az vm install-patches -g MyResourceGroup -n MyVm --maximum-duration PT4H --reboot-setting IfRequired --classifications-to-include-linux Critical

Required Parameters

--maximum-duration

Specify the maximum amount of time that the operation will run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours).

--reboot-setting

Define when it is acceptable to reboot a VM during a software update operation.

accepted values: Always, IfRequired, Never

Optional Parameters

--classifications-to-include-linux

Space-separated list of classifications to include for Linux VM.

accepted values: Critical, Other, Security
--classifications-to-include-win

Space-separated list of classifications to include for Windows VM.

accepted values: Critical, Definition, FeaturePack, Security, ServicePack, Tools, UpdateRollUp, Updates
--exclude-kbs-requiring-reboot

Filter out KBs that don't have a reboot behavior of 'NeverReboots' when this is set. Applicable to Windows VM only.

accepted values: false, true
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--kb-numbers-to-exclude

Space-separated list of KBs to exclude in the patch operation. Applicable to Windows VM only.

--kb-numbers-to-include

Space-separated list of KBs to include in the patch operation. Applicable to Windows VM only.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

default value: False
--package-name-masks-to-exclude

Space-separated list of packages to exclude in the patch operation. Format: packageName_packageVersion. Applicable to Linux VM only.

--package-name-masks-to-include

Space-separated list of packages to include in the patch operation. Format: packageName_packageVersion. Applicable to Linux VM only.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm list

List details of Virtual Machines.

--resource-group can pass in an empty string as a parameter, which will output all VM information under the subscription. For more information on querying information about Virtual Machines, see https://docs.microsoft.com/cli/azure/query-az-cli2.

az vm list [--resource-group]
           [--show-details]
           [--vmss]

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

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--show-details -d

Show public ip address, FQDN, and power states. command will run slow.

default value: False
--vmss

List VM instances in a specific VMSS. Please specify the VMSS id or VMSS name.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

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

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm list-sizes

List available sizes for VMs.

az vm list-sizes [--ids]
                 [--location]
                 [--subscription]

Examples

List the available VM sizes in the West US region.

az vm list-sizes -l westus

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--location -l

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm list-skus

Get details for compute-related resource SKUs.

This command incorporates subscription level restriction, offering the most accurate information.

az vm list-skus [--all {false, true}]
                [--location]
                [--resource-type]
                [--size]
                [--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

--all

Show all information including vm sizes not available under the current subscription.

accepted values: false, true
--location -l

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

--resource-type -r

Resource types e.g. "availabilitySets", "snapshots", "disks", etc.

--size -s

Size name, partial name is accepted.

--zone -z

Show skus supporting availability zones.

accepted values: false, true
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm list-usage

List available usage resources for VMs.

az vm list-usage --location

Examples

Get the compute resource usage for the West US region.

az vm list-usage -l westus

Required Parameters

--location -l

Location. Values from: az account list-locations. You can configure the default location using az configure --defaults location=<location>.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

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

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm open-port

Opens a VM to inbound traffic on specified ports.

Adds a security rule to the network security group (NSG) that is attached to the VM's network interface (NIC) or subnet. The existing NSG will be used or a new one will be created. The rule name is 'open-port-{port}' and will overwrite an existing rule with this name. For multi-NIC VMs, or for more fine-grained control, use the appropriate network commands directly (nsg rule create, etc).

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 ports 555, 557, 558, and 559 to inbound traffic with the highest priority.

az vm open-port -g MyResourceGroup -n MyVm --port 555,557-559 --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

--port

The port or port range (ex: 80-100) to open inbound traffic to. Use '*' to allow traffic to all ports. Use comma separated values to specify more than one port or port range.

Optional Parameters

--apply-to-subnet

Allow inbound traffic on the subnet instead of the NIC.

default value: False
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the virtual machine to open inbound traffic on.

--nsg-name

The name of the network security group to create if one does not exist. Ignored if an NSG already exists.

--priority

Rule priority, between 100 (highest priority) and 4096 (lowest priority). Must be unique for each rule in the collection.

default value: 900
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm perform-maintenance

The operation to perform maintenance on a virtual machine.

az vm perform-maintenance [--ids]
                          [--name]
                          [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                          [--resource-group]
                          [--subscription]

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm reapply

Reapply VMs.

az vm reapply [--ids]
              [--name]
              [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
              [--resource-group]
              [--subscription]

Examples

Reapply a VM.

az vm reapply -g MyResourceGroup -n MyVm

Reapply all VMs in a resource group.

az vm reapply --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm redeploy

Redeploy an existing VM.

az vm redeploy [--ids]
               [--name]
               [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
               [--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

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm reimage

Reimage (upgrade the operating system) a virtual machine.

Reimage (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should be updated accordingly before performing the reimage.

az vm reimage [--admin-password]
              [--custom-data]
              [--exact-version]
              [--ids]
              [--name]
              [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
              [--resource-group]
              [--subscription]
              [--temp-disk {0, 1, f, false, n, no, t, true, y, yes}]

Examples

Reimage a virtual machine.

az vm reimage --name MyVm --resource-group MyResourceGroup --admin-password MyPassword --custom-data "dGVzdA==" --temp-disk false --exact-version 0.1

Optional Parameters

--admin-password

Specifies the password of the administrator account.

--custom-data

Specifies a base-64 encoded string of custom data.

--exact-version

Specifies in decimal number, the version the OS disk should be reimaged to. If exact version is not provided, the OS disk is reimaged to the existing version of OS Disk.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--temp-disk

Specifies whether to reimage temp disk. Default value: false. Note: This temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

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

--size

The VM size.

value from: az vm list-vm-resize-options

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

default value: False
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

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

Force the VM to restart by redeploying it. Use if the VM is unresponsive.

default value: False
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

default value: False
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm show

Get the details of a VM.

az vm show [--ids]
           [--include-user-data]
           [--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

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--include-user-data -u

Include the user data properties in the query result.

default value: False
--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--show-details -d

Show public ip address, FQDN, and power states. command will run slow.

default value: False
--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm simulate-eviction

Simulate the eviction of a Spot VM.

az vm simulate-eviction [--ids]
                        [--name]
                        [--resource-group]
                        [--subscription]

Examples

Simulate the eviction of a Spot VM.

az vm simulate-eviction --resource-group MyResourceGroup --name MyVm

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm start

Start a stopped VM.

az vm start [--ids]
            [--name]
            [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
            [--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.

az vm start --name MyVm --no-wait --resource-group MyResourceGroup

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name --vm-name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm stop

Power off (stop) a running VM.

The VM will continue to be billed. To avoid this, you can deallocate the VM through "az vm deallocate".

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

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

default value: False
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--skip-shutdown

Skip shutdown and power-off immediately.

default value: False
--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm update

Update the properties of a VM.

Update VM objects and properties using paths that correspond to 'az vm show'.

az vm update [--add]
             [--capacity-reservation-group]
             [--disk-caching]
             [--disk-controller-type {NVMe, SCSI}]
             [--enable-hibernation {false, true}]
             [--enable-proxy-agent {false, true}]
             [--enable-secure-boot {false, true}]
             [--enable-vtpm {false, true}]
             [--ephemeral-os-disk-placement {CacheDisk, ResourceDisk}]
             [--force-string]
             [--host]
             [--host-group]
             [--ids]
             [--license-type {None, RHEL_BASE, RHEL_BASESAPAPPS, RHEL_BASESAPHA, RHEL_BYOS, RHEL_ELS_6, RHEL_EUS, RHEL_SAPAPPS, RHEL_SAPHA, SLES, SLES_BYOS, SLES_HPC, SLES_SAP, SLES_STANDARD, UBUNTU, UBUNTU_PRO, Windows_Client, Windows_Server}]
             [--max-price]
             [--name]
             [--no-wait]
             [--os-disk]
             [--ppg]
             [--priority {Low, Regular, Spot}]
             [--proxy-agent-mode {Audit, Enforce}]
             [--remove]
             [--resource-group]
             [--security-type {TrustedLaunch}]
             [--set]
             [--size]
             [--subscription]
             [--ultra-ssd-enabled {false, true}]
             [--user-data]
             [--v-cpus-available]
             [--v-cpus-per-core]
             [--workspace]
             [--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

Add an existing VM to a dedicated host

az vm deallocate -n name -g group
az vm update -n name -g group --host my-host
az vm start -n name -g group

Add an existing VM to a dedicated host group

az vm deallocate -n name -g group
az vm update -n name -g group --host-group my-host-group
az vm start -n name -g group

Optional Parameters

--add

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>.

default value: []
--capacity-reservation-group --crg
Preview

The ID or name of the capacity reservation group that is used to allocate. Pass in "None" to disassociate the capacity reservation group. Please note that if you want to delete a VM/VMSS that has been associated with capacity reservation group, you need to disassociate the capacity reservation group first.

--disk-caching

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.

--disk-controller-type
Preview

Specify the disk controller type configured for the VM or VMSS.

accepted values: NVMe, SCSI
--enable-hibernation

The flag that enable or disable hibernation capability on the VM.

accepted values: false, true
--enable-proxy-agent

Specify whether proxy agent feature should be enabled on the virtual machine or virtual machine scale set.

accepted values: false, true
--enable-secure-boot

Enable secure boot.

accepted values: false, true
--enable-vtpm

Enable vTPM.

accepted values: false, true
--ephemeral-os-disk-placement --ephemeral-placement

Only applicable when used with --size. Allows you to choose the Ephemeral OS disk provisioning location.

accepted values: CacheDisk, ResourceDisk
--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

default value: False
--host
Preview

Resource ID of the dedicated host that the VM will reside in. --host and --host-group can't be used together. You should deallocate the VM before update, and start the VM after update. Please check out help for more examples.

--host-group
Preview

Name or resource ID of the dedicated host group that the VM will reside in. --host and --host-group can't be used together. You should deallocate the VM before update, and start the VM after update. Please check out help for more examples.

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--license-type

Specifies that the Windows image or disk was licensed on-premises. To enable Azure Hybrid Benefit for Windows Server, use 'Windows_Server'. To enable Multi-tenant Hosting Rights for Windows 10, use 'Windows_Client'. For more information see the Azure Windows VM online docs.

accepted values: None, RHEL_BASE, RHEL_BASESAPAPPS, RHEL_BASESAPHA, RHEL_BYOS, RHEL_ELS_6, RHEL_EUS, RHEL_SAPAPPS, RHEL_SAPHA, SLES, SLES_BYOS, SLES_HPC, SLES_SAP, SLES_STANDARD, UBUNTU, UBUNTU_PRO, Windows_Client, Windows_Server
--max-price
Preview

The maximum price (in US Dollars) you are willing to pay for a Spot VM/VMSS. -1 indicates that the Spot VM/VMSS should not be evicted for price reasons.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

default value: False
--os-disk

Managed OS disk ID or name to swap to.

--ppg

The name or ID of the proximity placement group the VM should be associated with.

--priority

Priority. Use 'Spot' to run short-lived workloads in a cost-effective way. 'Low' enum will be deprecated in the future. Please use 'Spot' to deploy Azure spot VM and/or VMSS. Default to Regular.

accepted values: Low, Regular, Spot
--proxy-agent-mode

Specify the mode that proxy agent will execute on if the feature is enabled.

accepted values: Audit, Enforce
--remove

Remove a property or an element from a list. Example: --remove property.list <indexToRemove> OR --remove propertyToRemove.

default value: []
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--security-type

Specify the security type of the virtual machine.

accepted values: TrustedLaunch
--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=<value>.

default value: []
--size
Preview

The new size of the virtual machine. See https://azure.microsoft.com/pricing/details/virtual-machines/ for size info.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--ultra-ssd-enabled

Enables or disables the capability to have 1 or more managed data disks with UltraSSD_LRS storage account.

accepted values: false, true
--user-data

UserData for the VM. It can be passed in as file or string. If empty string is passed in, the existing value will be deleted.

--v-cpus-available

Specify the number of vCPUs available.

--v-cpus-per-core

Specify the ratio of vCPU to physical core. Setting this property to 1 also means that hyper-threading is disabled.

--workspace
Preview

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.

--write-accelerator

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.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

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

--created

Wait until created with 'provisioningState' at 'Succeeded'.

default value: False
--custom

Wait until the condition satisfies a custom JMESPath query. E.g. provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running'].

--deleted

Wait until deleted.

default value: False
--exists

Wait until the resource exists.

default value: False
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--interval

Polling interval in seconds.

default value: 30
--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--timeout

Maximum wait in seconds.

default value: 3600
--updated

Wait until updated with provisioningState at 'Succeeded'.

default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.