システム ID を使用して Marketplace 測定サービス アプリケーション ID (00001111-aaaa-2222-bbbb-3333cccc4444) のアクセス トークンを取得し、VM に RDP 接続し、PowerShell コンソールを開き、コマンドを実行します。
# curl is an alias to Web-Invoke PowerShell command
# Get system identity access tokenn
$MetadataUrl = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F"
$Token = curl -H @{"Metadata" = "true"} $MetadataUrl | Select-Object -Expand Content | ConvertFrom-Json
$Headers = @{}
$Headers.Add("Authorization","$($Token.token_type) "+ " " + "$($Token.access_token)")
現在のリソース グループ 'ManagedBy' プロパティからマネージド アプリ ID を取得します (Kubernetes アプリ オファーでは必要ありません)。
# Get subscription and resource group
$metadata = curl -H @{'Metadata'='true'} http://169.254.169.254/metadata/instance?api-version=2019-06-01 | select -ExpandProperty Content | ConvertFrom-Json
# Make sure the system identity has at least reader permission on the resource group
$managementUrl = "https://management.azure.com/subscriptions/" + $metadata.compute.subscriptionId + "/resourceGroups/" + $metadata.compute.resourceGroupName + "?api-version=2019-10-01"
$resourceGroupInfo = curl -Headers $Headers $managementUrl | select -ExpandProperty Content | ConvertFrom-Json
$managedappId = $resourceGroupInfo.managedBy