次の方法で共有


Machine Run Commands - Create Or Update

実行コマンドを作成または更新する操作。

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/runCommands/{runCommandName}?api-version=2024-05-20-preview

URI パラメーター

名前 / 必須 説明
machineName
path True

string

ハイブリッド マシンの名前。

正規表現パターン: [a-zA-Z0-9-_\.]+

resourceGroupName
path True

string

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

runCommandName
path True

string

run コマンドの名前。

正規表現パターン: [a-zA-Z0-9-_\.]+

subscriptionId
path True

string

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

api-version
query True

string

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

要求本文

名前 必須 説明
location True

string

リソースが保存されている地理的な場所

properties.asyncExecution

boolean

省略可能。 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 ストレージ BLOB を指定します。 読み取り、追加、作成、書き込みアクセス権を持つ SAS URI を使用するか、マネージド ID を使用して VM に BLOB へのアクセスを提供します。 errorBlobManagedIdentity パラメーターを参照してください。

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 ストレージ BLOB を指定します。 読み取り、追加、作成、書き込みアクセス権を持つ SAS URI を使用するか、マネージド ID を使用して VM に BLOB へのアクセスを提供します。 outputBlobManagedIdentity パラメーターを参照してください。

properties.parameters

RunCommandInputParameter[]

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

properties.protectedParameters

RunCommandInputParameter[]

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

properties.runAsPassword

string

実行コマンドを実行するときに、コンピューターのユーザー アカウント のパスワードを指定します。

properties.runAsUser

string

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

properties.source

MachineRunCommandScriptSource

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

properties.timeoutInSeconds

integer

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

tags

object

リソース タグ。

応答

名前 説明
200 OK

MachineRunCommand

更新されたリソース

201 Created

MachineRunCommand

作成済み

ヘッダー

  • Location: string
  • Retry-After: integer
  • Azure-AsyncOperation: string
Other Status Codes

ErrorResponse

操作に失敗した理由を説明するエラー応答。

セキュリティ

azure_auth

Azure Active Directory OAuth2 フロー

型: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名前 説明
user_impersonation ユーザー アカウントの借用

Create or Update a Run Command

Sample request

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/machines/myMachine/runCommands/myRunCommand?api-version=2024-05-20-preview

{
  "location": "eastus2",
  "properties": {
    "source": {
      "script": "Write-Host Hello World!"
    },
    "parameters": [
      {
        "name": "param1",
        "value": "value1"
      },
      {
        "name": "param2",
        "value": "value2"
      }
    ],
    "asyncExecution": false,
    "runAsUser": "user1",
    "runAsPassword": "<runAsPassword>",
    "timeoutInSeconds": 3600,
    "outputBlobUri": "https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt",
    "errorBlobUri": "https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt"
  }
}

Sample response

{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/runcommands/myRunCommand",
  "name": "myRunCommand",
  "type": "Microsoft.HybridCompute/machines/runcommands",
  "location": "eastus2",
  "properties": {
    "source": {
      "script": "Write-Host Hello World!"
    },
    "parameters": [
      {
        "name": "param1",
        "value": "value1"
      },
      {
        "name": "param2",
        "value": "value2"
      }
    ],
    "asyncExecution": false,
    "runAsUser": "user1",
    "timeoutInSeconds": 3600,
    "outputBlobUri": "https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt",
    "errorBlobUri": "https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt",
    "provisioningState": "Succeeded"
  }
}
Location: {callbackUrl}
Retry-After: 200
Azure-AsyncOperation: {callbackUri}
{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/runcommands/myRunCommand",
  "name": "myRunCommand",
  "type": "Microsoft.HybridCompute/machines/runcommands",
  "location": "eastus2",
  "properties": {
    "source": {
      "script": "Write-Host Hello World!"
    },
    "parameters": [
      {
        "name": "param1",
        "value": "value1"
      },
      {
        "name": "param2",
        "value": "value2"
      }
    ],
    "asyncExecution": false,
    "runAsUser": "user1",
    "timeoutInSeconds": 3600,
    "outputBlobUri": "https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt",
    "errorBlobUri": "https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt",
    "provisioningState": "Creating"
  }
}

定義

名前 説明
createdByType

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

ErrorAdditionalInfo

リソース管理エラーの追加情報。

ErrorDetail

エラーの詳細。

ErrorResponse

エラー応答

ExecutionState

スクリプトの実行状態。

ExtensionsResourceStatus

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

ExtensionsStatusLevelTypes

レベル コード。

MachineRunCommand

実行コマンドについて説明します

MachineRunCommandInstanceView

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

MachineRunCommandScriptSource

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

RunCommandInputParameter

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

RunCommandManagedIdentity

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

systemData

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

createdByType

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

名前 説明
Application

string

Key

string

ManagedIdentity

string

User

string

ErrorAdditionalInfo

リソース管理エラーの追加情報。

名前 説明
info

object

追加情報。

type

string

追加情報の種類。

ErrorDetail

エラーの詳細。

名前 説明
additionalInfo

ErrorAdditionalInfo[]

エラーの追加情報。

code

string

エラー コード。

details

ErrorDetail[]

エラーの詳細です。

message

string

エラー メッセージ。

target

string

エラーのターゲット。

ErrorResponse

エラー応答

名前 説明
error

ErrorDetail

error オブジェクト。

ExecutionState

スクリプトの実行状態。

名前 説明
Canceled

string

Failed

string

Pending

string

Running

string

Succeeded

string

TimedOut

string

Unknown

string

ExtensionsResourceStatus

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

名前 説明
code

string

ステータス コード。

displayStatus

string

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

level

ExtensionsStatusLevelTypes

レベル コード。

message

string

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

time

string

状態の時刻。

ExtensionsStatusLevelTypes

レベル コード。

名前 説明
Error

string

Info

string

Warning

string

MachineRunCommand

実行コマンドについて説明します

名前 既定値 説明
id

string

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

location

string

リソースが保存されている地理的な場所

name

string

リソースの名前

properties.asyncExecution

boolean

False

省略可能。 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 ストレージ BLOB を指定します。 読み取り、追加、作成、書き込みアクセス権を持つ SAS URI を使用するか、マネージド ID を使用して VM に BLOB へのアクセスを提供します。 errorBlobManagedIdentity パラメーターを参照してください。

properties.instanceView

MachineRunCommandInstanceView

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

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 ストレージ BLOB を指定します。 読み取り、追加、作成、書き込みアクセス権を持つ SAS URI を使用するか、マネージド ID を使用して VM に BLOB へのアクセスを提供します。 outputBlobManagedIdentity パラメーターを参照してください。

properties.parameters

RunCommandInputParameter[]

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

properties.protectedParameters

RunCommandInputParameter[]

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

properties.provisioningState

string

プロビジョニング状態。これは応答にのみ表示されます。

properties.runAsPassword

string

実行コマンドを実行するときに、コンピューターのユーザー アカウント のパスワードを指定します。

properties.runAsUser

string

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

properties.source

MachineRunCommandScriptSource

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

properties.timeoutInSeconds

integer

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

systemData

systemData

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

tags

object

リソース タグ。

type

string

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

MachineRunCommandInstanceView

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

名前 説明
endTime

string

スクリプトの終了時刻。

error

string

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

executionMessage

string

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

executionState

ExecutionState

スクリプトの実行状態。

exitCode

integer

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

output

string

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

startTime

string

スクリプトの開始時刻。

statuses

ExtensionsResourceStatus[]

状態情報。

MachineRunCommandScriptSource

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

名前 説明
commandId

string

定義済みの組み込みスクリプトの commandId を指定します。

script

string

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

scriptUri

string

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

scriptUriManagedIdentity

RunCommandManagedIdentity

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

RunCommandInputParameter

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

名前 説明
name

string

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

value

string

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

RunCommandManagedIdentity

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

名前 説明
clientId

string

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

objectId

string

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

systemData

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

名前 説明
createdAt

string

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

createdBy

string

リソースを作成した ID。

createdByType

createdByType

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

lastModifiedAt

string

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

lastModifiedBy

string

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

lastModifiedByType

createdByType

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