New-AzVm
Microsoft LearnでAzureを学習しています。
演習 - Azure PowerShell でスクリプトを使用して Azure リソースを作成する - Training | Microsoft Learn
でハマりました。
New-AzVm -ResourceGroupName *****-********-****-****-****-************ -Name "testvm-eus-01" -Credential (Get-Credential) -Location "japaneast" -Image UbuntuLTS -OpenPorts 22 -PublicIpAddressName "testvm-01"
New-AzVM: The platform image 'Canonical:UbuntuServer:20.04-LTS:latest' is not available.
Verify that all fields in the storage profile are correct.
For more details about storage profile information, please refer to https://aka.ms/storageprofile
-Image UbuntuLTS
がCanonical:UbuntuServer:20.04-LTS:latest
を指すのがわかるけど、それが使えないってどういうこと?
ポータルで見てみる
色々調べて
ARMの情報の通りにVMのソースイメージの指定のしかたを厳密にすれば特定のUbuntuのイメージを特定できることはわかりましたが、
初心者なのでまだあまりゴリゴリ書きたくない...
どうも、CanonicalによるLTS版の扱いに起因しているようです。
Can't find ubuntu 20.04 with azure cli · Issue #13320 · Azure/azure-cli · GitHub
解決策
上記Issueでの投稿を参考に、パラメータを変えて解消
ポータルから作成した時に気づいたけど、-Name
と-PublicIpAddressName
も合わせておかないとうまくいかないようです。
New-AzVm -ResourceGroupName *****-********-****-****-****-************ -Name "testvm-jeast-01" -Credential (Get-Credential) -Location "japaneast" -Image "Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest" -OpenPorts 22 -PublicIpAddressName "testvm-01"