https://learn.microsoft.com/ja-jp/azure/virtual-machines/linux/create-cli-complete?source=recommendations
https://learn.microsoft.com/en-us/azure/azure-resource-manager/troubleshooting/error-invalid-template?tabs=bicep#solution-5---circular-dependency-detected
-- 1. 前作業
az login --use-device-code
az account show
az version
az configure --list-defaults
az configure --defaults location=japaneast
az configure --list-defaults
az group create \
--name rg01 \
--location japaneast
az group list
-- 2. vm作成
az vm create \
--resource-group rg01 \
--name vm01 \
--image UbuntuLTS \
--size Standard_B1ls \
--admin-username azureuser \
--generate-ssh-keys \
--storage-sku Standard_LRS
-- 3. テンプレートとしてのエクスポート
az group export --name rg01 > rg01.json
循環参照を含む不完全なテンプレートが出力されるので
エラーが消えるまでテンプレートを修正する
cp rg01.json rg01.json.orig
vim rg01.json
77行目付近 requireGuestProvisionSignal 削除
94行目付近 osDisk.managedDisk.id 削除
106行目付近 dependsOn 削除
160行目付近 dependsOn 削除
-- 4. テンプレートからデプロイ
az deployment group create \
--resource-group rg01 \
--template-file rg01.json \
--parameters networkInterfaces_vm01VMNic_name=vm02VMNic \
networkSecurityGroups_vm01NSG_name=vm02NSG \
publicIPAddresses_vm01PublicIP_name=vm02PublicIP \
virtualMachines_vm01_name=vm02 \
virtualNetworks_vm01VNET_name=vm02VNET
-- 5. クリーンアップ
az group list
az group delete \
--name rg01 \
--yes
az group delete \
--name NetworkWatcherRG \
--yes