az vmss run-command
管理執行命令。
命令
| 名稱 | Description | 類型 | 狀態 |
|---|---|---|---|
| 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 執行命令的作業。 |
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"
必要參數
虛擬機的實例標識碼。
虛擬機執行命令的名稱。
資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。
VM 擴展集的名稱。
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
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] ...]。使用 「清除現有的標記」。
執行命令的逾時以秒為單位。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 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
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
VM 的執行個體。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
VirtualMachineRunCommand 的名稱。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
請勿等候長時間執行的作業完成。
| 屬性 | 值 |
|---|---|
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
VirtualMachineScaleSet 的名稱。
| 屬性 | 值 |
|---|---|
| 參數群組: | 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探索執行命令標識碼。
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 實例資源識別碼在所有 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
必要參數
命令標識碼。
| 屬性 | 值 |
|---|---|
| 值來源: | az vmss run-command list |
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
擴展集 VM 實例識別碼。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
擴展集名稱。 您可以使用 來設定預設值 az configure --defaults vmss=<name>。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
以 『[name=]value』 格式的空格分隔參數。
資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
以空格分隔的腳本行。 使用 @{file} 從檔案載入腳本。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
| 屬性 | 值 |
|---|---|
| 參數群組: | 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 的名稱。
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
要套用至作業的展開表達式。
命令輸出中要傳回的項目總數。 如果可用的專案總數超過指定的值,則會在命令的輸出中提供令牌。 若要繼續分頁,請在後續命令的 --next-token 自變數中提供令牌值。
| 屬性 | 值 |
|---|---|
| 參數群組: | Pagination Arguments |
標記,指定要開始分頁的位置。 這是先前截斷回應中的令牌值。
| 屬性 | 值 |
|---|---|
| 參數群組: | Pagination Arguments |
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 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"
必要參數
虛擬機執行命令的名稱。
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
虛擬機的實例標識碼。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
執行命令的實例檢視。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
VM 擴展集的名稱。
| 屬性 | 值 |
|---|---|
| 參數群組: | 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 執行命令的作業。
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"
必要參數
虛擬機執行命令的名稱。
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
Optional. 如果設定為 true,則一開始腳本就會完成布建,且不會等待腳本完成。
| 屬性 | 值 |
|---|---|
| 接受的值: | false, true |
指定預先定義內建腳本的 commandId。
URI (不含 SAS)至附加 Blob,其中會上傳腳本錯誤數據流。
一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
虛擬機的實例標識碼。
| 屬性 | 值 |
|---|---|
| 參數群組: | 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>來設定預設群組。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
如果需要使用執行身分用戶參數,請使用密碼。 將會加密且未記錄。
根據預設,腳本進程會在系統/根使用者下執行。 指定要裝載進程的自定義使用者。
指定要在 VM 上執行的文稿內容。
指定文稿下載位置。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
以空格分隔的標記:key[=value] [key[=value] ...]。使用 「清除現有的標記」。
執行命令的逾時以秒為單位。
VM 擴展集的名稱。
| 屬性 | 值 |
|---|---|
| 參數群組: | 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]
選擇性參數
下列參數是選擇性參數,但視內容而定,命令可能需要一或多個參數才能成功執行。
請等候在 'Succeeded' 使用 'provisioningState' 建立。
| 屬性 | 值 |
|---|---|
| 參數群組: | Wait Condition Arguments |
| 預設值: | False |
等到條件符合自定義 JMESPath 查詢為止。 例如 provisioningState!='InProgress', instanceView.statuses[?code=='PowerState/running']。
| 屬性 | 值 |
|---|---|
| 參數群組: | Wait Condition Arguments |
等到刪除為止。
| 屬性 | 值 |
|---|---|
| 參數群組: | Wait Condition Arguments |
| 預設值: | False |
等候資源存在。
| 屬性 | 值 |
|---|---|
| 參數群組: | Wait Condition Arguments |
| 預設值: | False |
要套用至作業的展開表達式。
一或多個資源識別碼(以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
VM 的執行個體。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
輪詢間隔以秒為單位。
| 屬性 | 值 |
|---|---|
| 參數群組: | Wait Condition Arguments |
| 預設值: | 30 |
VirtualMachineRunCommand 的名稱。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
資源組名。 您可以使用 az configure --defaults group=<name>來設定預設群組。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID來設定預設訂用帳戶。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
以秒為單位的等候上限。
| 屬性 | 值 |
|---|---|
| 參數群組: | Wait Condition Arguments |
| 預設值: | 3600 |
等到 provisioningState 更新為 'Succeeded'。
| 屬性 | 值 |
|---|---|
| 參數群組: | Wait Condition Arguments |
| 預設值: | False |
VirtualMachineScaleSet 的名稱。
| 屬性 | 值 |
|---|---|
| 參數群組: | Resource Id Arguments |
全域參數
提高日誌詳細程度以顯示所有調試日誌。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
| 屬性 | 值 |
|---|---|
| 預設值: | False |
輸出格式。
| 屬性 | 值 |
|---|---|
| 預設值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。
| 屬性 | 值 |
|---|---|
| 預設值: | False |