az vm extension

Manage extensions on VMs.

Extensions are small applications that provide post-deployment configuration and automation tasks on Azure virtual machines. For example, if a virtual machine requires software installation, anti-virus protection, or Docker configuration, a VM extension can be used to complete these tasks. Extensions can be bundled with a new virtual machine deployment or run against any existing system.

Commands

az vm extension delete

Remove an extension attached to a VM.

az vm extension image

Find the available VM extensions for a subscription and region.

az vm extension image list

List the information on available extensions.

az vm extension image list-names

List the names of available extensions.

az vm extension image list-versions

List the versions for available extensions.

az vm extension image show

Display information for an extension.

az vm extension list

List the extensions attached to a VM.

az vm extension set

Set extensions for a VM.

az vm extension show

Display information about extensions attached to a VM.

az vm extension wait

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

az vm extension delete

Remove an extension attached to a VM.

az vm extension delete [--ids]
                       [--name]
                       [--no-wait]
                       [--resource-group]
                       [--subscription]
                       [--vm-name]

Examples

Use a VM name and extension to delete an extension from a VM.

az vm extension delete -g MyResourceGroup --vm-name MyVm -n extension_name

Delete extensions with IDs containing the string "MyExtension" from a VM.

az vm extension delete --ids \
    $(az resource list --query "[?contains(name, 'MyExtension')].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

Name of the extension.

--no-wait

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

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

--vm-name

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

az vm extension list

List the extensions attached to a VM.

az vm extension list --resource-group
                     --vm-name
                     [--query-examples]
                     [--subscription]

Examples

List attached extensions to a named VM.

az vm extension list -g MyResourceGroup --vm-name MyVm

Required Parameters

--resource-group -g

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

--vm-name

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

Optional Parameters

--query-examples

Recommend JMESPath string for you. You can copy one of the query and paste it after --query parameter within double quotation marks to see the results. You can add one or more positional keywords so that we can give suggestions based on these key words.

--subscription

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

az vm extension set

Set extensions for a VM.

Get extension details from az vm extension image list.

az vm extension set --name
                    --publisher
                    [--extension-instance-name]
                    [--force-update]
                    [--ids]
                    [--no-auto-upgrade {false, true}]
                    [--no-wait]
                    [--protected-settings]
                    [--resource-group]
                    [--settings]
                    [--subscription]
                    [--version]
                    [--vm-name]

Examples

Add a user account to a Linux VM.

az vm extension set -n VMAccessForLinux --publisher Microsoft.OSTCExtensions --version 1.4 \
    --vm-name MyVm --resource-group MyResourceGroup \
    --protected-settings '{"username":"user1", "ssh_key":"ssh_rsa ..."}'

Add a customScript extension to VM(s) specified by --ids.

az vm extension set -n customScript --publisher Microsoft.Azure.Extensions --ids {vm_id}

Required Parameters

--name -n

Name of the extension.

value from: az vm extension image list
--publisher

The name of the extension publisher.

Optional Parameters

--extension-instance-name

Name of extension instance, which can be customized. Default: name of the extension.

--force-update

Force to update even if the extension configuration has not changed.

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

--no-auto-upgrade

If set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.

accepted values: false, true
--no-wait

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

--protected-settings

Protected settings in JSON format for sensitive information like credentials. A JSON file path is also accepted.

--resource-group -g

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

--settings

Extension settings in JSON format. A JSON file path is also accepted.

--subscription

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

--version

The version of the extension. To pin extension version to this value, please specify --no-auto-upgrade.

--vm-name

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

az vm extension show

Display information about extensions attached to a VM.

az vm extension show [--expand]
                     [--ids]
                     [--name]
                     [--query-examples]
                     [--resource-group]
                     [--subscription]
                     [--vm-name]

Examples

Use VM name and extension name to show the extensions attached to a VM.

az vm extension show -g MyResourceGroup --vm-name MyVm -n extension_name

Optional Parameters

--expand

The expand expression to apply on the operation.

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

Name of the extension.

--query-examples

Recommend JMESPath string for you. You can copy one of the query and paste it after --query parameter within double quotation marks to see the results. You can add one or more positional keywords so that we can give suggestions based on these key words.

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

--vm-name

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

az vm extension wait

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

az vm extension wait [--created]
                     [--custom]
                     [--deleted]
                     [--exists]
                     [--expand]
                     [--ids]
                     [--interval]
                     [--name]
                     [--resource-group]
                     [--subscription]
                     [--timeout]
                     [--updated]
                     [--vm-name]

Examples

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

az vm extension wait --created --name MyExtension --resource-group MyResourceGroup --vm-name MyVm

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

az vm extension wait --exists --name MyExtension --resource-group MyResourceGroup --vm-name MyVm

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

az vm extension wait --ids @- --name MyExtension --subscription MySubscription --updated --vm-name MyVm

Optional Parameters

--created

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

--custom

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

--deleted

Wait until deleted.

--exists

Wait until the resource exists.

--expand

The expand expression to apply on the operation.

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

Name of the extension.

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

--vm-name

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