az vmss run-command
Manage run commands on a Virtual Machine Scale Set.
For more information, see https://docs.microsoft.com/azure/virtual-machines/windows/run-command or https://docs.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
--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
Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete.
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.
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.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
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.
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
The name of the virtual machine run command.
Optional Parameters
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.
The instance ID of the virtual machine.
Do not wait for the long-running operation to finish.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
The name of the VM scale set.
Do not prompt for confirmation.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
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.
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.
Optional Parameters
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.
Scale set VM instance id.
Scale set name. You can configure the default using az configure --defaults vmss=<name>
.
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>
.
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
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
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.
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 expand expression to apply on the operation.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
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.
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
The name of the virtual machine run command.
Optional Parameters
Argument 'expand' has been deprecated and will be removed in a future release.
The expand expression to apply on the operation.
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.
The instance ID of the virtual machine.
The instance view of a run command.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
The name of the VM scale set.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
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.
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
The name of the virtual machine run command.
Optional Parameters
Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete.
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.
The instance ID of the virtual machine.
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.
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>
.
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
.
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.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
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.
Azure CLI