Virtual Machines - Run Command
VM でコマンドを実行します。
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand?api-version=2024-03-01
URI パラメーター
名前 | / | 必須 | 型 | 説明 |
---|---|---|---|---|
resource
|
path | True |
string |
リソース グループの名前。 |
subscription
|
path | True |
string |
Microsoft Azure サブスクリプションを一意に識別するサブスクリプション資格情報。 サブスクリプション ID は、全ての修理依頼についてURI の一部を生じさせます。 |
vm
|
path | True |
string |
仮想マシンの名前。 |
api-version
|
query | True |
string |
クライアント API のバージョン。 |
要求本文
Media Types: "application/json", "text/json"
名前 | 必須 | 型 | 説明 |
---|---|---|---|
commandId | True |
string |
run コマンド ID。 |
parameters |
run コマンド パラメーター。 |
||
script |
string[] |
省略可能。 実行するスクリプト。 この値を指定すると、指定されたスクリプトによってコマンドの既定のスクリプトがオーバーライドされます。 |
応答
名前 | 型 | 説明 |
---|---|---|
200 OK |
OK Media Types: "application/json", "text/json" |
|
202 Accepted |
同意 Media Types: "application/json", "text/json" |
セキュリティ
azure_auth
Azure Active Directory OAuth2 フロー
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名前 | 説明 |
---|---|
user_impersonation | ユーザー アカウントの借用 |
例
VirtualMachineRunCommand
Sample Request
POST https://management.azure.com/subscriptions/24fb23e3-6ba3-41f0-9b6e-e41131d5d61e/resourceGroups/crptestar98131/providers/Microsoft.Compute/virtualMachines/vm3036/runCommand?api-version=2024-03-01
{
"commandId": "RunPowerShellScript"
}
Sample Response
{
"value": [
{
"code": "ComponentStatus/StdOut/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"message": "This is a sample script with parameters value1 value2"
},
{
"code": "ComponentStatus/StdErr/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"message": ""
}
]
}
Location: https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/westus/operations/{operationId}&monitor=true&api-version=2024-03-01
定義
名前 | 説明 |
---|---|
Instance |
インスタンス ビューの状態。 |
Run |
仮想マシンのパラメーターをキャプチャします。 |
Run |
実行コマンド パラメーターのプロパティについて説明します。 |
Run |
|
Status |
レベル コード。 |
InstanceViewStatus
インスタンス ビューの状態。
名前 | 型 | 説明 |
---|---|---|
code |
string |
ステータス コード。 |
displayStatus |
string |
状態の短いローカライズ可能なラベル。 |
level |
レベル コード。 |
|
message |
string |
アラートやエラー メッセージを含む詳細なステータス メッセージ。 |
time |
string |
状態の時刻。 |
RunCommandInput
仮想マシンのパラメーターをキャプチャします。
名前 | 型 | 説明 |
---|---|---|
commandId |
string |
run コマンド ID。 |
parameters |
run コマンド パラメーター。 |
|
script |
string[] |
省略可能。 実行するスクリプト。 この値を指定すると、指定されたスクリプトによってコマンドの既定のスクリプトがオーバーライドされます。 |
RunCommandInputParameter
実行コマンド パラメーターのプロパティについて説明します。
名前 | 型 | 説明 |
---|---|---|
name |
string |
run コマンド パラメーター名。 |
value |
string |
run コマンド パラメーターの値。 |
RunCommandResult
名前 | 型 | 説明 |
---|---|---|
value |
コマンド操作の応答を実行します。 |
StatusLevelTypes
レベル コード。
名前 | 型 | 説明 |
---|---|---|
Error |
string |
|
Info |
string |
|
Warning |
string |