1
3

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 5 years have passed since last update.

Azure でカスタムイメージを作成したときのメモ

Last updated at Posted at 2017-03-21

概要

カスタムイメージを作ったときに何をしたかをメモしておく

前提

あらかじめ、Azure上にAzureで提供されているイメージから、必要な状態にしたマシンを作製しておく

結論

2017年3月17日の時点では、このページをみればよかった。

PowerShell の場合

Azure CLI 1.0 の場合

Azure CLI 2.0 の場合

実際の作業

今回は Azure CLI 2.0 の方法を、Azure CLi 0.10.6 (docker)で実行し、
途中から Azure CLI 1.0 の方法に切り替えた。
作業はじめたときに見落としていたので。

azure config arm

なっている前提

1. 元となるVMのプロビジョニングを解除する

azureuser@standalonevm:~$ sudo waagent -deprovision+user -force
WARNING! The waagent service will be stopped.
WARNING! All SSH host key pairs will be deleted.
WARNING! Cached DHCP leases will be deleted.
WARNING! Nameserver configuration in /etc/resolvconf/resolv.conf.d/{tail,original} will be deleted.
WARNING! azureuser account and entire home directory will be deleted.

メッセージを読むと、SSH の鍵などが削除されるとある。

このコマンドの実行後確認してみた

azureuser@standalonevm:~$ ls -lar
total 0

2. azure vm deallocate で VM の割当を解除

sshを接続したままで、以下のコマンドを実行すると、sshの接続が解除されるので、
なにか作業があるときは、早めに行っておくこと。

azure vm deallocate --resource-group TESTRESOURCEGROUP1 --name standalonevm

数分ほど時間がかかって、終了した

azure vm deallocate --resource-group TESTRESOURCEGROUP1 --name standalonevm
info:    Executing command vm deallocate
+ Looking up the VM "standalonevm"                                              
+ Deallocating the virtual machine "standalonevm"   

3. azure vm generize で一般化する

このコマンドは、すぐにおわった

root@3371f3750d51:/# azure vm generalize --resource-group TESTRESOURCEGROUP1 --name standalonevm
info:    Executing command vm generalize
+ Looking up the VM "standalonevm"                                              
+ Generalizing the virtual machine "standalonevm"                               
info:    vm generalize command OK

4. azure vm capture で、VMをキャプチャする

これは

root@3371f3750d51:/# azure vm capture -g TESTRESOURCEGROUP1 -n standalonevm -p standalonevm -t standalonevm.json
info:    Executing command vm capture
+ Looking up the VM "standalonevm"
+ Capturing the virtual machine "standalonevm"
info:    Saved template to file "standalonevm.json"
info:    vm capture command OK
1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?