Microsoft Azure 仮想マシン用の Systems Manager をセットアップ
ネイティブ Azure Instance Metadata Service (IMDS) 統合のハイブリッドアクティベーションプロセスを使用して、Azure 仮想マシン (VM) を Systems Manager マネージドノードとして登録できます。登録時に -provider Azure パラメータを指定すると、SSM Agent は Azure IMDS エンドポイントから直接 Azure VM ID データを読み取り、マネージドノードをソース Azure VM に関連付けます。
この統合には、次のような利点があります。
-
インスタンス ID の関連付け: SSM マネージドノード (mi-) は Azure VM ID に自動的にリンクされるため、クラウド間で一貫したリソース追跡が可能になります。
-
豊富なメタデータコレクション: サブスクリプション ID、リソースグループ、場所、アベイラビリティーゾーンなどの Azure VM プロパティがキャプチャされ、マネージドノード属性として表示されます。
-
セキュリティの強化: 明示的なプロバイダー指定により、IMDS なりすまし攻撃を防ぎ、認証情報が適切なクラウドプロバイダーにスコープされるようにします。
注記
開始する前に、「ハイブリッドおよびマルチクラウド環境で Systems Manager に必要な IAM サービスロールを作成する」および「ハイブリッドアクティベーションを作成して、Systems Manager にノードを登録する」で説明されているように、前提条件のステップを完了して IAM サービスロールとハイブリッドアクティベーションを作成します。
Azure Linux VM に SSM Agent をインストール
Azure Linux VM に SSM Agent をインストールして登録するには、次の手順に従います。
Azure Linux VM に SSM Agent をインストールするには
-
Azure VM に接続します。
-
以下のコマンドを実行します。プレースホルダー値を、ハイブリッドアクティベーションプロセス中に生成されたアクティベーションコードとアクティベーション ID、および使用する AWS リージョン の識別子に置き換えます。
注記
次のコマンドで
linux_amd64バイナリを使用します。Azure VM が ARM64 プロセッサ (Dpsv5 や Epsv5 シリーズなど) を使用している場合は、linux_amd64をlinux_arm64に置き換えます。mkdir /tmp/ssm curl https://amazon-ssm-region.s3.region.amazonaws.com/latest/linux_amd64/ssm-setup-cli -o /tmp/ssm/ssm-setup-cli sudo chmod +x /tmp/ssm/ssm-setup-cli sudo /tmp/ssm/ssm-setup-cli -register \ -activation-code "activation-code" \ -activation-id "activation-id" \ -region "region" \ -provider Azure -
SSM Agent が実行中であり、登録データが正しく書き込まれていることを確認します。
sudo systemctl status amazon-ssm-agent cat /var/lib/amazon/ssm/registration
Azure Windows Server VM に SSM Agent をインストール
Azure Windows Server VM に SSM Agent をインストールして登録するには、次の手順に従います。
Azure Windows Server VM に SSM Agent をインストールするには
-
Azure VM に接続します。
-
昇格された (管理者) モードで Windows PowerShell を開きます。
-
Windows PowerShell に以下のコマンドブロックを貼り付けます。各
リソースプレースホルダーの例をユーザー自身の情報に置き換えます。注記
次のコマンドで
windows_amd64バイナリを使用します。Azure VM が ARM64 プロセッサを使用している場合は、windows_amd64をwindows_arm64に置き換えます。[System.Net.ServicePointManager]::SecurityProtocol = 'TLS12' $code = "activation-code" $id = "activation-id" $region = "us-east-1" $dir = $env:TEMP + "\ssm" New-Item -ItemType directory -Path $dir -Force cd $dir (New-Object System.Net.WebClient).DownloadFile("https://amazon-ssm-$region.s3.$region.amazonaws.com/latest/windows_amd64/ssm-setup-cli.exe", $dir + "\ssm-setup-cli.exe") Start-Process ./ssm-setup-cli.exe -ArgumentList @( "-register", "-activation-code=$code", "-activation-id=$id", "-region=$region", "-provider=Azure" ) -Wait -NoNewWindow Get-Content ($env:ProgramData + "\Amazon\SSM\InstanceData\registration") Get-Service -Name "AmazonSSMAgent"
Azure VM メタデータマッピング
-provider Azure パラメータを使用して Azure VM を登録すると、SSM Agent は Azure IMDS エンドポイント (http://169.254.169.254/metadata/instance) から次のプロパティを読み取り、対応する Systems Manager マネージドノード属性にマッピングします。
| マネージド型ノードプロパティ | Azure IMDS フィールド | 値の例 |
|---|---|---|
ComputerName |
{compute.subscriptionId}:{compute.resourceGroupName}:{compute.name} |
14724fea-7bad-4c32-8af0-ebde38f42a46:MyRG:my-azure-vm |
SourceType |
ハードコード | Microsoft.Compute/virtualMachines |
SourceID |
{compute.vmId} |
1724afd8-9092-429e-8b04-0708130c38f7 |
SourceLocation |
{compute.location} |
centralus |
AvailabilityZone |
{compute.zone} |
1 |
AvailabilityZoneId |
Zone{compute.zone} |
Zone1 |
DescribeInstanceInformation を使用してマネージドノード登録を検証
登録後、 describe-instance-information コマンドを使用して Azure VM メタデータが正しくキャプチャされたことを確認します。次の例では、Azure VM ID を使用して SourceId でフィルタリングします。
aws ssm describe-instance-information \ --filters "Key=SourceIds,Values=1724afd8-9092-429e-8b04-0708130c38f7" \ --regionus-east-1
レスポンスには、マネージドノード ID (プレフィックスは mi-) と、ComputerName、SourceId、SourceType などの入力済みメタデータフィールドが含まれます。
{ "InstanceInformationList": [ { "InstanceId": "mi-008d36be46EXAMPLE", "ComputerName": "14724fea-7bad-4c32-8af0-ebde38f42a46:MyRG:my-azure-vm", "SourceId": "1724afd8-9092-429e-8b04-0708130c38f7", "SourceType": "Microsoft.Compute/virtualMachines", "SourceLocation": "centralus", "AvailabilityZone": "1", "AvailabilityZoneId": "Zone1", "PingStatus": "Online", "PlatformType": "Linux", "PlatformName": "Ubuntu", "PlatformVersion": "24.04" } ] }