az vmss run-command
管理运行命令。
命令
| 名称 | 说明 | 类型 | Status |
|---|---|---|---|
| az vmss run-command create |
创建 VMSS VM 运行命令的操作。 |
Core | GA |
| az vmss run-command delete |
删除作以删除 VMSS VM 运行命令。 |
Core | GA |
| az vmss run-command invoke |
在虚拟机规模集实例上执行特定的运行命令。 |
Core | GA |
| az vmss run-command list |
用于获取虚拟机规模集中实例的所有运行命令的列表作。 |
Core | GA |
| az vmss run-command show |
用于获取 VMSS 运行命令的操作。 |
Core | GA |
| az vmss run-command update |
用于更新 VMSS run 命令的操作。 |
Core | GA |
| az vmss run-command wait |
将 CLI 置于等待状态,直到满足条件。 |
Core | GA |
az vmss run-command create
创建 VMSS VM 运行命令的操作。
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]
示例
创建 VMSS 运行命令。
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"
必需参数
虚拟机的实例 ID。
虚拟机运行命令的名称。
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
VM 规模集的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Optional. 如果设置为 true,则脚本启动后,预配将立即完成,并且不会等待脚本完成。
| 属性 | 值 |
|---|---|
| 接受的值: | false, true |
指定预定义内置脚本的 commandId。
URI (不含 SAS)到追加 blob,其中将上传脚本错误流。
Location.
az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。
不等待长时间运行的操作完成。
| 属性 | 值 |
|---|---|
| 默认值: | False |
URI(没有 SAS)到将上传脚本输出的追加 blob。
脚本使用的参数。
用法:--parameters arg1=XX arg2=XX。
脚本使用的参数。
用法:--protected-parameters credentials=somefoo secret=somebar。
使用运行方式用户参数所需的密码。 它将经过加密且未记录。
默认情况下,脚本进程在系统/根用户下运行。 指定要托管进程的自定义用户。
指定要在 VM 上执行的脚本内容。
指定脚本下载位置。
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。
执行 run 命令的超时(以秒为单位)。
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az vmss run-command delete
删除作以删除 VMSS VM 运行命令。
az vmss run-command delete [--ids]
[--instance-id]
[--name --run-command-name]
[--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
[--resource-group]
[--subscription]
[--vmss-name]
[--yes]
示例
删除 VMSS 运行命令。
az vmss run-command delete --resource-group myResourceGroup --vmss-name myvmScaleSet --instance-id 0 --run-command-name myRunCommand
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
VM 的实例。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
VirtualMachineRunCommand 的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
不等待长时间运行的操作完成。
| 属性 | 值 |
|---|---|
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
VirtualMachineScaleSet 的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
不要提示确认。
| 属性 | 值 |
|---|---|
| 默认值: | False |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az vmss run-command invoke
在虚拟机规模集实例上执行特定的运行命令。
az vmss run-command show 返回有关每个 run-command 的有用信息。 通过 az vmss run-command list发现 Run command-id。
az vmss run-command invoke --command-id
[--ids]
[--instance-id]
[--name]
[--parameters]
[--resource-group]
[--scripts]
[--subscription]
示例
在 VMSS 实例上安装 nginx。
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"
在 VMSS 实例上使用参数调用 Run-command。
az vmss run-command invoke -g MyResourceGroup -n MyVMSS --command-id RunShellScript \ --instance-id 4 --scripts 'echo $1 $2' --parameters hello world
使用 VMSS 实例资源 ID 对所有 VMSS 实例调用命令。 注意:“@-”展开为 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 @-
使用参数在 Windows VMSS 实例上运行 powershell 脚本。 内联提供的脚本。 对 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
使用参数在 Windows VMSS 实例上运行 powershell 脚本。 从文件提供的脚本。
# 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
必需参数
命令 ID。
| 属性 | 值 |
|---|---|
| 值来源: | az vmss run-command list |
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
规模集 VM 实例 ID。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
规模集名称。 可以使用 < a0/a0> 配置默认值 az configure --defaults vmss=<name>。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
以“[name=]value”格式分隔的空间分隔参数。
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
空格分隔的脚本行。 使用 @{file} 从文件加载脚本。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az vmss run-command list
用于获取虚拟机规模集中实例的所有运行命令的列表作。
az vmss run-command list --instance-id
--resource-group
--vmss-name
[--expand]
[--max-items]
[--next-token]
示例
列出 Vmss 实例中的运行命令。
az vmss run-command list --resource-group "myResourceGroup" --vmss-name "myVMSS" --instance-id "0"
必需参数
VM 的实例。
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
VirtualMachineScaleSet 的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
要应用于作的展开表达式。
命令输出中要返回的项总数。 如果可用的项总数大于指定的值,则会在命令的输出中提供令牌。 若要恢复分页,请在后续命令的 --next-token 参数中提供令牌值。
| 属性 | 值 |
|---|---|
| Parameter group: | Pagination Arguments |
用于指定开始分页的位置的令牌。 这是先前截断的响应中的令牌值。
| 属性 | 值 |
|---|---|
| Parameter group: | Pagination Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az vmss run-command show
用于获取 VMSS 运行命令的操作。
az vmss run-command show --name --run-command-name
[--ids]
[--instance-id]
[--instance-view]
[--resource-group]
[--subscription]
[--vmss-name]
示例
获取 VMSS 运行命令。
az vmss run-command show --instance-id "0" --resource-group "myResourceGroup" --run-command-name "myRunCommand" --vmss-name "myVMSS"
必需参数
虚拟机运行命令的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
虚拟机的实例 ID。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
运行命令的实例视图。
| 属性 | 值 |
|---|---|
| 默认值: | False |
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
VM 规模集的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az vmss run-command update
用于更新 VMSS run 命令的操作。
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]
示例
更新 VMSS 运行命令。
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"
必需参数
虚拟机运行命令的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Optional. 如果设置为 true,则脚本启动后,预配将立即完成,并且不会等待脚本完成。
| 属性 | 值 |
|---|---|
| 接受的值: | false, true |
指定预定义内置脚本的 commandId。
URI (不含 SAS)到追加 blob,其中将上传脚本错误流。
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
虚拟机的实例 ID。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
Location.
az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。
不等待长时间运行的操作完成。
| 属性 | 值 |
|---|---|
| 默认值: | False |
URI(没有 SAS)到将上传脚本输出的追加 blob。
脚本使用的参数。
用法:--parameters arg1=XX arg2=XX。
脚本使用的参数。
用法:--protected-parameters credentials=somefoo secret=somebar。
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
使用运行方式用户参数所需的密码。 它将经过加密且未记录。
默认情况下,脚本进程在系统/根用户下运行。 指定要托管进程的自定义用户。
指定要在 VM 上执行的脚本内容。
指定脚本下载位置。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。
执行 run 命令的超时(以秒为单位)。
VM 规模集的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az vmss run-command wait
将 CLI 置于等待状态,直到满足条件。
az vmss run-command wait [--created]
[--custom]
[--deleted]
[--exists]
[--expand]
[--ids]
[--instance-id]
[--interval]
[--name --run-command-name]
[--resource-group]
[--subscription]
[--timeout]
[--updated]
[--vmss-name]
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
等待在“Succeeded”中使用“provisioningState”创建。
| 属性 | 值 |
|---|---|
| Parameter group: | Wait Condition Arguments |
| 默认值: | False |
等待条件满足自定义 JMESPath 查询。 例如 provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']。
| 属性 | 值 |
|---|---|
| Parameter group: | Wait Condition Arguments |
等到删除为止。
| 属性 | 值 |
|---|---|
| Parameter group: | Wait Condition Arguments |
| 默认值: | False |
等待资源存在。
| 属性 | 值 |
|---|---|
| Parameter group: | Wait Condition Arguments |
| 默认值: | False |
要应用于作的展开表达式。
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
VM 的实例。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
轮询间隔(以秒为单位)。
| 属性 | 值 |
|---|---|
| Parameter group: | Wait Condition Arguments |
| 默认值: | 30 |
VirtualMachineRunCommand 的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
最大等待(以秒为单位)。
| 属性 | 值 |
|---|---|
| Parameter group: | Wait Condition Arguments |
| 默认值: | 3600 |
等到 provisioningState 更新为“Succeeded”。
| 属性 | 值 |
|---|---|
| Parameter group: | Wait Condition Arguments |
| 默认值: | False |
VirtualMachineScaleSet 的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |