Share via


az connectedmachine run-command

Note

This reference is part of the connectedmachine extension for the Azure CLI (version 2.57.0 or higher). The extension will automatically install the first time you run an az connectedmachine run-command command. Learn more about extensions.

This command group is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Manage run commands on an Azure Arc-Enabled Server.

Commands

Name Description Type Status
az connectedmachine run-command create

Create a run command.

Extension Preview
az connectedmachine run-command delete

Delete a run command.

Extension Preview
az connectedmachine run-command list

Get all the run commands of a non-Azure machine.

Extension Preview
az connectedmachine run-command show

Get a run command.

Extension Preview
az connectedmachine run-command update

Update operation to create or update a run command.

Extension Preview
az connectedmachine run-command wait

Place the CLI in a waiting state until a condition is met.

Extension Preview

az connectedmachine run-command create

Preview

Command group 'az connectedmachine run-command' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Create a run command.

az connectedmachine run-command create --machine-name
                                       --name --run-command-name
                                       --resource-group
                                       [--async-execution {0, 1, f, false, n, no, t, true, y, yes}]
                                       [--command-id]
                                       [--error-blob-id --error-blob-managed-identity]
                                       [--error-blob-uri]
                                       [--location]
                                       [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                                       [--output-blob-id --output-blob-managed-identity]
                                       [--output-blob-uri]
                                       [--parameters]
                                       [--protected-parameters]
                                       [--run-as-password]
                                       [--run-as-user]
                                       [--script]
                                       [--script-uri]
                                       [--script-uri-id --script-uri-managed-identity]
                                       [--tags]
                                       [--timeout-in-seconds]

Examples

Sample command for run-command create

az connectedmachine run-command create --resource-group myResourceGroup --location "WestUS" --async false --parameters "[{"name":"param1","value":"value1"}]" --password "<runAsPassword>" --user "user1" --script "Write-Host Hello World!" --timeout 3600 --name myRunCommand --machine-name myMachine --subscription mySubscription
az connectedmachine run-command create --resource-group myResourceGroup --location "WestUS" --script "Write-Host Hello World!" --name myRunCommand --machine-name myMachine --output-uri "outputuri" --subscription mySubscription

Required Parameters

--machine-name

The name of the hybrid machine.

--name --run-command-name -n

The name of the run command.

--resource-group -g

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

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--async-execution

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

Property Value
Parameter group: Properties Arguments
Default value: False
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--command-id

Specifies the commandId of predefined built-in script.

Property Value
Parameter group: Source Arguments
--error-blob-id --error-blob-managed-identity

User-assigned managed identity that has access to errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--error-blob-uri

Specifies the Azure storage blob where script error stream will be uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to provide the VM access to the blob. Refer errorBlobManagedIdentity parameter.

Property Value
Parameter group: Properties Arguments
--location -l

The geo-location where the resource lives When not specified, the location of the resource group will be used.

Property Value
Parameter group: RunCommandProperties Arguments
--no-wait

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

Property Value
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--output-blob-id --output-blob-managed-identity

User-assigned managed identity that has access to outputBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--output-blob-uri

Specifies the Azure storage blob where script output stream will be uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to provide the VM access to the blob. Refer outputBlobManagedIdentity parameter.

Property Value
Parameter group: Properties Arguments
--parameters

The parameters used by the script. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--protected-parameters

The parameters used by the script. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--run-as-password

Specifies the user account password on the machine when executing the run command.

Property Value
Parameter group: Properties Arguments
--run-as-user

Specifies the user account on the machine when executing the run command.

Property Value
Parameter group: Properties Arguments
--script

Specifies the script content to be executed on the machine.

Property Value
Parameter group: Source Arguments
--script-uri

Specifies the script download location. It can be either SAS URI of an Azure storage blob with read access or public URI.

Property Value
Parameter group: Source Arguments
--script-uri-id --script-uri-managed-identity

User-assigned managed identity that has access to scriptUri in case of Azure storage blob. Use an empty object in case of system-assigned identity. Make sure the Azure storage blob exists, and managed identity has been given access to blob's container with 'Storage Blob Data Reader' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Source Arguments
--tags

Resource tags. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: RunCommandProperties Arguments
--timeout-in-seconds

The timeout in seconds to execute the run command.

Property Value
Parameter group: Properties Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--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.

Property Value
Default value: False

az connectedmachine run-command delete

Preview

Command group 'az connectedmachine run-command' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Delete a run command.

az connectedmachine run-command delete [--ids]
                                       [--machine-name]
                                       [--name --run-command-name]
                                       [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                                       [--resource-group]
                                       [--subscription]
                                       [--yes]

Examples

Sample command for run-command delete

az connectedmachine run-command delete --resource-group myResourceGroup --machine-name myMachine --name myRunCommand

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

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

Property Value
Parameter group: Resource Id Arguments
--machine-name

The name of the hybrid machine.

Property Value
Parameter group: Resource Id Arguments
--name --run-command-name -n

The name of the run command.

Property Value
Parameter group: Resource Id Arguments
--no-wait

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

Property Value
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--resource-group -g

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

Property Value
Parameter group: Resource Id Arguments
--subscription

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

Do not prompt for confirmation.

Property Value
Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az connectedmachine run-command list

Preview

Command group 'az connectedmachine run-command' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Get all the run commands of a non-Azure machine.

az connectedmachine run-command list --machine-name
                                     --resource-group
                                     [--expand]
                                     [--max-items]
                                     [--next-token]

Examples

Sample command for run-command list

az connectedmachine run-command list --resource-group myResourceGroup --machine-name myMachine --subscription mySubscription

Required Parameters

--machine-name

The name of the hybrid machine.

--resource-group -g

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

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--expand

The expand expression to apply on the operation.

--max-items

Total number of items to return in the command's output. If the total number of items available is more than the value specified, a token is provided in the command's output. To resume pagination, provide the token value in --next-token argument of a subsequent command.

Property Value
Parameter group: Pagination Arguments
--next-token

Token to specify where to start paginating. This is the token value from a previously truncated response.

Property Value
Parameter group: Pagination Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--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.

Property Value
Default value: False

az connectedmachine run-command show

Preview

Command group 'az connectedmachine run-command' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Get a run command.

az connectedmachine run-command show [--ids]
                                     [--machine-name]
                                     [--name --run-command-name]
                                     [--resource-group]
                                     [--subscription]

Examples

Sample command for run-command show

az connectedmachine run-command show --resource-group myResourceGroup --machine-name myMachine --name myRunCommand

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

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

Property Value
Parameter group: Resource Id Arguments
--machine-name

The name of the hybrid machine.

Property Value
Parameter group: Resource Id Arguments
--name --run-command-name -n

The name of the run command.

Property Value
Parameter group: Resource Id Arguments
--resource-group -g

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

Property Value
Parameter group: Resource Id Arguments
--subscription

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

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az connectedmachine run-command update

Preview

Command group 'az connectedmachine run-command' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Update operation to create or update a run command.

az connectedmachine run-command update [--add]
                                       [--async-execution {0, 1, f, false, n, no, t, true, y, yes}]
                                       [--error-blob-id --error-blob-managed-identity]
                                       [--error-blob-uri]
                                       [--force-string {0, 1, f, false, n, no, t, true, y, yes}]
                                       [--ids]
                                       [--machine-name]
                                       [--name --run-command-name]
                                       [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                                       [--output-blob-id --output-blob-managed-identity]
                                       [--output-blob-uri]
                                       [--parameters]
                                       [--protected-parameters]
                                       [--remove]
                                       [--resource-group]
                                       [--run-as-password]
                                       [--run-as-user]
                                       [--set]
                                       [--source]
                                       [--subscription]
                                       [--tags]
                                       [--timeout-in-seconds]

Examples

sample command for run-command update

az connetcedmachine run-command update --resource-group myResourceGroup --name myRunCommand --machine-name myMachine --subscription mySubscription --tags Tag1=Value1

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

Property Value
Parameter group: Generic Update Arguments
--async-execution

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

Property Value
Parameter group: Properties Arguments
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--error-blob-id --error-blob-managed-identity

User-assigned managed identity that has access to errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--error-blob-uri

Specifies the Azure storage blob where script error stream will be uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to provide the VM access to the blob. Refer errorBlobManagedIdentity parameter.

Property Value
Parameter group: Properties Arguments
--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

Property Value
Parameter group: Generic Update Arguments
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--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.

Property Value
Parameter group: Resource Id Arguments
--machine-name

The name of the hybrid machine.

Property Value
Parameter group: Resource Id Arguments
--name --run-command-name -n

The name of the run command.

Property Value
Parameter group: Resource Id Arguments
--no-wait

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

Property Value
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--output-blob-id --output-blob-managed-identity

User-assigned managed identity that has access to outputBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--output-blob-uri

Specifies the Azure storage blob where script output stream will be uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to provide the VM access to the blob. Refer outputBlobManagedIdentity parameter.

Property Value
Parameter group: Properties Arguments
--parameters

The parameters used by the script. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--protected-parameters

The parameters used by the script. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--remove

Remove a property or an element from a list. Example: --remove property.list <indexToRemove> OR --remove propertyToRemove.

Property Value
Parameter group: Generic Update Arguments
--resource-group -g

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

Property Value
Parameter group: Resource Id Arguments
--run-as-password

Specifies the user account password on the machine when executing the run command.

Property Value
Parameter group: Properties Arguments
--run-as-user

Specifies the user account on the machine when executing the run command.

Property Value
Parameter group: Properties Arguments
--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=<value>.

Property Value
Parameter group: Generic Update Arguments
--source

The source of the run command script. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: Properties Arguments
--subscription

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

Resource tags. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: RunCommandProperties Arguments
--timeout-in-seconds

The timeout in seconds to execute the run command.

Property Value
Parameter group: Properties Arguments
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az connectedmachine run-command wait

Preview

Command group 'az connectedmachine run-command' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Place the CLI in a waiting state until a condition is met.

az connectedmachine run-command wait [--created]
                                     [--custom]
                                     [--deleted]
                                     [--exists]
                                     [--ids]
                                     [--interval]
                                     [--machine-name]
                                     [--name --run-command-name]
                                     [--resource-group]
                                     [--subscription]
                                     [--timeout]
                                     [--updated]

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--created

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

Property Value
Parameter group: Wait Condition Arguments
Default value: False
--custom

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

Property Value
Parameter group: Wait Condition Arguments
--deleted

Wait until deleted.

Property Value
Parameter group: Wait Condition Arguments
Default value: False
--exists

Wait until the resource exists.

Property Value
Parameter group: Wait Condition Arguments
Default value: False
--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.

Property Value
Parameter group: Resource Id Arguments
--interval

Polling interval in seconds.

Property Value
Parameter group: Wait Condition Arguments
Default value: 30
--machine-name

The name of the hybrid machine.

Property Value
Parameter group: Resource Id Arguments
--name --run-command-name -n

The name of the run command.

Property Value
Parameter group: Resource Id Arguments
--resource-group -g

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

Property Value
Parameter group: Resource Id Arguments
--subscription

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

Maximum wait in seconds.

Property Value
Parameter group: Wait Condition Arguments
Default value: 3600
--updated

Wait until updated with provisioningState at 'Succeeded'.

Property Value
Parameter group: Wait Condition Arguments
Default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False