[アーティクル] 2024/10/15
14 人の共同作成者
フィードバック
この記事の内容
使用方法
セキュリティと認証
プロキシ
レート制限
HTTP 動詞
パラメーター
スキーマ
リージョン別の提供状況
ルート エンドポイント
エンドポイント カテゴリ
Versions
インスタンス メタデータ
構成証明済みデータ
マネージド ID
Load Balancer メタデータ
スケジュールされたイベント
さまざまな言語のサンプル コード
エラーとデバッグ
よく寄せられる質問
サポート
製品フィードバック
次のステップ
さらに 18 個を表示
適用対象: ✔️ Linux VM ✔️ Windows VM ✔️ フレキシブル スケール セット
Azure Instance Metadata Service (IMDS) によって、現在実行中の仮想マシン インスタンスに関する情報が提供されます。 これを使用して、仮想マシンの管理と構成を行うことができます。
この情報には、SKU、ストレージ、ネットワークの構成、今後のメンテナンス イベントなどがあります。 使用できるデータの完全な一覧については、エンドポイント カテゴリの概要 に関するページを参照してください。
IMDS は、仮想マシン (VM) のインスタンスとスケール セット インスタンスを実行するために使用できます。 Azure Resource Manager を使用して作成および管理されている VM は、すべてのエンドポイントでサポートされます。 クラシック デプロイ モデルを使用して作成された VM は、構成証明されたカテゴリと、インスタンス カテゴリのネットワーク部分のみでサポートされます。 構成証明されたエンドポイントでのサポートは、制限された範囲内のみとなります。
IMDS は、既知のルーティング不可能な IP アドレス (169.254.169.254
) で使用できる REST API です。 VM 内からのみアクセスできます。 VM と IMDS 間の通信がホストから離れることはありません。
IMDS に対してクエリを実行する場合は、HTTP クライアントが VM 内の Web プロキシをバイパスするようにします。
IMDS にアクセスするには、Azure Resource Manager または Azure ポータル から VM を作成し、以下のサンプルを使用します。
その他の例については、「Azure Instance Metadata Samples (Azure Instance Metadata のサンプル) 」を参照してください。
インスタンスのすべてのメタデータを取得するサンプル コードを次に示します。 特定のデータ ソースにアクセスするには、使用可能なすべての機能の概要について「エンドポイント カテゴリ 」を参照してください。
Request
重要
この例では、プロキシをバイパスします。 IMDS に対してクエリを実行する場合は、プロキシをバイパスする必要があります 。 追加情報については、「プロキシ 」を参照してください。
注意
IMDS 要求は VM のプライマリ NIC とプライマリ IP を使用して送信し、かつ DHCP を有効にする必要があります。
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | ConvertTo-Json -Depth 64
-NoProxy
には PowerShell V6 以上が必須です。 PowerShell の旧バージョンでの例が必要であれば、こちらのサンプル リポジトリ を参照してください。
curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq
jq
ユーティリティは多くの場合に使用できますが、すべての場合に使用できるわけではありません。 jq
ユーティリティが存在しない場合は、代わりに | python -m json.tool
を使用します。
Response
注意
応答は JSON 文字列です。 次の例の応答は、読みやすくするために整えられています。
{
"compute" : {
"azEnvironment" : "AZUREPUBLICCLOUD" ,
"additionalCapabilities" : {
"hibernationEnabled" : "true"
},
"hostGroup" : {
"id" : "testHostGroupId"
},
"extendedLocation" : {
"type" : "edgeZone" ,
"name" : "microsoftlosangeles"
},
"evictionPolicy" : "" ,
"isHostCompatibilityLayerVm" : "true" ,
"licenseType" : "Windows_Client" ,
"location" : "westus" ,
"name" : "examplevmname" ,
"offer" : "WindowsServer" ,
"osProfile" : {
"adminUsername" : "admin" ,
"computerName" : "examplevmname" ,
"disablePasswordAuthentication" : "true"
},
"osType" : "Windows" ,
"placementGroupId" : "f67c14ab-e92c-408c-ae2d-da15866ec79a" ,
"plan" : {
"name" : "planName" ,
"product" : "planProduct" ,
"publisher" : "planPublisher"
},
"platformFaultDomain" : "36" ,
"platformSubFaultDomain" : "" ,
"platformUpdateDomain" : "42" ,
"priority" : "Regular" ,
"publicKeys" : [{
"keyData" : "ssh-rsa 0" ,
"path" : "/home/user/.ssh/authorized_keys0"
},
{
"keyData" : "ssh-rsa 1" ,
"path" : "/home/user/.ssh/authorized_keys1"
}
],
"publisher" : "RDFE-Test-Microsoft-Windows-Server-Group" ,
"resourceGroupName" : "macikgo-test-may-23" ,
"resourceId" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname" ,
"securityProfile" : {
"secureBootEnabled" : "true" ,
"virtualTpmEnabled" : "false" ,
"encryptionAtHost" : "true" ,
"securityType" : "TrustedLaunch"
},
"sku" : "2019-Datacenter" ,
"storageProfile" : {
"dataDisks" : [{
"bytesPerSecondThrottle" : "979202048" ,
"caching" : "None" ,
"createOption" : "Empty" ,
"diskCapacityBytes" : "274877906944" ,
"diskSizeGB" : "1024" ,
"image" : {
"uri" : ""
},
"isSharedDisk" : "false" ,
"isUltraDisk" : "true" ,
"lun" : "0" ,
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampledatadiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampledatadiskname" ,
"opsPerSecondThrottle" : "65280" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
}],
"imageReference" : {
"id" : "" ,
"offer" : "WindowsServer" ,
"publisher" : "MicrosoftWindowsServer" ,
"sku" : "2019-Datacenter" ,
"version" : "latest" ,
"communityGalleryImageId" : "/CommunityGalleries/testgallery/Images/1804Gen2/Versions/latest" ,
"sharedGalleryImageId" : "/SharedGalleries/1P/Images/gen2/Versions/latest" ,
"exactVersion" : "1.1686127202.30113"
},
"osDisk" : {
"caching" : "ReadWrite" ,
"createOption" : "FromImage" ,
"diskSizeGB" : "30" ,
"diffDiskSettings" : {
"option" : "Local"
},
"encryptionSettings" : {
"enabled" : "false" ,
"diskEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-source-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"secretUrl" : "https://test-disk.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
},
"keyEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-key-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"keyUrl" : "https://test-key.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
},
"image" : {
"uri" : ""
},
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampleosdiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampleosdiskname" ,
"osType" : "Windows" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
},
"resourceDisk" : {
"size" : "4096"
}
},
"subscriptionId" : "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" ,
"tags" : "baz:bash;foo:bar" ,
"userData" : "Zm9vYmFy" ,
"version" : "15.05.22" ,
"virtualMachineScaleSet" : {
"id" : "/subscriptions/xxxxxxxx-xxxxx-xxx-xxx-xxxx/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachineScaleSets/virtual-machine-scale-set-name"
},
"vmId" : "02aab8a4-74ef-476e-8182-f6d2ba4166a6" ,
"vmScaleSetName" : "crpteste9vflji9" ,
"vmSize" : "Standard_A3" ,
"zone" : ""
},
"network" : {
"interface" : [{
"ipv4" : {
"ipAddress" : [{
"privateIpAddress" : "10.144.133.132" ,
"publicIpAddress" : ""
}],
"subnet" : [{
"address" : "10.144.133.128" ,
"prefix" : "26"
}]
},
"ipv6" : {
"ipAddress" : [
]
},
"macAddress" : "0011AAFFBB22"
}]
}
}
{
"compute" : {
"azEnvironment" : "AZUREPUBLICCLOUD" ,
"additionalCapabilities" : {
"hibernationEnabled" : "true"
},
"hostGroup" : {
"id" : "testHostGroupId"
},
"extendedLocation" : {
"type" : "edgeZone" ,
"name" : "microsoftlosangeles"
},
"evictionPolicy" : "" ,
"isHostCompatibilityLayerVm" : "true" ,
"licenseType" : "" ,
"location" : "westus" ,
"name" : "examplevmname" ,
"offer" : "UbuntuServer" ,
"osProfile" : {
"adminUsername" : "admin" ,
"computerName" : "examplevmname" ,
"disablePasswordAuthentication" : "true"
},
"osType" : "Linux" ,
"placementGroupId" : "f67c14ab-e92c-408c-ae2d-da15866ec79a" ,
"plan" : {
"name" : "planName" ,
"product" : "planProduct" ,
"publisher" : "planPublisher"
},
"platformFaultDomain" : "36" ,
"platformSubFaultDomain" : "" ,
"platformUpdateDomain" : "42" ,
"priority" : "Regular" ,
"publicKeys" : [{
"keyData" : "ssh-rsa 0" ,
"path" : "/home/user/.ssh/authorized_keys0"
},
{
"keyData" : "ssh-rsa 1" ,
"path" : "/home/user/.ssh/authorized_keys1"
}
],
"publisher" : "Canonical" ,
"resourceGroupName" : "macikgo-test-may-23" ,
"resourceId" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname" ,
"securityProfile" : {
"secureBootEnabled" : "true" ,
"virtualTpmEnabled" : "false" ,
"encryptionAtHost" : "true" ,
"securityType" : "TrustedLaunch"
},
"sku" : "18.04-LTS" ,
"storageProfile" : {
"dataDisks" : [{
"bytesPerSecondThrottle" : "979202048" ,
"caching" : "None" ,
"createOption" : "Empty" ,
"diskCapacityBytes" : "274877906944" ,
"diskSizeGB" : "1024" ,
"image" : {
"uri" : ""
},
"isSharedDisk" : "false" ,
"isUltraDisk" : "true" ,
"lun" : "0" ,
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampledatadiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampledatadiskname" ,
"opsPerSecondThrottle" : "65280" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
}],
"imageReference" : {
"id" : "" ,
"offer" : "UbuntuServer" ,
"publisher" : "Canonical" ,
"sku" : "16.04.0-LTS" ,
"version" : "latest" ,
"communityGalleryImageId" : "/CommunityGalleries/testgallery/Images/1804Gen2/Versions/latest" ,
"sharedGalleryImageId" : "/SharedGalleries/1P/Images/gen2/Versions/latest" ,
"exactVersion" : "1.1686127202.30113"
},
"osDisk" : {
"caching" : "ReadWrite" ,
"createOption" : "FromImage" ,
"diskSizeGB" : "30" ,
"diffDiskSettings" : {
"option" : "Local"
},
"encryptionSettings" : {
"enabled" : "false" ,
"diskEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-source-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"secretUrl" : "https://test-disk.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
},
"keyEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-key-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"keyUrl" : "https://test-key.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
},
"image" : {
"uri" : ""
},
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampleosdiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampleosdiskname" ,
"osType" : "Linux" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
},
"resourceDisk" : {
"size" : "4096"
}
},
"subscriptionId" : "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" ,
"tags" : "baz:bash;foo:bar" ,
"version" : "15.05.22" ,
"virtualMachineScaleSet" : {
"id" : "/subscriptions/xxxxxxxx-xxxxx-xxx-xxx-xxxx/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachineScaleSets/virtual-machine-scale-set-name"
},
"vmId" : "02aab8a4-74ef-476e-8182-f6d2ba4166a6" ,
"vmScaleSetName" : "crpteste9vflji9" ,
"vmSize" : "Standard_A3" ,
"zone" : ""
},
"network" : {
"interface" : [{
"ipv4" : {
"ipAddress" : [{
"privateIpAddress" : "10.144.133.132" ,
"publicIpAddress" : ""
}],
"subnet" : [{
"address" : "10.144.133.128" ,
"prefix" : "26"
}]
},
"ipv6" : {
"ipAddress" : [
]
},
"macAddress" : "0011AAFFBB22"
}]
}
}
Instance Metadata Service には、実行中の仮想マシン インスタンス内からのみ、ルーティング不可能な IP アドレスでアクセスできます。 VM は、独自のメタデータ/機能だけと対話できます。 API は HTTP のみであり、ホストから出ることはありません。
要求が IMDS に確実に直接送信されるようにし、意図しない、または望ましくない要求のリダイレクトを防ぐには、要求を次のように処理する必要があります。
ヘッダー Metadata: true
を含める
ヘッダー X-Forwarded-For
を含めない
これらの要件が両方 とも満たされていない要求は、サービスによって拒否されます。
重要
IMDS は、機密データ用のチャネルではありません 。 API は認証されておらず、VM 上のすべてのプロセスに対してオープン状態になっています。 このサービスを通じて公開される情報は、VM 内で実行されているすべてのアプリケーションに対する共有情報と見なす必要があります。
VM 上のすべてのプロセスで IMDS エンドポイントにアクセスする必要がない場合、アクセスを制限するようにローカルのファイアウォール規則を設定できます。
たとえば、ある既知のシステム サービスだけがインスタンス メタデータ サービスにアクセスする必要がある場合、IMDS エンドポイントでファイアウォール規則を設定し、特定のプロセスにのみアクセスを許可したり、残りのプロセスのアクセスを拒否したりできます。
IMDS をプロキシの背後で使用することは想定されておらず 、サポートされていません。 ほとんどの HTTP クライアントでは、要求に応じてプロキシを無効にするオプションが提供されています。この機能は、IMDS と通信するときに使用する必要があります。 詳細については、クライアントのドキュメントを参照してください。
重要
お使いの環境でプロキシ構成がわからない場合でも、既定のクライアント プロキシ設定をオーバーライドする必要があります 。 プロキシ構成は自動的に検出され、このような構成をバイパスしないと、コンピューターの構成が将来変更された場合に侵害のリスクが生じます。
一般に、IMDS への要求は、(VM ごとに) 1 秒あたり 5 つの要求に制限されます。 このしきい値を超える要求は、429 の応答で拒否されます。 マネージド ID カテゴリに対する要求は、1 秒あたり 20 件の要求、同時要求数は 5 件 (VM 単位) に制限されます。
現在、次の HTTP 動詞がサポートされています。
テーブルを展開する
エンドポイントでは、必須パラメーターまたは省略可能なパラメーターがサポートされる場合があります。 詳細については、「スキーマ 」と、対象の特定のエンドポイントに関するドキュメントを参照してください。
IMDS エンドポイントでは、HTTP クエリ文字列パラメーターがサポートされています。 次に例を示します。
http://169.254.169.254/metadata/instance/compute?api-version=2021-01-01&format=json
パラメーターを指定します。
テーブルを展開する
名前
値
api-version
2021-01-01
format
json
クエリ パラメーター名が重複している要求は拒否されます。
より大きな JSON BLOB を返す一部のエンドポイントでは、応答のサブセットに絞り込むために、要求エンドポイントへのルート パラメーターの追加がサポートされています。
http://169.254.169.254/metadata/<endpoint>/[<filter parameter>/...]?<query parameters>
パラメーターは、解析された表現を操作する場合に、JSON オブジェクトを処理するのに使用されるインデックスとキーに対応します。
たとえば、/metadata/instance
によって JSON オブジェクトが返されます。
{
"compute" : { ... },
"network" : {
"interface" : [
{
"ipv4" : {
"ipAddress" : [{
"privateIpAddress" : "10.144.133.132" ,
"publicIpAddress" : ""
}],
"subnet" : [{
"address" : "10.144.133.128" ,
"prefix" : "26"
}]
},
"ipv6" : {
"ipAddress" : [
]
},
"macAddress" : "0011AAFFBB22"
},
...
]
}
}
応答をフィルター処理して compute プロパティのみに絞り込む場合は、次の要求を送信します。
http://169.254.169.254/metadata/instance/compute?api-version=<version>
同様に、入れ子になったプロパティまたは特定の配列要素に絞り込む場合は、次のようにさらにキーを追加します。
http://169.254.169.254/metadata/instance/network/interface/0?api-version=<version>
これにより、Network.interface
プロパティの最初の要素に絞り込まれ、次の内容が返されます。
{
"ipv4" : {
"ipAddress" : [{
"privateIpAddress" : "10.144.133.132" ,
"publicIpAddress" : ""
}],
"subnet" : [{
"address" : "10.144.133.128" ,
"prefix" : "26"
}]
},
"ipv6" : {
"ipAddress" : [
]
},
"macAddress" : "0011AAFFBB22"
}
注意
リーフ ノードに絞り込む場合、format=json
は機能しません。 これらのクエリでは、既定の形式は json なので、format=text
を明示的に指定する必要があります。
既定では、IMDS によって JSON 形式 (Content-Type: application/json
) でデータが返されます。 ただし、応答のフィルター処理をサポートするエンドポイント (「ルート パラメーター 」を参照) では、text
形式もサポートされています。
既定以外の応答形式にアクセスするには、要求のクエリ文字列パラメーターとして要求の形式を指定します。 次に例を示します。
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance?api-version=2017-08-01&format=text"
curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2017-08-01&format=text"
JSON 応答では、すべてのプリミティブは string
型になり、欠損値または対象外の値は常に含まれますが、空の文字列に設定されます。
IMDS はバージョン管理されており、HTTP 要求での API バージョンの指定は必須です。 この要件の唯一の例外はバージョン エンドポイントであり、使用可能な API バージョンを動的に取得するために使用できます。
新しいバージョンが追加されても、特定のデータ形式への依存関係がスクリプトにある場合、互換性を確保するために古いバージョンにもアクセスできます。
バージョンを指定しない場合、エラーが表示され、サポートされている最新バージョンの一覧が示されます。
{
"error" : "Bad request. api-version was not specified in the request. For more information refer to aka.ms/azureimds" ,
"newest-versions" : [
"2020-10-01" ,
"2020-09-01" ,
"2020-07-15"
]
}
注意
バージョン 2023-11-15 はまだロールアウトの途中の段階です。一部のリージョンでは使用できない場合があります。
2023-11-15
2023-07-01
2021-12-13
2021-11-15
2021-11-01
2021-10-01
2021-08-01
2021-05-01
2021-03-01
2021-02-01
2021-01-01
2020-12-01
2020-10-01
2020-09-01
2020-07-15
2020-06-01
2019-11-01
2019-08-15
2019-08-01
2019-06-04
2019-06-01
2019-04-30
2019-03-11
2019-02-01
2018-10-01
2018-04-02
2018-02-01
2017-12-01
2017-10-01
2017-08-01
2017-04-02
2017-03-01
IMDS の完全な Swagger 定義は、 https://github.com/Azure/azure-rest-api-specs/blob/main/specification/imds/data-plane/readme.md で入手できます。
このサービスは、すべての Azure クラウドで一般提供 されています。
ルート エンドポイントは http://169.254.169.254/metadata
です。
IMDS API には、さまざまなデータ ソースを表す複数のエンドポイント カテゴリが含まれており、それぞれに 1 つ以上のエンドポイントが含まれています。 詳細については、各カテゴリを参照してください。
テーブルを展開する
サポートされている API バージョンのセットを返します。
GET /metadata/versions
なし (このエンドポイントはバージョン管理されていません)。
{
"apiVersions" : [
"2017-03-01" ,
"2017-04-02" ,
...
]
}
コンピューティング、ネットワーク、ストレージなど、VM インスタンスの重要なメタデータを公開します。
GET /metadata/instance
テーブルを展開する
名前
必須/任意
内容
api-version
必須
要求を処理するために使用されるバージョン。
format
省略可能*
応答の形式 (json
または text
)。 *注:要求パラメーターを使用するときに必要になる場合があります。
このエンドポイントでは、ルート パラメーター を使用した応答フィルター処理がサポートされています。
{
"compute" : {
"azEnvironment" : "AZUREPUBLICCLOUD" ,
"additionalCapabilities" : {
"hibernationEnabled" : "true"
},
"hostGroup" : {
"id" : "testHostGroupId"
},
"extendedLocation" : {
"type" : "edgeZone" ,
"name" : "microsoftlosangeles"
},
"evictionPolicy" : "" ,
"isHostCompatibilityLayerVm" : "true" ,
"licenseType" : "Windows_Client" ,
"location" : "westus" ,
"name" : "examplevmname" ,
"offer" : "WindowsServer" ,
"osProfile" : {
"adminUsername" : "admin" ,
"computerName" : "examplevmname" ,
"disablePasswordAuthentication" : "true"
},
"osType" : "Windows" ,
"placementGroupId" : "f67c14ab-e92c-408c-ae2d-da15866ec79a" ,
"plan" : {
"name" : "planName" ,
"product" : "planProduct" ,
"publisher" : "planPublisher"
},
"platformFaultDomain" : "36" ,
"platformSubFaultDomain" : "" ,
"platformUpdateDomain" : "42" ,
"priority" : "Regular" ,
"publicKeys" : [{
"keyData" : "ssh-rsa 0" ,
"path" : "/home/user/.ssh/authorized_keys0"
},
{
"keyData" : "ssh-rsa 1" ,
"path" : "/home/user/.ssh/authorized_keys1"
}
],
"publisher" : "RDFE-Test-Microsoft-Windows-Server-Group" ,
"resourceGroupName" : "macikgo-test-may-23" ,
"resourceId" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname" ,
"securityProfile" : {
"secureBootEnabled" : "true" ,
"virtualTpmEnabled" : "false" ,
"encryptionAtHost" : "true" ,
"securityType" : "TrustedLaunch"
},
"sku" : "2019-Datacenter" ,
"storageProfile" : {
"dataDisks" : [{
"bytesPerSecondThrottle" : "979202048" ,
"caching" : "None" ,
"createOption" : "Empty" ,
"diskCapacityBytes" : "274877906944" ,
"diskSizeGB" : "1024" ,
"image" : {
"uri" : ""
},
"isSharedDisk" : "false" ,
"isUltraDisk" : "true" ,
"lun" : "0" ,
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampledatadiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampledatadiskname" ,
"opsPerSecondThrottle" : "65280" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
}],
"imageReference" : {
"id" : "" ,
"offer" : "WindowsServer" ,
"publisher" : "MicrosoftWindowsServer" ,
"sku" : "2019-Datacenter" ,
"version" : "latest" ,
"communityGalleryImageId" : "/CommunityGalleries/testgallery/Images/1804Gen2/Versions/latest" ,
"sharedGalleryImageId" : "/SharedGalleries/1P/Images/gen2/Versions/latest" ,
"exactVersion" : "1.1686127202.30113"
},
"osDisk" : {
"caching" : "ReadWrite" ,
"createOption" : "FromImage" ,
"diskSizeGB" : "30" ,
"diffDiskSettings" : {
"option" : "Local"
},
"encryptionSettings" : {
"enabled" : "false" ,
"diskEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-source-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"secretUrl" : "https://test-disk.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
},
"keyEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-key-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"keyUrl" : "https://test-key.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
},
"image" : {
"uri" : ""
},
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampleosdiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampleosdiskname" ,
"osType" : "Windows" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
},
"resourceDisk" : {
"size" : "4096"
}
},
"subscriptionId" : "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" ,
"tags" : "baz:bash;foo:bar" ,
"userData" : "Zm9vYmFy" ,
"version" : "15.05.22" ,
"virtualMachineScaleSet" : {
"id" : "/subscriptions/xxxxxxxx-xxxxx-xxx-xxx-xxxx/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachineScaleSets/virtual-machine-scale-set-name"
},
"vmId" : "02aab8a4-74ef-476e-8182-f6d2ba4166a6" ,
"vmScaleSetName" : "crpteste9vflji9" ,
"vmSize" : "Standard_A3" ,
"zone" : ""
},
"network" : {
"interface" : [{
"ipv4" : {
"ipAddress" : [{
"privateIpAddress" : "10.144.133.132" ,
"publicIpAddress" : ""
}],
"subnet" : [{
"address" : "10.144.133.128" ,
"prefix" : "26"
}]
},
"ipv6" : {
"ipAddress" : [
]
},
"macAddress" : "0011AAFFBB22"
}]
}
}
{
"compute" : {
"azEnvironment" : "AZUREPUBLICCLOUD" ,
"additionalCapabilities" : {
"hibernationEnabled" : "true"
},
"hostGroup" : {
"id" : "testHostGroupId"
},
"extendedLocation" : {
"type" : "edgeZone" ,
"name" : "microsoftlosangeles"
},
"evictionPolicy" : "" ,
"isHostCompatibilityLayerVm" : "true" ,
"licenseType" : "" ,
"location" : "westus" ,
"name" : "examplevmname" ,
"offer" : "UbuntuServer" ,
"osProfile" : {
"adminUsername" : "admin" ,
"computerName" : "examplevmname" ,
"disablePasswordAuthentication" : "true"
},
"osType" : "Linux" ,
"placementGroupId" : "f67c14ab-e92c-408c-ae2d-da15866ec79a" ,
"plan" : {
"name" : "planName" ,
"product" : "planProduct" ,
"publisher" : "planPublisher"
},
"platformFaultDomain" : "36" ,
"platformSubFaultDomain" : "" ,
"platformUpdateDomain" : "42" ,
"priority" : "Regular" ,
"publicKeys" : [{
"keyData" : "ssh-rsa 0" ,
"path" : "/home/user/.ssh/authorized_keys0"
},
{
"keyData" : "ssh-rsa 1" ,
"path" : "/home/user/.ssh/authorized_keys1"
}
],
"publisher" : "Canonical" ,
"resourceGroupName" : "macikgo-test-may-23" ,
"resourceId" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname" ,
"securityProfile" : {
"secureBootEnabled" : "true" ,
"virtualTpmEnabled" : "false" ,
"encryptionAtHost" : "true" ,
"securityType" : "TrustedLaunch"
},
"sku" : "18.04-LTS" ,
"storageProfile" : {
"dataDisks" : [{
"bytesPerSecondThrottle" : "979202048" ,
"caching" : "None" ,
"createOption" : "Empty" ,
"diskCapacityBytes" : "274877906944" ,
"diskSizeGB" : "1024" ,
"image" : {
"uri" : ""
},
"isSharedDisk" : "false" ,
"isUltraDisk" : "true" ,
"lun" : "0" ,
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampledatadiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampledatadiskname" ,
"opsPerSecondThrottle" : "65280" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
}],
"imageReference" : {
"id" : "" ,
"offer" : "UbuntuServer" ,
"publisher" : "Canonical" ,
"sku" : "16.04.0-LTS" ,
"version" : "latest" ,
"communityGalleryImageId" : "/CommunityGalleries/testgallery/Images/1804Gen2/Versions/latest" ,
"sharedGalleryImageId" : "/SharedGalleries/1P/Images/gen2/Versions/latest" ,
"exactVersion" : "1.1686127202.30113"
},
"osDisk" : {
"caching" : "ReadWrite" ,
"createOption" : "FromImage" ,
"diskSizeGB" : "30" ,
"diffDiskSettings" : {
"option" : "Local"
},
"encryptionSettings" : {
"enabled" : "false" ,
"diskEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-source-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"secretUrl" : "https://test-disk.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
},
"keyEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-key-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"keyUrl" : "https://test-key.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
},
"image" : {
"uri" : ""
},
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampleosdiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampleosdiskname" ,
"osType" : "Linux" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
},
"resourceDisk" : {
"size" : "4096"
}
},
"subscriptionId" : "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" ,
"tags" : "baz:bash;foo:bar" ,
"version" : "15.05.22" ,
"virtualMachineScaleSet" : {
"id" : "/subscriptions/xxxxxxxx-xxxxx-xxx-xxx-xxxx/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachineScaleSets/virtual-machine-scale-set-name"
},
"vmId" : "02aab8a4-74ef-476e-8182-f6d2ba4166a6" ,
"vmScaleSetName" : "crpteste9vflji9" ,
"vmSize" : "Standard_A3" ,
"zone" : ""
},
"network" : {
"interface" : [{
"ipv4" : {
"ipAddress" : [{
"privateIpAddress" : "10.144.133.132" ,
"publicIpAddress" : ""
}],
"subnet" : [{
"address" : "10.144.133.128" ,
"prefix" : "26"
}]
},
"ipv6" : {
"ipAddress" : [
]
},
"macAddress" : "0011AAFFBB22"
}]
}
}
スキーマの内訳:
Compute
テーブルを展開する
Data
説明
導入されたバージョン
azEnvironment
VM が実行されている Azure 環境
2018-10-01
additionalCapabilities.hibernationEnabled
VM で休止状態が有効になっているかどうかを識別します
2021-11-01
customData
IMDS では 、この機能は非推奨とされ、無効になっています。 userData
に置き換えられています。
2019-02-01
evictionPolicy
スポット VM を削除する方法を設定します。
2020-12-01
extendedLocation.type
VM の拡張された場所の種類。
2021-03-01
extendedLocation.name
VM の拡張された場所の名前
2021-03-01
host.id
VM のホストの名前。 VM にはホストまたは hostGroup がありますが、両方は存在しないことに注意してください。
2021-11-15
hostGroup.id
VM の hostGroup の名前。 VM にはホストまたは hostGroup がありますが、両方は存在しないことに注意してください。
2021-11-15
isHostCompatibilityLayerVm
ホストの互換性レイヤーで VM が実行されているかどうかを示します
2020-06-01
licenseType
Azure ハイブリッド特典 のライセンスの種類。 これは AHB 対応 VM でのみ利用できます。
2020-09-01
location
VM を実行中の Azure リージョン
2017-04-02
name
VM の名前
2017-04-02
offer
VM イメージのオファーの情報。Azure イメージ ギャラリーからデプロイされるイメージについてのみ存在します。
2017-04-02
osProfile.adminUsername
管理者アカウントの名前を指定します。
2020-07-15
osProfile.computerName
コンピューターの名前を指定します。
2020-07-15
osProfile.disablePasswordAuthentication
パスワード認証が無効かどうかを指定します。 これは Linux VM でのみ利用できます。
2020-10-01
osType
Linux または Windows
2017-04-02
physicalZone
VM の物理ゾーン
2023-11-15
placementGroupId
スケール セットの配置グループ
2017-08-01
plan
VM が Azure Marketplace イメージである場合、プラン にはその名前、製品、発行元が含まれています
2018-04-02
platformUpdateDomain
VM を実行中の更新ドメイン
2017-04-02
platformFaultDomain
VM を実行中の障害ドメイン
2017-04-02
platformSubFaultDomain
VM が実行されているサブ障害ドメイン (該当する場合)。
2021-10-01
priority
VM の優先度。 詳細については、「スポット VM 」を参照してください
2020-12-01
provider
VM のプロバイダー
2018-10-01
publicKeys
VM とパスに割り当てられた公開キーのコレクション
2018-04-02
publisher
VM イメージの発行元
2017-04-02
resourceGroupName
お使いの仮想マシンのリソース グループ
2017-08-01
resourceId
リソースの完全修飾 ID
2019-03-11
sku
VM イメージの特定の SKU
2017-04-02
securityProfile.secureBootEnabled
VM で UEFI セキュア ブートが有効になっているかどうかを示します
2020-06-01
securityProfile.virtualTpmEnabled
VM で仮想トラステッド プラットフォーム モジュール (TPM) が有効になっているかどうかを示します
2020-06-01
securityProfile.encryptionAtHost
VM で ホストでの暗号化 が有効になっているかどうかを識別します
2021-11-01
securityProfile.securityType
VM が信頼された VM または機密 VM であるかどうかを識別します
2021-12-13
storageProfile
下記の「ストレージ プロファイル」を参照してください
2019-06-01
subscriptionId
仮想マシンの Azure サブスクリプション
2017-08-01
tags
お使いの仮想マシンのタグ
2017-08-01
tagsList
プログラムによる解析を簡単にするために JSON 配列として書式設定されたタグ
2019-06-04
userData
プロビジョニング中またはプロビジョニング後に使用するために VM が作成されたときに指定されたデータのセット (Base64 エンコード)
2021-01-01
version
VM イメージのバージョン
2017-04-02
virtualMachineScaleSet.id
仮想マシンが含まれているフレキシブル オーケストレーションで作成された仮想マシン スケール セット の ID。 このフィールドは、均一オーケストレーションで作成された仮想マシン スケール セットには使用できません。
2021-03-01
vmId
VM の一意の識別子 。 参照されているブログは、SMBIOS が 2.6 未満である VM にのみ適しています。 SMBIOS が 2.6 以上である VM の場合、DMI からの UUID はリトル エンディアン形式で表示されるため、バイトを切り替える必要はありません。
2017-04-02
vmScaleSetName
お使いのスケール セットの仮想マシン スケール セット名
2017-12-01
vmSize
VM サイズ
2017-04-02
zone
仮想マシンの可用性ゾーン
2017-12-01
† このバージョンはまだ完全には利用できないため、一部のリージョンではサポートされていない場合があります。
ストレージ プロファイル
VM のストレージ プロファイルは、イメージ参照、OS ディスク、データ ディスクの 3 つのカテゴリに分けられ、さらにローカル一時ディスク用の追加オブジェクトがあります。
イメージ参照オブジェクトには、OS イメージに関する次の情報が含まれており、イメージは、プラットフォーム、マーケットプレース、コミュニティ ギャラリー、または直接共有ギャラリーのいずれかから取得できますが、両方から取得することはできないことにご注意ください。
テーブルを展開する
データ
説明
導入されたバージョン
id
Resource ID
2019-06-01
offer
プラットフォームまたは marketplace イメージのオファー
2019-06-01
publisher
プラットフォームまたはマーケットプレース イメージのパブリッシャー
2019-06-01
sku
プラットフォームまたはマーケットプレース イメージの Sku
2019-06-01
version
イメージのバージョン
2019-06-01
communityGalleryImageId
コミュニティ イメージのリソース ID。それ以外の場合は空
2023-07-01
sharedGalleryImageId
直接共有イメージのリソース ID。それ以外の場合は空
2023-07-01
exactVersion
コミュニティまたは直接共有イメージのバージョン
2023-07-01
OS ディスク オブジェクトには、VM によって使用される OS ディスクに関する次の情報が含まれています。
テーブルを展開する
Data
説明
caching
キャッシュの要件
createOption
VM が作成された方法に関する情報
diffDiskSettings
一時ディスクの設定
diskSizeGB
ディスクのサイズ (GB)
image
ソース ユーザー イメージの仮想ハード ディスク
managedDisk
マネージド ディスクのパラメーター
name
ディスク名
vhd
仮想ハード ディスク
writeAcceleratorEnabled
ディスクで writeAccelerator が有効になっているかどうか
データ ディスク アレイには、VM に接続されているデータ ディスクの一覧が含まれています。 各データ ディスク オブジェクトには、次の情報が含まれています。
テーブルを展開する
Data
説明
導入されたバージョン
bytesPerSecondThrottle
*
ディスクの読み取り/書き込みクォータ (バイト単位)
2021-05-01
caching
キャッシュの要件
2019-06-01
createOption
VM が作成された方法に関する情報
2019-06-01
diffDiskSettings
一時ディスクの設定
2019-06-01
diskCapacityBytes
*
ディスク サイズ (バイト単位)
2021-05-01
diskSizeGB
ディスクのサイズ (GB)
2019-06-01
encryptionSettings
ディスクの暗号化の設定
2019-06-01
image
ソース ユーザー イメージの仮想ハード ディスク
2019-06-01
isSharedDisk
*
ディスクがリソース間で共有されるか特定します
2021-05-01
isUltraDisk
データ ディスクが Ultra Disk かどうかを特定します
2021-05-01
lun
ディスクの論理ユニット番号
2019-06-01
managedDisk
マネージド ディスクのパラメーター
2019-06-01
name
ディスク名
2019-06-01
opsPerSecondThrottle
*
ディスクの読み取り/書き込みクォータ (IOPS)
2021-05-01
osType
ディスクに含まれている OS の種類
2019-06-01
vhd
仮想ハード ディスク
2019-06-01
writeAcceleratorEnabled
ディスクで writeAccelerator が有効になっているかどうか
2019-06-01
*これらのフィールドは Ultra Disk の場合にのみ入力されます。Ultra Disk ではない場合、空の文字列になります。
暗号化設定 BLOB には、ディスクの暗号化方法に関する以下のデータが含まれています (暗号化されている場合)。
テーブルを展開する
Data
説明
導入されたバージョン
diskEncryptionKey.sourceVault.id
ディスク暗号化キーの場所
2021-11-01
diskEncryptionKey.secretUrl
シークレットの場所
2021-11-01
keyEncryptionKey.sourceVault.id
キー暗号化キーの場所
2021-11-01
keyEncryptionKey.keyUrl
キーの場所
2021-11-01
リソース ディスク オブジェクトには、VM に接続されているローカル一時ディスク (ある場合) のサイズ (KB 単位) が格納されます。
VM のローカル一時ディスクがない 場合、この値は 0 です。
テーブルを展開する
Data
説明
導入されたバージョン
resourceDisk.size
VM のローカル一時ディスクのサイズ (KB 単位)
2021-02-01
Network
テーブルを展開する
Data
説明
導入されたバージョン
ipv4.privateIpAddress
VM のローカル IPv4 アドレス
2017-04-02
ipv4.publicIpAddress
VM のパブリック IPv4 アドレス
2017-04-02
subnet.address
VM のサブネット アドレス
2017-04-02
subnet.prefix
サブネットのプレフィックス (24 など)
2017-04-02
ipv6.ipAddress
VM のローカル IPv6 アドレス
2017-04-02
macAddress
VM の mac アドレス
2017-04-02
注意
ネットワーク呼び出しによって返される NIC は順序どおりになることは保証されていません。
新しい VM を作成するときに、VM のプロビジョニング中またはプロビジョニング後に使用されるデータのセットを指定し、IMDS を通じて取得することができます。 エンドツーエンドのユーザー データ体験はこちら をご覧ください。
ユーザー データを設定するには、こちら のクイックスタート テンプレートを利用します。 次のサンプルは、IMDS を介してこのデータを取得する方法を示しています。 この機能はバージョン 2021-01-01
以上でリリースされます。
注意
セキュリティに関する通知: IMDS は VM 上のすべてのアプリケーションに対して開かれているため、機密データをユーザー データに配置しないでください。
$userData = Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/compute/userData?api-version=2021-01-01&format=text"
[System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($userData ))
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/userData?api-version=2021-01-01&format=text" | base64 --decode
サンプル 1:Azure で動作している VM の追跡
サービス プロバイダーは、ソフトウェアを実行している VM の数を追跡する必要があったり、VM の一意性を追跡する必要のあるエージェントを使用していたりする場合があります。 VM の一意の ID を取得できるようにするには、Instance Metadata Service から vmId
フィールドを使用します。
Request
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/compute/vmId?api-version=2017-08-01&format=text"
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/vmId?api-version=2017-08-01&format=text"
Response
5c08b38e-4d57-4c23-ac45-aca61037f084
特定のシナリオでは、異なるレプリカの配置が非常に重要です。 たとえば、Orchestrator を介した HDFS レプリカの配置 またはコンテナーの配置では、VM が実行されている platformFaultDomain
と platformUpdateDomain
を把握しておく必要がある場合があります。
これらの決定を行うために、インスタンスの可用性ゾーン を使用することもできます。
IMDS を介して、このデータに直接クエリを実行できます。
Request
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/compute/platformFaultDomain?api-version=2017-08-01&format=text"
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/platformFaultDomain?api-version=2017-08-01&format=text"
Response
0
VM タグは、instance/compute/tags エンドポイントの下にあるインスタンス API に含まれています。
論理的に分類するために Azure VM にタグが適用されている場合があります。 次の要求を使用して、VM に割り当てられたタグを取得できます。
Request
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/compute/tags?api-version=2017-08-01&format=text"
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/tags?api-version=2017-08-01&format=text"
Response
Department:IT;ReferenceNumber:123456;TestStatus:Pending
tags
フィールドは、セミコロンで区切られたタグを含む文字列です。 この出力は、タグ自体でセミコロンが使用されている場合に問題になることがあります。 プログラムでタグを抽出するようにパーサーが作成されている場合は、tagsList
フィールドを使用する必要があります。 tagsList
フィールドは区切り記号のない JSON 配列であるため、解析が容易になります。 次の要求を使用して、VM に割り当てられた tagsList を取得できます。
Request
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/compute/tagsList?api-version=2019-06-04" | ConvertTo-Json -Depth 64
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/tagsList?api-version=2019-06-04" | jq
jq
ユーティリティは多くの場合に使用できますが、すべての場合に使用できるわけではありません。 jq
ユーティリティが存在しない場合は、代わりに | python -m json.tool
を使用します。
Response
{
"value" : [
{
"name" : "Department" ,
"value" : "IT"
},
{
"name" : "ReferenceNumber" ,
"value" : "123456"
},
{
"name" : "TestStatus" ,
"value" : "Pending"
}
],
"Count" : 3
}
[
{
"name" : "Department" ,
"value" : "IT"
},
{
"name" : "ReferenceNumber" ,
"value" : "123456"
},
{
"name" : "TestStatus" ,
"value" : "Pending"
}
]
サービス プロバイダーとして、VM の詳細情報を得る必要があるサポート コールを受けることがあります。 顧客にコンピューティング メタデータの共有を依頼すると、サポート担当者が Azure 上の VM の種類を確認するための基本情報を得られる場合があります。
Request
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/compute?api-version=2020-09-01" | ConvertTo-Json -Depth 64
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute?api-version=2020-09-01"
Response
注意
応答は JSON 文字列です。 次の例の応答は、読みやすくするために整えられています。
{
"azEnvironment" : "AZUREPUBLICCLOUD" ,
"extendedLocation" : {
"type" : "edgeZone" ,
"name" : "microsoftlosangeles"
},
"evictionPolicy" : "" ,
"additionalCapabilities" : {
"hibernationEnabled" : "false"
},
"hostGroup" : {
"id" : "testHostGroupId"
},
"isHostCompatibilityLayerVm" : "true" ,
"licenseType" : "Windows_Client" ,
"location" : "westus" ,
"name" : "examplevmname" ,
"offer" : "WindowsServer" ,
"osProfile" : {
"adminUsername" : "admin" ,
"computerName" : "examplevmname" ,
"disablePasswordAuthentication" : "true"
},
"osType" : "Windows" ,
"placementGroupId" : "f67c14ab-e92c-408c-ae2d-da15866ec79a" ,
"plan" : {
"name" : "planName" ,
"product" : "planProduct" ,
"publisher" : "planPublisher"
},
"platformFaultDomain" : "36" ,
"platformUpdateDomain" : "42" ,
"priority" : "Regular" ,
"publicKeys" : [{
"keyData" : "ssh-rsa 0" ,
"path" : "/home/user/.ssh/authorized_keys0"
},
{
"keyData" : "ssh-rsa 1" ,
"path" : "/home/user/.ssh/authorized_keys1"
}
],
"publisher" : "RDFE-Test-Microsoft-Windows-Server-Group" ,
"physicalZone" : "useast-AZ01" ,
"resourceGroupName" : "macikgo-test-may-23" ,
"resourceId" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname" ,
"securityProfile" : {
"secureBootEnabled" : "true" ,
"virtualTpmEnabled" : "false" ,
"encryptionAtHost" : "true" ,
"securityType" : "TrustedLaunch"
},
"sku" : "2019-Datacenter" ,
"storageProfile" : {
"dataDisks" : [{
"bytesPerSecondThrottle" : "979202048" ,
"caching" : "None" ,
"createOption" : "Empty" ,
"diskCapacityBytes" : "274877906944" ,
"diskSizeGB" : "1024" ,
"image" : {
"uri" : ""
},
"isSharedDisk" : "false" ,
"isUltraDisk" : "true" ,
"lun" : "0" ,
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/MicrosoftCompute/disks/exampledatadiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampledatadiskname" ,
"opsPerSecondThrottle" : "65280" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
}],
"imageReference" : {
"id" : "" ,
"offer" : "WindowsServer" ,
"publisher" : "MicrosoftWindowsServer" ,
"sku" : "2019-Datacenter" ,
"version" : "latest" ,
"communityGalleryImageId" : "/CommunityGalleries/testgallery/Images/1804Gen2/Versions/latest" ,
"sharedGalleryImageId" : "/SharedGalleries/1P/Images/gen2/Versions/latest" ,
"exactVersion" : "1.1686127202.30113"
},
"osDisk" : {
"caching" : "ReadWrite" ,
"createOption" : "FromImage" ,
"diskSizeGB" : "30" ,
"diffDiskSettings" : {
"option" : "Local"
},
"encryptionSettings" : {
"enabled" : "false" ,
"diskEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-source-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"secretUrl" : "https://test-disk.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
},
"keyEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-key-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"keyUrl" : "https://test-key.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
},
"image" : {
"uri" : ""
},
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampleosdiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampleosdiskname" ,
"osType" : "Windows" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
},
"resourceDisk" : {
"size" : "4096"
}
},
"subscriptionId" : "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" ,
"tags" : "baz:bash;foo:bar" ,
"version" : "15.05.22" ,
"virtualMachineScaleSet" : {
"id" : "/subscriptions/xxxxxxxx-xxxxx-xxx-xxx-xxxx/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachineScaleSets/virtual-machine-scale-set-name"
},
"vmId" : "02aab8a4-74ef-476e-8182-f6d2ba4166a6" ,
"vmScaleSetName" : "crpteste9vflji9" ,
"vmSize" : "Standard_A3" ,
"zone" : "3"
}
{
"azEnvironment" : "AZUREPUBLICCLOUD" ,
"extendedLocation" : {
"type" : "edgeZone" ,
"name" : "microsoftlosangeles"
},
"evictionPolicy" : "" ,
"additionalCapabilities" : {
"hibernationEnabled" : "false"
},
"hostGroup" : {
"id" : "testHostGroupId"
},
"isHostCompatibilityLayerVm" : "true" ,
"licenseType" : "Windows_Client" ,
"location" : "westus" ,
"name" : "examplevmname" ,
"offer" : "UbuntuServer" ,
"osProfile" : {
"adminUsername" : "admin" ,
"computerName" : "examplevmname" ,
"disablePasswordAuthentication" : "true"
},
"osType" : "Linux" ,
"physicalZone" : "useast-AZ01" ,
"placementGroupId" : "f67c14ab-e92c-408c-ae2d-da15866ec79a" ,
"plan" : {
"name" : "planName" ,
"product" : "planProduct" ,
"publisher" : "planPublisher"
},
"platformFaultDomain" : "36" ,
"platformUpdateDomain" : "42" ,
"Priority" : "Regular" ,
"publicKeys" : [{
"keyData" : "ssh-rsa 0" ,
"path" : "/home/user/.ssh/authorized_keys0"
},
{
"keyData" : "ssh-rsa 1" ,
"path" : "/home/user/.ssh/authorized_keys1"
}
],
"publisher" : "Canonical" ,
"resourceGroupName" : "macikgo-test-may-23" ,
"resourceId" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/virtualMachines/examplevmname" ,
"securityProfile" : {
"secureBootEnabled" : "true" ,
"virtualTpmEnabled" : "false" ,
"encryptionAtHost" : "true" ,
"securityType" : "TrustedLaunch"
},
"sku" : "18.04-LTS" ,
"storageProfile" : {
"dataDisks" : [{
"bytesPerSecondThrottle" : "979202048" ,
"caching" : "None" ,
"createOption" : "Empty" ,
"diskCapacityBytes" : "274877906944" ,
"diskSizeGB" : "1024" ,
"image" : {
"uri" : ""
},
"isSharedDisk" : "false" ,
"isUltraDisk" : "true" ,
"lun" : "0" ,
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampledatadiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampledatadiskname" ,
"opsPerSecondThrottle" : "65280" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
}],
"imageReference" : {
"id" : "" ,
"offer" : "UbuntuServer" ,
"publisher" : "Canonical" ,
"sku" : "16.04.0-LTS" ,
"version" : "latest" ,
"communityGalleryImageId" : "/CommunityGalleries/testgallery/Images/1804Gen2/Versions/latest" ,
"sharedGalleryImageId" : "/SharedGalleries/1P/Images/gen2/Versions/latest" ,
"exactVersion" : "1.1686127202.30113"
},
"osDisk" : {
"caching" : "ReadWrite" ,
"createOption" : "FromImage" ,
"diskSizeGB" : "30" ,
"diffDiskSettings" : {
"option" : "Local"
},
"encryptionSettings" : {
"enabled" : "false" ,
"diskEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-source-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"secretUrl" : "https://test-disk.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
},
"keyEncryptionKey" : {
"sourceVault" : {
"id" : "/subscriptions/test-key-guid/resourceGroups/testrg/providers/Microsoft.KeyVault/vaults/test-kv"
},
"keyUrl" : "https://test-key.vault.azure.net/secrets/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
},
"image" : {
"uri" : ""
},
"managedDisk" : {
"id" : "/subscriptions/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/macikgo-test-may-23/providers/Microsoft.Compute/disks/exampleosdiskname" ,
"storageAccountType" : "StandardSSD_LRS"
},
"name" : "exampleosdiskname" ,
"osType" : "linux" ,
"vhd" : {
"uri" : ""
},
"writeAcceleratorEnabled" : "false"
},
"resourceDisk" : {
"size" : "4096"
}
},
"subscriptionId" : "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" ,
"tags" : "baz:bash;foo:bar" ,
"version" : "15.05.22" ,
"virtualMachineScaleSet" : {
"id" : "/subscriptions/xxxxxxxx-xxxxx-xxx-xxx-xxxx/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachineScaleSets/virtual-machine-scale-set-name"
},
"vmId" : "02aab8a4-74ef-476e-8182-f6d2ba4166a6" ,
"vmScaleSetName" : "crpteste9vflji9" ,
"vmSize" : "Standard_A3" ,
"zone" : "3"
}
サンプル 5: VM が実行されている Azure 環境を取得する
Azure には、Azure Government など多数のソブリン クラウドがあります。 ランタイムの決定を行うために、Azure 環境が必要な場合があります。 次の例では、この動作を実現する方法を示します。
Request
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/compute/azEnvironment?api-version=2018-10-01&format=text"
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/azEnvironment?api-version=2018-10-01&format=text"
Response
AzurePublicCloud
クラウドと Azure 環境の値を次に示します。
テーブルを展開する
Request
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/network?api-version=2017-08-01" | ConvertTo-Json -Depth 64
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/network?api-version=2017-08-01"
Response
{
"interface" : [
{
"ipv4" : {
"ipAddress" : [
{
"privateIpAddress" : "10.1.0.4" ,
"publicIpAddress" : "X.X.X.X"
}
],
"subnet" : [
{
"address" : "10.1.0.0" ,
"prefix" : "24"
}
]
},
"ipv6" : {
"ipAddress" : []
},
"macAddress" : "000D3AF806EC"
}
]
}
サンプル 7: パブリック IP アドレスを取得する
Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/publicIpAddress?api-version=2017-08-01&format=text"
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/publicIpAddress?api-version=2017-08-01&format=text"
IMDS は、提供されるデータが Azure から送信されることを保証するために役立ちます。 Microsoft によってこの情報の一部に署名が行われるため、Azure Marketplace のイメージが Azure で実行されているものであることを確認できます。
GET /metadata/attested/document
テーブルを展開する
名前
必須/任意
内容
api-version
必須
要求を処理するために使用されるバージョン。
nonce
Optional
暗号化 nonce として機能する 10 桁の文字列。 値が指定されていない場合、IMDS では現在の UTC タイムスタンプが使用されます。
{
"encoding" :"pkcs7" ,
"signature" :"MIIEEgYJKoZIhvcNAQcCoIIEAzCCA/8CAQExDzANBgkqhkiG9w0BAQsFADCBugYJKoZIhvcNAQcBoIGsBIGpeyJub25jZSI6IjEyMzQ1NjY3NjYiLCJwbGFuIjp7Im5hbWUiOiIiLCJwcm9kdWN0IjoiIiwicHVibGlzaGVyIjoiIn0sInRpbWVTdGFtcCI6eyJjcmVhdGVkT24iOiIxMS8yMC8xOCAyMjowNzozOSAtMDAwMCIsImV4cGlyZXNPbiI6IjExLzIwLzE4IDIyOjA4OjI0IC0wMDAwIn0sInZtSWQiOiIifaCCAj8wggI7MIIBpKADAgECAhBnxW5Kh8dslEBA0E2mIBJ0MA0GCSqGSIb3DQEBBAUAMCsxKTAnBgNVBAMTIHRlc3RzdWJkb21haW4ubWV0YWRhdGEuYXp1cmUuY29tMB4XDTE4MTEyMDIxNTc1N1oXDTE4MTIyMDIxNTc1NlowKzEpMCcGA1UEAxMgdGVzdHN1YmRvbWFpbi5tZXRhZGF0YS5henVyZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAML/tBo86ENWPzmXZ0kPkX5dY5QZ150mA8lommszE71x2sCLonzv4/UWk4H+jMMWRRwIea2CuQ5RhdWAHvKq6if4okKNt66fxm+YTVz9z0CTfCLmLT+nsdfOAsG1xZppEapC0Cd9vD6NCKyE8aYI1pliaeOnFjG0WvMY04uWz2MdAgMBAAGjYDBeMFwGA1UdAQRVMFOAENnYkHLa04Ut4Mpt7TkJFfyhLTArMSkwJwYDVQQDEyB0ZXN0c3ViZG9tYWluLm1ldGFkYXRhLmF6dXJlLmNvbYIQZ8VuSofHbJRAQNBNpiASdDANBgkqhkiG9w0BAQQFAAOBgQCLSM6aX5Bs1KHCJp4VQtxZPzXF71rVKCocHy3N9PTJQ9Fpnd+bYw2vSpQHg/AiG82WuDFpPReJvr7Pa938mZqW9HUOGjQKK2FYDTg6fXD8pkPdyghlX5boGWAMMrf7bFkup+lsT+n2tRw2wbNknO1tQ0wICtqy2VqzWwLi45RBwTGB6DCB5QIBATA/MCsxKTAnBgNVBAMTIHRlc3RzdWJkb21haW4ubWV0YWRhdGEuYXp1cmUuY29tAhBnxW5Kh8dslEBA0E2mIBJ0MA0GCSqGSIb3DQEBCwUAMA0GCSqGSIb3DQEBAQUABIGAld1BM/yYIqqv8SDE4kjQo3Ul/IKAVR8ETKcve5BAdGSNkTUooUGVniTXeuvDj5NkmazOaKZp9fEtByqqPOyw/nlXaZgOO44HDGiPUJ90xVYmfeK6p9RpJBu6kiKhnnYTelUk5u75phe5ZbMZfBhuPhXmYAdjc7Nmw97nx8NnprQ="
}
signature BLOB は、ドキュメントの pkcs7 で署名されたバージョンです。 特定の VM 固有の詳細と共に署名に使用される証明書が含まれています。
Azure Resource Manager を使用して作成された VM の場合、ドキュメントには、ドキュメントの作成と有効期限のための vmId
、sku
、nonce
、subscriptionId
、timeStamp
とイメージに関するプラン情報が含まれています。 プラン情報は Azure Marketplace のイメージにのみ設定されます。
クラシック デプロイ モデルを使用して作成された VM の場合、設定されることが保証されているのは vmId
と subscriptionId
のみです。 応答から証明書を抽出し、応答が有効で Azure から送られたものであることを確認するために使用できます。
デコードされたドキュメントには、次のフィールドが含まれています。
テーブルを展開する
Data
説明
導入されたバージョン
licenseType
Azure ハイブリッド特典 のライセンスの種類。 これは AHB 対応 VM でのみ利用できます。
2020-09-01
nonce
必要に応じて、要求で指定できる文字列。 nonce
が指定されていない場合は、現在の協定世界時のタイムスタンプが使用されます。
2018-10-01
plan
Azure Marketplace イメージ プラン 。 プラン ID (名前)、製品イメージまたはオファー (製品)、およびパブリッシャー ID (パブリッシャー) が含まれます。
2018-10-01
timestamp.createdOn
署名されたドキュメントが作成されたときの UTC タイムスタンプ
2018-20-01
timestamp.expiresOn
署名されたドキュメントの有効期限が切れるときの UTC タイムスタンプ
2018-10-01
vmId
VM の一意の識別子
2018-10-01
subscriptionId
仮想マシンの Azure サブスクリプション
2019-04-30
sku
VM イメージの特定の SKU (Instance Metadata エンドポイント [/metadata/instance
] の compute/sku
プロパティに対応)
2019-11-01
注意
従来の (Azure Resource Manager 以外の) VM の場合は、vmId の設定のみが保証されます。
ドキュメントのサンプル:
{
"nonce" :"20201130-211924" ,
"plan" :{
"name" :"planName" ,
"product" :"planProduct" ,
"publisher" :"planPublisher"
},
"sku" :"Windows-Server-2012-R2-Datacenter" ,
"subscriptionId" :"8d10da13-8125-4ba9-a717-bf7490507b3d" ,
"timeStamp" :{
"createdOn" :"11/30/20 21:19:19 -0000" ,
"expiresOn" :"11/30/20 21:19:24 -0000"
},
"vmId" :"02aab8a4-74ef-476e-8182-f6d2ba4166a6"
}
署名を検証するときは、署名が Azure の証明書を使用して作成されていることを確認する必要があります。 これは、証明書サブジェクトの別名 (SAN) を検証することによって行います。
SAN DNS Name=eastus.metadata.azure.com, DNS Name=metadata.azure.com
の例
注意
パブリック クラウドと各ソブリン クラウドのドメインは異なります。
テーブルを展開する
注意
証明書は、ドメインと完全には一致しない場合があります。 このため、認定の検証では、サブドメインを受け入れる必要があります (たとえば、パブリック クラウドの一般提供リージョンでは、*.metadata.azure.com
を受け入れます)。
中間証明書では証明書のピン留めをお勧めしていません。 詳細なガイダンスについては、証明書のピン留め - 証明書のピン留めと Azure サービス に関する記事を参照してください。
Azure Instance Metadata Service では、証明機関の今後の変更に関する通知が行われないことに注意してください。
代わりに、今後のすべての更新については、一元的にまとめた記事「Azure 証明機関の詳細 」を参照してください。
サンプル 1:VM が Azure で実行されていることの検証
Azure Marketplace のベンダーは、自分たちのソフトウェアが Azure でのみ実行されるようにライセンスされていることを確認することを望みます。 だれかが VHD をオンプレミスの環境にコピーする場合、ベンダーはそれを検出できる必要があります。 これらのベンダーは、IMDS を介して、応答が Azure のみからであることを保証する署名付きデータを取得できます。
注意
このサンプルを実行するには、jq ユーティリティがインストールされている必要があります。
検証
$attestedDoc = Invoke-RestMethod -Headers @{"Metadata" ="true" } -Method GET -NoProxy -Uri http://169.254 .169.254 /metadata/attested/document?api-version =2020 -09 -01
$signature = [System.Convert]::FromBase64String($attestedDoc .signature)
シグネチャが Microsoft Azure からのものであることを確認し、証明書チェーンにエラーがないか検査します。
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]($signature )
$chain = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Chain
$chain .Build($cert )
foreach ($element in $chain .ChainElements)
{
Write-Host $element .Certificate.Subject
}
Add-Type -AssemblyName System.Security
$signedCms = New-Object -TypeName System.Security.Cryptography.Pkcs.SignedCms
$signedCms .Decode($signature );
$content = [System.Text.Encoding]::UTF8.GetString($signedCms .ContentInfo.Content)
Write-Host "Attested data: " $content
$json = $content | ConvertFrom-Json
curl --silent -H Metadata:True --noproxy "*" "http://169.254.169.254/metadata/attested/document?api-version=2020-09-01" | jq -r '.["signature"]' > signature
base64 -d signature > decodedsignature
openssl pkcs7 -in decodedsignature -inform DER -out sign.pk7
openssl pkcs7 -in decodedsignature -inform DER -print_certs -out signer.pem
curl -s -o intermediate.cer "$(openssl x509 -in signer.pem -text -noout | grep " CA Issuers -" | awk -FURI: '{print $2}') "
openssl x509 -inform der -in intermediate.cer -out intermediate.pem
openssl smime -verify -in sign.pk7 -inform pem -noverify
結果
Verification successful
{
"nonce" : "20181128-001617" ,
"plan" :
{
"name" : "" ,
"product" : "" ,
"publisher" : ""
},
"timeStamp" :
{
"createdOn" : "11/28/18 00:16:17 -0000" ,
"expiresOn" : "11/28/18 06:16:17 -0000"
},
"vmId" : "d3e0e374-fda6-4649-bbc9-7f20dc379f34" ,
"licenseType" : "Windows_Client" ,
"subscriptionId" : "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" ,
"sku" : "RS3-Pro"
}
署名が Microsoft Azure からのものであることを確認し、証明書チェーンにエラーがないか確認します。
openssl x509 -noout -subject -in signer.pem
openssl x509 -noout -issuer -in signer.pem
openssl x509 -noout -subject -in intermediate.pem
openssl x509 -noout -issuer -in intermediate.pem
openssl verify -verbose -CAfile /etc/ssl/certs/DigiCert_Global_Root.pem -untrusted intermediate.pem signer.pem
最初の要求で nonce
パラメーターを指定した場合、署名されたドキュメントの nonce
を比較できます。
システムによって割り当てられたマネージド ID は、VM 上で有効にすることができます。 1 つ以上のユーザー割り当てのマネージド ID を VM に割り当てることもできます。
その後、IMDS からマネージド ID のトークンを要求できます。 これらのトークンは、Azure Key Vault などの他の Azure サービスで認証するために使用します。
この機能を有効にするための詳細な手順については、アクセストークンの取得 に関するページを参照してください。
仮想マシンまたは仮想マシン セットのインスタンスを Azure Standard Load Balancer の背後に配置する場合は、IMDS を使用して、ロード バランサーとインスタンスに関連するメタデータを取得できます。 詳細については、ロード バランサー情報の取得 に関する記事を参照してください。
IMDS を使用すると、スケジュールされたイベントの状態を取得できます。 その後、ユーザーは、これらのイベントに対して実行する一連のアクションを指定できます。 詳細については、Linux のスケジュールされたイベント または Windows のスケジュールされたイベント に関する記事を参照してください。
次の表に、VM 内で各種の言語を使用して IMDS を呼び出す例を示します。
テーブルを展開する
見つからないデータ要素または形式に誤りがある要求が存在する場合、Instance Metadata Service は標準 HTTP エラーを返します。 次に例を示します。
テーブルを展開する
HTTP 状態コード
理由
200 OK
要求は成功しました。
400 Bad Request
リーフ ノードのクエリ時に Metadata: true
ヘッダーがないか、パラメーター format=json
がありません
404 Not Found
要求された要素は存在しません
405 Method Not Allowed
このエンドポイントでは、HTTP メソッド (Verb) はサポートされていません。
410 Gone
しばらくしてから再試行してください (最長 70 秒)
429 Too Many Requests
API の転送率の制限 を超えました
500 Service Error
しばらくしてからやり直してください
エラー 400 Bad Request, Required metadata header not specified
を取得しています。 これはどういう意味でしょうか。
IMDS では、要求に Metadata: true
ヘッダーを渡す必要があります。 このヘッダーを REST 呼び出しに渡すと、IMDS へのアクセスが許可されます。
使用している VM に関するコンピューティング情報を取得できないのはなぜですか。
現在、IMDS では、Azure Resource Manager で作成されたインスタンスのみがサポートされます。
しばらく前に Azure Resource Manager で VM を作成しました。 コンピューティング メタデータ情報が表示されないのはなぜですか。
2016 年 9 月以降に VM を作成した場合は、タグ を追加して、コンピューティング メタデータの表示を開始してください。 2016 年 9 月より前に VM を作成した場合は、VM インスタンスに対して拡張機能またはデータ ディスクを追加/削除して、メタデータを更新してください。
ユーザー データはカスタム データと同じですか?
ユーザー データには、カスタム データと同様の機能が用意されているため、独自のメタデータを VM インスタンスに渡すことができます。 違いは、ユーザー データが IMDS を通じて取得され、VM インスタンスの有効期間全体にわたって永続的であることです。 既存のカスタム データ機能は、この記事 で説明されているように機能し続けます。 ただし、カスタム データは、IMDS ではなくローカル システム フォルダーからのみ取得できます。
新しいバージョンに入力されたすべてのデータが表示されないのはなぜですか。
2016 年 9 月以降に VM を作成した場合は、タグ を追加して、コンピューティング メタデータの表示を開始してください。 2016 年 9 月より前に VM を作成した場合は、VM インスタンスに対して拡張機能またはデータ ディスクを追加/削除して、メタデータを更新してください。
エラー 500 Internal Server Error
または 410 Resource Gone
が発生するのはなぜですか。
要求を再試行してください。 詳細については、「一時的な障害の処理 」を参照してください。 問題が解決しない場合は、VM の Azure portal でサポートの問題を作成してください。
これはスケール セット インスタンスで機能しますか。
はい。IMDS はスケール セット インスタンスで使用できます。
スケール セットでタグを更新しましたが、(単一インスタンスの VM とは異なり) インスタンスにタグが表示されません。 操作方法に何か間違いがありますか。
現時点では、スケール セットのタグは、再起動、再イメージ化、またはインスタンスに対するディスクの変更の際に VM に対してのみ表示されます。
VM の SKU 情報が instance/compute
の詳細に表示されないのはなぜですか。
Azure Marketplace から作成されたカスタム イメージの場合、Azure プラットフォームではカスタム イメージの SKU 情報と、カスタム イメージから作成された VM の詳細は保持されません。 これは仕様であるため、VM instance/compute
詳細には表示されません。
サービスの呼び出しの要求がタイムアウト (または接続に失敗) するのはなぜですか。
Windows Server でのフェールオーバー クラスタリング
フェールオーバー クラスタリングを使用して IMDS に対してクエリを実行する場合は、ルーティング テーブルにルートを追加する必要がある場合があります。 その方法は次のとおりです。
管理者特権でコマンド プロンプトを開きます。
次のコマンドを実行し、IPv4 ルーティング テーブルのネットワーク宛先 (0.0.0.0
) のインターフェイスのアドレスをメモします。
route print
注意
次の出力例は、フェールオーバー クラスターが有効になっている Windows Server VM からのものです。 わかりやすくするために、出力には IPv4 ルート テーブルだけが含まれています。
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.0.1.1 10.0.1.10 266
10.0.1.0 255.255.255.192 On-link 10.0.1.10 266
10.0.1.10 255.255.255.255 On-link 10.0.1.10 266
10.0.1.15 255.255.255.255 On-link 10.0.1.10 266
10.0.1.63 255.255.255.255 On-link 10.0.1.10 266
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
169.254.0.0 255.255.0.0 On-link 169.254.1.156 271
169.254.1.156 255.255.255.255 On-link 169.254.1.156 271
169.254.255.255 255.255.255.255 On-link 169.254.1.156 271
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 169.254.1.156 271
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 169.254.1.156 271
255.255.255.255 255.255.255.255 On-link 10.0.1.10 266
次のコマンドを実行し、ネットワーク宛先 (0.0.0.0
) のインターフェイスのアドレスを使用します。この例では 10.0.1.10
です。
route add 169 .254 .169 .254 /32 10 .0 .1 .10 metric 1 -p
複数回試行してもメタデータの応答を取得できない場合は、Azure portal でサポートの問題を作成できます。
製品のフィードバックとアイデアは、[Virtual Machines] > [Instance Metadata Service] にあるユーザー フィードバック チャネル (>) にお寄せください