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 パラメーター

名前 / 必須 説明
resourceGroupName
path True

string

リソース グループの名前。

subscriptionId
path True

string

Microsoft Azure サブスクリプションを一意に識別するサブスクリプション資格情報。 サブスクリプション ID は、すべてのサービス呼び出しの URI の一部を形成します。

vmName
path True

string

仮想マシンの名前。

api-version
query True

string

クライアント API のバージョン。

要求本文

Media Types: "application/json", "text/json"

名前 必須 説明
commandId True

string

実行コマンド ID。

parameters

RunCommandInputParameter[]

run コマンド のパラメーター。

script

string[]

随意。 実行するスクリプト。 この値を指定すると、指定されたスクリプトによってコマンドの既定のスクリプトがオーバーライドされます。

応答

名前 説明
200 OK

RunCommandResult

わかりました

Media Types: "application/json", "text/json"

202 Accepted

受け入れ られる

Media Types: "application/json", "text/json"

セキュリティ

azure_auth

Azure Active Directory OAuth2 フロー

型: oauth2
フロー: implicit
Authorization URL (承認 URL): https://login.microsoftonline.com/common/oauth2/authorize

スコープ

名前 説明
user_impersonation ユーザー アカウントを偽装する

VirtualMachineRunCommand

要求のサンプル

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"
}

応答のサンプル

{
  "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

定義

名前 説明
InstanceViewStatus

インスタンス ビューの状態。

RunCommandInput

仮想マシンのパラメーターをキャプチャします。

RunCommandInputParameter

run コマンド パラメーターのプロパティについて説明します。

RunCommandResult
StatusLevelTypes

レベル コード。

InstanceViewStatus

インスタンス ビューの状態。

名前 説明
code

string

状態コード。

displayStatus

string

状態の短いローカライズ可能なラベル。

level

StatusLevelTypes

レベル コード。

message

string

アラートやエラー メッセージを含む詳細なステータス メッセージ。

time

string

状態の時刻。

RunCommandInput

仮想マシンのパラメーターをキャプチャします。

名前 説明
commandId

string

実行コマンド ID。

parameters

RunCommandInputParameter[]

run コマンド のパラメーター。

script

string[]

随意。 実行するスクリプト。 この値を指定すると、指定されたスクリプトによってコマンドの既定のスクリプトがオーバーライドされます。

RunCommandInputParameter

run コマンド パラメーターのプロパティについて説明します。

名前 説明
name

string

run コマンド のパラメーター名。

value

string

run コマンド パラメーターの値。

RunCommandResult

名前 説明
value

InstanceViewStatus[]

コマンド操作の応答を実行します。

StatusLevelTypes

レベル コード。

名前 説明
Error

string

Info

string

Warning

string