0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure CLI で Windows11 のVMを起動/削除/イメージ作成/イメージからの起動をする

Posted at

Azure CLI で Windows11 のVMを起動/削除/イメージ作成/イメージからの起動をする手順を解説します。

サブスクリプションの指定(省略可)

az account set --subscription "******-******-******-******"

***-***-***-***-***にはサブスクリプションIDを指定します。

リソースグループの作成

az group create^
 --name vm_resource_group^
 --location japaneast

Windows VM の起動

az vm create --location japaneast^
 --resource-group vm_resource_group^
 --name win-11-vm^
 --image MicrosoftWindowsDesktop:Windows-11:win11-22h2-pro:latest^
 --size Standard_B1ms^
 --public-ip-address public_ip_01^
 --public-ip-sku Standard^
 --data-disk-delete-option Delete^
 --os-disk-delete-option Delete^
 --nic-delete-option Delete^
 --nsg nsg_01^
 --vnet-name vnet_01^
 --priority Regular^
 --nsg-rule RDP^
 --admin-username admin01^
 --admin-password SampleVM!123

👇下記内容が出力されるので、publicIpAddressを利用してリモートデスクトップ接続できます。

{
  "fqdns": "",
  "id": "/subscriptions/*****-*****-*****/resourceGroups/vm_resource_group/providers/Microsoft.Compute/virtualMachines/win-11-vm",
  "location": "japaneast",
  "macAddress": "**********",
  "powerState": "VM running",
  "privateIpAddress": "10.0.0.4",
  "publicIpAddress": "**.**.**.**",
  "resourceGroup": "vm_resource_group",
  "zones": ""
}

👇リモートデスクトップ接続イメージ
image
image

VM停止

az vm deallocate^
 --resource-group vm_resource_group^
 --name win-11-vm

VMイメージ作成

az sig create^
 --resource-group vm_resource_group^
 --location japaneast^
 --gallery-name shared_image_gallery_01
az sig image-definition create^
 --resource-group vm_resource_group^
 --gallery-name shared_image_gallery_01^
 --gallery-image-definition win-11-vm-image_01^
 --publisher GreatPublisher^
 --offer Windows-11^
 --sku win11-22h2-pro^
 --os-type windows^
 --hyper-v-generation V2^
 --location japaneast^
 --features SecurityType=TrustedLaunch^
 --os-state Specialized
az sig image-version create^
 --resource-group vm_resource_group^
 --gallery-name shared_image_gallery_01^
 --gallery-image-definition win-11-vm-image_01^
 --gallery-image-version 0.0.1^
 --location japaneast^
 --virtual-machine /subscriptions/***-***-***-***-***/resourceGroups/vm_resource_group/providers/Microsoft.Compute/virtualMachines/win-11-vm^
 --no-wait

***-***-***-***-***にはサブスクリプションIDを指定します。

イメージからのVM作成

az vm create --location japaneast^
 --resource-group vm_resource_group^
 --name win-11-vm^
 --image /subscriptions/***-***-***-***-***/resourceGroups/vm_resource_group/providers/Microsoft.Compute/galleries/shared_image_gallery_01/images/win-11-vm-image_01^
 --size Standard_B1ms^
 --public-ip-address public_ip_01^
 --public-ip-sku Standard^
 --data-disk-delete-option Delete^
 --os-disk-delete-option Delete^
 --nic-delete-option Delete^
 --nsg nsg_01^
 --vnet-name vnet_01^
 --priority Regular^
 --nsg-rule RDP^
 --specialized true^
 --security-type TrustedLaunch^
 --admin-username admin01^
 --admin-password SampleVM!123

***-***-***-***-***にはサブスクリプションIDを指定します。

VM削除

az vm delete^
 --resource-group vm_resource_group^
 --name win-11-vm^
 --yes

リソースグループの削除

az group delete^
 --name vm_resource_group^
 --yes

ユーザー割り当てマネージドIDによるAzureリソースへのアクセス権限付与

ユーザー割り当てマネージドIDによるAzureリソースへアクセス権限を付与する手順は下記記事参照下さい。
ユーザー割り当てマネージドIDによるAzureリソースへのアクセス権限付与

👇関連記事

本記事へのリンク

image

https://docs.saurus12.com/azure/windows11_vm

👇参考URL

[keywords]
Azure CLI Windows11 イメージ

Azure CLI で Windows11 のVMを起動/削除/イメージ作成/イメージからの起動をする

更新日:2024年01月23日

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?