az vmss run-command
Manage run commands on a Virtual Machine Scale Set.
For more information, see https://learn.microsoft.com/azure/virtual-machines/windows/run-command or https://learn.microsoft.com/azure/virtual-machines/linux/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 --run-command-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
The instance ID of the virtual machine.
The name of the virtual machine run command.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The name of the VM scale set.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete.
Property | Value |
---|---|
Accepted values: | false, true |
Specify a commandId of predefined built-in script.
Uri (without SAS) to an append blob where the script error stream will be uploaded.
Location. Values from: az account list-locations
. You can configure the default location using az configure --defaults location=<location>
.
Do not wait for the long-running operation to finish.
Property | Value |
---|---|
Default value: | False |
Uri (without SAS) to an append blob where the script output will be uploaded.
The parameters used by the script.
Usage: --parameters arg1=XX arg2=XX.
The parameters used by the script.
Usage: --protected-parameters credentials=somefoo secret=somebar.
Password if needed for using run-as-user parameter. It will be encrypted and not logged.
By default script process runs under system/root user. Specify custom user to host the process.
Specify the script content to be executed on the VM.
Specify the script download location.
Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.
The timeout in seconds to execute the run command.
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vmss run-command delete
The operation to delete the run command.
az vmss run-command delete --name --run-command-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
The name of the virtual machine run command.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
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.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The instance ID of the virtual machine.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Do not wait for the long-running operation to finish.
Property | Value |
---|---|
Default value: | False |
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The name of the VM scale set.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Do not prompt for confirmation.
Property | Value |
---|---|
Default value: | False |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
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
The command id.
Property | Value |
---|---|
Value from: | az vmss run-command list |
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
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.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Scale set VM instance id.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Scale set name. You can configure the default using az configure --defaults vmss=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Space-separated parameters in the format of '[name=]value'.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Space-separated script lines. Use @{file} to load script from a file.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
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
The instance ID of the virtual machine.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
The name of the VM scale set.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
The expand expression to apply on the operation.
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vmss run-command show
The operation to get the VMSS run command.
az vmss run-command show --name --run-command-name
[--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
The name of the virtual machine run command.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
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.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The instance ID of the virtual machine.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The instance view of a run command.
Property | Value |
---|---|
Default value: | False |
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The name of the VM scale set.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vmss run-command update
The operation to update the VMSS run command.
az vmss run-command update --name --run-command-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
The name of the virtual machine run command.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete.
Property | Value |
---|---|
Accepted values: | false, true |
Specify a commandId of predefined built-in script.
Uri (without SAS) to an append blob where the script error stream will be uploaded.
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.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The instance ID of the virtual machine.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Location. Values from: az account list-locations
. You can configure the default location using az configure --defaults location=<location>
.
Do not wait for the long-running operation to finish.
Property | Value |
---|---|
Default value: | False |
Uri (without SAS) to an append blob where the script output will be uploaded.
The parameters used by the script.
Usage: --parameters arg1=XX arg2=XX.
The parameters used by the script.
Usage: --protected-parameters credentials=somefoo secret=somebar.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Password if needed for using run-as-user parameter. It will be encrypted and not logged.
By default script process runs under system/root user. Specify custom user to host the process.
Specify the script content to be executed on the VM.
Specify the script download location.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.
The timeout in seconds to execute the run command.
The name of the VM scale set.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |