az vmss run-command

Commands

Name Description Type Status
az vmss run-command create

The operation to Create the VMSS VM run command.

Core GA
az vmss run-command delete

The operation to delete the run command.

Core GA
az vmss run-command invoke

Execute a specific run command on a Virtual Machine Scale Set instance.

Core GA
az vmss run-command list

The operation to get all run commands of an instance in Virtual Machine Scaleset.

Core GA
az vmss run-command show

The operation to get the VMSS run command.

Core GA
az vmss run-command update

The operation to update the VMSS run command.

Core GA

az vmss run-command create

The operation to Create the VMSS VM run command.

az vmss run-command create --instance-id
                           --name
                           --resource-group
                           --vmss-name
                           [--async-execution {false, true}]
                           [--command-id]
                           [--error-blob-uri]
                           [--location]
                           [--no-wait]
                           [--output-blob-uri]
                           [--parameters]
                           [--protected-parameters]
                           [--run-as-password]
                           [--run-as-user]
                           [--script]
                           [--script-uri]
                           [--tags]
                           [--timeout-in-seconds]

Examples

Create VMSS run command.

az vmss run-command create --resource-group "myResourceGroup" --instance-id "0" --location "West US" --async-execution false --parameters arg1=param1 arg2=value1 --run-as-password "<runAsPassword>" --run-as-user "user1" --script "Write-Host Hello World!" --timeout-in-seconds 3600 --run-command-name "myRunCommand" --vmss-name "myVMSS"

Required Parameters

--instance-id

The instance ID of the virtual machine.

--name --run-command-name

The name of the virtual machine run command.

--resource-group -g

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

--vmss-name

The name of the VM scale set.

Optional Parameters

--async-execution

Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete.

Accepted values: false, true
--command-id

Specify a commandId of predefined built-in script.

--error-blob-uri

Uri (without SAS) to an append blob where the script error stream will be uploaded.

--location -l

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

--no-wait

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

Default value: False
--output-blob-uri

Uri (without SAS) to an append blob where the script output will be uploaded.

--parameters

The parameters used by the script.

Usage: --parameters arg1=XX arg2=XX.

--protected-parameters

The parameters used by the script.

Usage: --protected-parameters credentials=somefoo secret=somebar.

--run-as-password

Password if needed for using run-as-user parameter. It will be encrypted and not logged.

--run-as-user

By default script process runs under system/root user. Specify custom user to host the process.

--script

Specify the script content to be executed on the VM.

--script-uri

Specify the script download location.

--tags

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

--timeout-in-seconds

The timeout in seconds to execute the run command.

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 vmss run-command delete

The operation to delete the run command.

az vmss run-command delete --name
                           [--ids]
                           [--instance-id]
                           [--no-wait]
                           [--resource-group]
                           [--subscription]
                           [--vmss-name]
                           [--yes]

Examples

The operation to delete the VMSS run command..

az vmss run-command delete --resource-group "myResourceGroup" --instance-id "0" --run-command-name "myRunCommand" --vmss-name "myVMSS"

Required Parameters

--name --run-command-name

The name of the virtual machine run command.

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.

--instance-id

The instance ID of the virtual machine.

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

--vmss-name

The name of the VM scale set.

--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 vmss run-command invoke

Execute a specific run command on a Virtual Machine Scale Set instance.

az vmss run-command show returns helpful information on each run-command. Discover Run command-id's via az vmss run-command list.

az vmss run-command invoke --command-id
                           [--ids]
                           [--instance-id]
                           [--name]
                           [--parameters]
                           [--resource-group]
                           [--scripts]
                           [--subscription]

Examples

Install nginx on a VMSS instance.

az vmss run-command invoke -g MyResourceGroup -n MyVMSS --command-id RunShellScript \ --instance-id 0 --scripts "sudo apt-get update && sudo apt-get install -y nginx"

Invoke a run-command with parameters on a VMSS instance.

az vmss run-command invoke -g MyResourceGroup -n MyVMSS --command-id RunShellScript \ --instance-id 4 --scripts 'echo $1 $2' --parameters hello world

Invoke command on all VMSS instances using the VMSS instance resource IDs. Note: "@-" expands to stdin.

az vmss list-instances -n MyVMSS -g my-rg --query "[].id" --output tsv | \
az vmss run-command invoke --scripts 'echo $1 $2' --parameters hello world  \
    --command-id RunShellScript --ids @-

Run powershell script on a windows VMSS instance with parameters. Script supplied inline. Be wary of single-quoting in CMD.exe.

az vmss run-command invoke  --command-id RunPowerShellScript --name win-vm -g my-resource-group \
    --scripts 'param([string]$arg1,[string]$arg2)' \
    'Write-Host This is a sample script with parameters $arg1 and $arg2' \
    --parameters 'arg1=somefoo' 'arg2=somebar' --instance-id 2

Run powershell script on a windows VMSS instance with parameters. Script supplied from file.

# script.ps1
#   param(
#       [string]$arg1,
#       [string]$arg2
#   )
#   Write-Host This is a sample script with parameters $arg1 and $arg2

az vmss run-command invoke  --command-id RunPowerShellScript --name win-vm -g my-resource-group \
    --scripts @script.ps1 --parameters "arg1=somefoo" "arg2=somebar" --instance-id 5

Required Parameters

--command-id

The command id.

Value from: az vmss run-command list

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.

--instance-id

Scale set VM instance id.

--name -n

Scale set name. You can configure the default using az configure --defaults vmss=<name>.

--parameters

Space-separated parameters in the format of '[name=]value'.

--resource-group -g

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

--scripts

Space-separated script lines. Use @{file} to load script from a file.

--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 vmss run-command list

The operation to get all run commands of an instance in Virtual Machine Scaleset.

az vmss run-command list --instance-id
                         --resource-group
                         --vmss-name
                         [--expand]

Examples

List run commands in Vmss instance.

az vmss run-command list --resource-group "myResourceGroup" --vmss-name "myVMSS" --instance-id "0"

Required Parameters

--instance-id

The instance ID of the virtual machine.

--resource-group -g

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

--vmss-name

The name of the VM scale set.

Optional Parameters

--expand

The expand expression to apply on the operation.

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 vmss run-command show

The operation to get the VMSS run command.

az vmss run-command show --name
                         [--expand]
                         [--ids]
                         [--instance-id]
                         [--instance-view]
                         [--resource-group]
                         [--subscription]
                         [--vmss-name]

Examples

Get VMSS run commands.

az vmss run-command show --instance-id "0" --resource-group "myResourceGroup" --run-command-name "myRunCommand" --vmss-name "myVMSS"

Required Parameters

--name --run-command-name

The name of the virtual machine run command.

Optional Parameters

--expand
Deprecated

Argument 'expand' has been deprecated and will be removed in a future release.

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.

--instance-id

The instance ID of the virtual machine.

--instance-view

The instance view of a run command.

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.

--vmss-name

The name of the VM scale set.

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 vmss run-command update

The operation to update the VMSS run command.

az vmss run-command update --name
                           [--async-execution {false, true}]
                           [--command-id]
                           [--error-blob-uri]
                           [--ids]
                           [--instance-id]
                           [--location]
                           [--no-wait]
                           [--output-blob-uri]
                           [--parameters]
                           [--protected-parameters]
                           [--resource-group]
                           [--run-as-password]
                           [--run-as-user]
                           [--script]
                           [--script-uri]
                           [--subscription]
                           [--tags]
                           [--timeout-in-seconds]
                           [--vmss-name]

Examples

Update VMSS run command.

az vmss run-command update --resource-group "myResourceGroup" --instance-id "0" --location "West US" --async-execution false --parameters arg1=param1 arg2=value1 --run-as-password "<runAsPassword>" --run-as-user "user1" --script "Write-Host Hello World!" --timeout-in-seconds 3600 --run-command-name "myRunCommand" --vmss-name "myVMSS"

Required Parameters

--name --run-command-name

The name of the virtual machine run command.

Optional Parameters

--async-execution

Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete.

Accepted values: false, true
--command-id

Specify a commandId of predefined built-in script.

--error-blob-uri

Uri (without SAS) to an append blob where the script error stream will be uploaded.

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

--instance-id

The instance ID of the virtual machine.

--location -l

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

--no-wait

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

Default value: False
--output-blob-uri

Uri (without SAS) to an append blob where the script output will be uploaded.

--parameters

The parameters used by the script.

Usage: --parameters arg1=XX arg2=XX.

--protected-parameters

The parameters used by the script.

Usage: --protected-parameters credentials=somefoo secret=somebar.

--resource-group -g

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

--run-as-password

Password if needed for using run-as-user parameter. It will be encrypted and not logged.

--run-as-user

By default script process runs under system/root user. Specify custom user to host the process.

--script

Specify the script content to be executed on the VM.

--script-uri

Specify the script download location.

--subscription

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

--tags

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

--timeout-in-seconds

The timeout in seconds to execute the run command.

--vmss-name

The name of the VM scale set.

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.