次の方法で共有


Virtual Machine Run Commands - Get By Virtual Machine

実行コマンドを取得する操作。

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}?api-version=2025-04-01
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}?api-version=2025-04-01&$expand={$expand}

URI パラメーター

名前 / 必須 説明
resourceGroupName
path True

string

minLength: 1
maxLength: 90

リソース グループの名前。 名前は大文字と小文字が区別されます。

runCommandName
path True

string

VirtualMachineRunCommand の名前

subscriptionId
path True

string

minLength: 1

ターゲット サブスクリプションの ID。

vmName
path True

string

仮想マシンの名前

api-version
query True

string

minLength: 1

この操作に使用する API バージョン。

$expand
query

string

操作に適用する展開式。

応答

名前 説明
200 OK

VirtualMachineRunCommand

Azure 操作は正常に完了しました。

Other Status Codes

CloudError

予期しないエラー応答。

セキュリティ

azure_auth

Azure Active Directory OAuth2 フロー。

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

スコープ

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

Get a run command.

要求のサンプル

GET https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM/runCommands/myRunCommand?api-version=2025-04-01

応答のサンプル

{
  "name": "myRunCommand",
  "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM/runCommands/myRunCommand",
  "type": "Microsoft.Compute/virtualMachines/runCommands",
  "___location": "westus",
  "tags": {
    "tag1": "value1",
    "tag2": "value2"
  },
  "properties": {
    "source": {
      "script": "Write-Host Hello World! ; Remove-Item C:\test\testFile.txt"
    },
    "parameters": [
      {
        "name": "param1",
        "value": "value1"
      },
      {
        "name": "param2",
        "value": "value2"
      }
    ],
    "asyncExecution": false,
    "treatFailureAsDeploymentFailure": false,
    "runAsUser": "user1",
    "timeoutInSeconds": 3600,
    "provisioningState": "Succeeded",
    "outputBlobUri": "https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt",
    "errorBlobUri": "https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt"
  }
}

定義

名前 説明
ApiError

API エラー。

ApiErrorBase

API エラー ベース。

CloudError

コンピュート・サービスからのエラー・レスポンス。

createdByType

リソースを作成した ID の種類。

ExecutionState

スクリプトの実行ステータス。

InnerError

内部エラーの詳細。

InstanceViewStatus

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

RunCommandInputParameter

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

RunCommandManagedIdentity

コマンドの実行で使用されるストレージ BLOB にアクセスできるユーザー割り当てマネージド ID の clientId または objectId (両方ではなく、一方のみ使用) が含まれます。 システム割り当て ID の場合は、空の RunCommandManagedIdentity オブジェクトを使用します。 scriptUri の場合に Azure Storage BLOB が存在し、scriptUri BLOB と BLOB の追加 (outputBlobUri、errorBlobUri) の "Storage Blob Data Contributor" ロールの割り当てを使用して、マネージド ID に BLOB のコンテナーへのアクセス権が付与されていることを確認します。 ユーザーが割り当てた ID の場合は、必ず VM の ID の下に追加してください。 マネージド ID と実行コマンドの詳細については、「https://aka.ms/ManagedIdentityhttps://aka.ms/RunCommandManaged」を参照してください。

ScriptShellTypes

スクリプト シェルの種類。

StatusLevelTypes

レベル コード。

systemData

リソースの作成と最後の変更に関連するメタデータ。

VirtualMachineRunCommand

仮想マシンの実行コマンドについて説明します。

VirtualMachineRunCommandInstanceView

仮想マシン実行コマンドのインスタンスビュー。

VirtualMachineRunCommandScriptSource

コマンドの実行のスクリプトソースについて説明します。 スクリプト ソース (script、scriptUri、commandId、galleryScriptReferenceId) の 1 つだけを使用します。

ApiError

API エラー。

名前 説明
code

string

エラー コード。

details

ApiErrorBase[]

Api エラーの詳細

innererror

InnerError

Api 内部エラー

message

string

エラー メッセージ。

target

string

特定のエラーのターゲット。

ApiErrorBase

API エラー ベース。

名前 説明
code

string

エラー コード。

message

string

エラー メッセージ。

target

string

特定のエラーのターゲット。

CloudError

コンピュート・サービスからのエラー・レスポンス。

名前 説明
error

ApiError

API エラー。

createdByType

リソースを作成した ID の種類。

説明
User
Application
ManagedIdentity
Key

ExecutionState

スクリプトの実行ステータス。

説明
Unknown
Pending
Running
Failed
Succeeded
TimedOut
Canceled

InnerError

内部エラーの詳細。

名前 説明
errordetail

string

内部エラー・メッセージまたは例外ダンプ。

exceptiontype

string

例外タイプ。

InstanceViewStatus

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

名前 説明
code

string

状態コード。

displayStatus

string

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

level

StatusLevelTypes

レベル コード。

message

string

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

time

string (date-time)

状態の時刻。

RunCommandInputParameter

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

名前 説明
name

string

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

value

string

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

RunCommandManagedIdentity

コマンドの実行で使用されるストレージ BLOB にアクセスできるユーザー割り当てマネージド ID の clientId または objectId (両方ではなく、一方のみ使用) が含まれます。 システム割り当て ID の場合は、空の RunCommandManagedIdentity オブジェクトを使用します。 scriptUri の場合に Azure Storage BLOB が存在し、scriptUri BLOB と BLOB の追加 (outputBlobUri、errorBlobUri) の "Storage Blob Data Contributor" ロールの割り当てを使用して、マネージド ID に BLOB のコンテナーへのアクセス権が付与されていることを確認します。 ユーザーが割り当てた ID の場合は、必ず VM の ID の下に追加してください。 マネージド ID と実行コマンドの詳細については、「https://aka.ms/ManagedIdentityhttps://aka.ms/RunCommandManaged」を参照してください。

名前 説明
clientId

string

ユーザー割り当てマネージド ID のクライアント ID (GUID 値)。 ObjectId を指定する場合は使用しないでください。

objectId

string

ユーザー割り当てマネージド ID のオブジェクト ID (GUID 値)。 これが指定されている場合は、ClientId を使用しないでください。

ScriptShellTypes

スクリプト シェルの種類。

説明
Default

デフォルトのスクリプトシェルタイプ。

Powershell7

Powershell7 スクリプト シェル タイプ。

StatusLevelTypes

レベル コード。

説明
Info
Warning
Error

systemData

リソースの作成と最後の変更に関連するメタデータ。

名前 説明
createdAt

string (date-time)

リソース作成のタイムスタンプ (UTC)。

createdBy

string

リソースを作成した ID。

createdByType

createdByType

リソースを作成した ID の種類。

lastModifiedAt

string (date-time)

リソースの最終変更のタイムスタンプ (UTC)

lastModifiedBy

string

リソースを最後に変更した ID。

lastModifiedByType

createdByType

リソースを最後に変更した ID の種類。

VirtualMachineRunCommand

仮想マシンの実行コマンドについて説明します。

名前 説明
id

string

リソースの完全修飾リソース ID。 例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

___location

string

リソースが存在する地理的な場所

name

string

リソースの名前

properties.asyncExecution

boolean

Optional. true に設定すると、スクリプトが開始されるとすぐにプロビジョニングが完了し、スクリプトが完了するまで待機しません。

properties.errorBlobManagedIdentity

RunCommandManagedIdentity

errorBlobUri ストレージ BLOB にアクセスできるユーザー割り当てマネージド ID。 システム割り当て ID の場合は、空のオブジェクトを使用します。 "ストレージ BLOB データ共同作成者" ロールの割り当てを使用して、マネージド ID に BLOB のコンテナーへのアクセス権が付与されていることを確認します。 ユーザー割り当て ID の場合は、必ず VM の ID の下に追加してください。 マネージド ID と実行コマンドの詳細については、https://aka.ms/ManagedIdentityhttps://aka.ms/RunCommandManaged を参照してください。

properties.errorBlobUri

string

スクリプト エラー ストリームをアップロードする Azure Storage BLOB を指定します。 読み取り、追加、作成、書き込みアクセス権を持つ SAS URI を使用するか、マネージド ID を使用して VM に BLOB へのアクセスを提供します。 errorBlobManagedIdentity パラメーターを参照します。

properties.instanceView

VirtualMachineRunCommandInstanceView

仮想マシンの実行コマンド インスタンス ビュー。

properties.outputBlobManagedIdentity

RunCommandManagedIdentity

outputBlobUri ストレージ BLOB にアクセスできるユーザー割り当てマネージド ID。 システム割り当て ID の場合は、空のオブジェクトを使用します。 "ストレージ BLOB データ共同作成者" ロールの割り当てを使用して、マネージド ID に BLOB のコンテナーへのアクセス権が付与されていることを確認します。 ユーザー割り当て ID の場合は、必ず VM の ID の下に追加してください。 マネージド ID と実行コマンドの詳細については、https://aka.ms/ManagedIdentityhttps://aka.ms/RunCommandManaged を参照してください。

properties.outputBlobUri

string

スクリプト出力ストリームをアップロードする Azure Storage BLOB を指定します。 読み取り、追加、作成、書き込みアクセス権を持つ SAS URI を使用するか、マネージド ID を使用して VM に BLOB へのアクセスを提供します。 outputBlobManagedIdentity パラメーターを参照します。

properties.parameters

RunCommandInputParameter[]

スクリプトで使用されるパラメーター。

properties.protectedParameters

RunCommandInputParameter[]

スクリプトで使用されるパラメーター。

properties.provisioningState

string

プロビジョニング状態。応答にのみ表示されます。 treatFailureAsDeploymentFailure を true に設定すると、スクリプトでエラーが発生するとデプロイが失敗し、ProvisioningState は Failed としてマークされます。 treatFailureAsDeploymentFailure を false に設定すると、ProvisioningState は、run コマンドが拡張機能プラットフォームによって実行されたかどうかのみを反映し、スクリプトが失敗した場合にスクリプトが失敗したかどうかは示しません。 スクリプトエラーが発生した場合は、run コマンドのインスタンス ビューを参照して、executionMessage、output、error を表示します。 https://aka.ms/runcommandmanaged#get-execution-status-and-results

properties.runAsPassword

string

実行コマンドの実行時に VM のユーザー アカウント パスワードを指定します。

properties.runAsUser

string

実行コマンドの実行時に VM 上のユーザー アカウントを指定します。

properties.source

VirtualMachineRunCommandScriptSource

実行コマンド スクリプトのソース。

properties.timeoutInSeconds

integer (int32)

run コマンドを実行するためのタイムアウト (秒単位)。

properties.treatFailureAsDeploymentFailure

boolean

Optional. true に設定すると、スクリプト内のエラーはデプロイに失敗し、ProvisioningState は Failed としてマークされます。 false に設定すると、ProvisioningState は、実行コマンドが拡張機能プラットフォームによって実行されたかどうかのみを反映し、スクリプトが失敗した場合にスクリプトが失敗したかどうかを示しません。 スクリプトエラーが発生した場合は、run コマンドのインスタンス ビューを参照して、executionMessage、output、error を表示します。 https://aka.ms/runcommandmanaged#get-execution-status-and-results

systemData

systemData

createdBy および modifiedBy 情報を含む Azure Resource Manager メタデータ。

tags

object

リソース タグ。

type

string

リソースの型。 例: "Microsoft.Compute/virtualMachines" または "Microsoft.Storage/storageAccounts"

VirtualMachineRunCommandInstanceView

仮想マシン実行コマンドのインスタンスビュー。

名前 説明
endTime

string (date-time)

スクリプトの終了時刻。

error

string

スクリプト エラー ストリーム。

executionMessage

string

スクリプト構成エラーまたは実行メッセージを伝達します。

executionState

ExecutionState

スクリプトの実行ステータス。

exitCode

integer (int32)

スクリプトの実行から返される終了コード。

output

string

スクリプト出力ストリーム。

startTime

string (date-time)

スクリプトの開始時刻。

statuses

InstanceViewStatus[]

リソースの状態情報。

VirtualMachineRunCommandScriptSource

コマンドの実行のスクリプトソースについて説明します。 スクリプト ソース (script、scriptUri、commandId、galleryScriptReferenceId) の 1 つだけを使用します。

名前 説明
commandId

string

定義済みの組み込みスクリプトの commandId を指定します。 Linux で使用可能なコマンド ID は、 https://aka.ms/RunCommandManagedLinux#available-commands、Windows の https://aka.ms/RunCommandManagedWindows#available-commands に記載されています。

galleryScriptReferenceId

string

実行する必要があるギャラリー スクリプト バージョンのリソース ID。 ID の例は、/subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Compute/galleries/{galleryName}/scripts/{scriptName}/versions/{version} のようになります。

script

string

VM で実行するスクリプトコンテンツを指定します。

scriptShell

ScriptShellTypes

Optional. スクリプトの実行に使用するシェルを指定します。 これらの値は、拡張機能で予期される値と一致する必要があります。 現在、Windows VM でのみサポートされており、スクリプトは指定されている場合に Powershell 7 を使用します。 Powershell7 パラメーター値を使用するには、Powershell 7 がコンピューターに既にインストールされている必要があります。

scriptUri

string

スクリプトのダウンロード場所を指定します。 読み取りアクセス権を持つ Azure ストレージ BLOB の SAS URI またはパブリック URI のいずれかを指定できます。

scriptUriManagedIdentity

RunCommandManagedIdentity

Azure Storage BLOB の場合に scriptUri にアクセスできるユーザー割り当てマネージド ID。 システム割り当て ID の場合は、空のオブジェクトを使用します。 Azure ストレージ BLOB が存在し、マネージド ID に "ストレージ BLOB データ閲覧者" ロールの割り当てで BLOB のコンテナーへのアクセス権が付与されていることを確認します。 ユーザー割り当て ID の場合は、必ず VM の ID の下に追加してください。 マネージド ID と実行コマンドの詳細については、「https://aka.ms/ManagedIdentityhttps://aka.ms/RunCommandManaged」を参照してください。