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 で ubuntu のVMを起動/削除する

Last updated at Posted at 2024-01-18

Azure CLI で Ubuntu のVMを起動/削除する手順を解説します。

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

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

リソースグループの作成

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

Ubuntu VM の起動

az vm create --location japaneast^
 --resource-group vm_resource_group^
 --name ubuntu-vm^
 --image Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2: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 SSH^
 --admin-username admin01^
 --admin-password SampleVM!123

👇下記内容が出力されるので、publicIpAddressを利用してSSH接続できます。

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

👇SSH接続イメージ
image.png

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

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

VM削除

az vm delete^
 --resource-group vm_resource_group^
 --name ubuntu-vm^
 --yes

リソースグループの削除

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

👇関連記事

👇参考URL

[keywords]
Azure CLI Ubuntu

Azure CLI で Ubuntu の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?