az vm run-command

Commands

az vm run-command invoke Execute a specific run command on a vm.
az vm run-command list Lists all available run commands for a subscription in a location.
az vm run-command show Gets specific run command for a subscription in a location.

az vm run-command invoke

Execute a specific run command on a vm.

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

Examples

install nginx on a vm

az vm run-command invoke -g MyResourceGroup -n MyVm --command-id RunShellScript --scripts "sudo apt-get update && sudo apt-get install -y nginx"

invoke command with parameters

az vm run-command invoke -g MyResourceGroup -n MyVm --command-id RunShellScript --scripts 'echo $1 $2' --parameters hello world

Required Parameters

--command-id

The command id. Use 'az vm run-command list' to get the list.

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<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

Script lines separated by whites spaces. Use @{file} to load from a file.

--subscription

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

az vm run-command list

Lists all available run commands for a subscription in a location.

az vm run-command list --location
[--subscription]

Required Parameters

--location -l

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

Optional Parameters

--subscription

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

az vm run-command show

Gets specific run command for a subscription in a location.

az vm run-command show --command-id
--location
[--subscription]

Required Parameters

--command-id

The command id. Use 'az vm run-command list' to get the list.

--location -l

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

Optional Parameters

--subscription

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