VagrantでAzureを使ってみた話
-
Upload
yuta-matsumura -
Category
Technology
-
view
328 -
download
3
Transcript of VagrantでAzureを使ってみた話
Vagrant で Azure を使ってみた話
2014/12/22 ふくあず
松村優大
自己紹介
•松村優大 ( Yuta Matsumura )
• C#, VB.NET, VB6
• Twitter → @tsubakimoto_s
•島根県出身(スタバあります)
2
今日のお話
•みんな大好き Microsoft Azure と Vagrant
• Vagrant から Azure の仮想マシンを
作ったり壊したりしてみるための手順をご紹介します。
3
4
Vagrant
•仮想マシンの構築や配布を便利にしてくれるツール。
•仮想マシンの構成は Vagrantfileで管理。
• Windows の仮想マシンにも対応。
•豊富なプラグイン。
• http://vagrantup.com/
5
Vagrant のコマンド
• vagrant up … 仮想マシンの作成/起動
• vagrant destroy … 仮想マシンの破棄
• vagrant ssh … 仮想マシンへのSSH接続
• vagrant rdp … 仮想マシンへのリモートデスクトップ接続
6
Vagrant で Azure を使う
① 管理証明書の作成・アップロード
② プラグインの導入
③ Vagrantfileの作成
④ 仮想マシンの起動
7
管理証明書
•コマンドライン、または GUI で管理証明書を作成。
• GUI での参考
• http://www.techno-officer.com/blog/archives/1671
•今回はコマンドラインで管理証明書を作成。
• Visual Studio 開発者ツール、 Gitを利用。
8
VS開発者ツールを使う
9
makecert -r -pe -n CN=azure-cert -sky exchange azure.cer -sv azure.pvk
pvk2pfx -pvk azure.pvk -spc azure.cer -pfx azure.pfx
openssl pkcs12 -in azure.pfx -out azure.pem -nodes
管理証明書
• .cerは Azure にアップロード、.pemは Vagrant で使用。
11
プラグインの導入
• vagrant plugin install vagrant-azure
• https://github.com/MSOpenTech/vagrant-azure
12
Vagrantfileの作成
• Azure に接続するための設定を Vagrantfileに記述。
•サンプルは Githubに公開されているが英語のため苦戦。
•和訳
• https://github.com/tsubakimoto/vagrant-azure#configuration
•サンプル
• https://gist.github.com/tsubakimoto/c389925be109239532d6
13
仮想マシンの起動
• vagrant up --provider=azure
•気長に待ちましょう。
14
$ vagrant up --provider=azure
==> default: Attempting to read state for vagrant-test-01 in vagrant-test-01
Bringing machine 'default' up with 'azure' provider...
==> default: Attempting to read state for vagrant-test-01 in vagrant-test-01
==> default: Attempting to read state for vagrant-test-01 in vagrant-test-01
==> default: {:vm_name=>"vagrant-test-
01", :vm_user=>"vagrant", :image=>"a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201411.01-
en.us-127GB.vhd", :password=>"lG6Yskj7Sl", :location=>"Japan West"}
==> default: {:cloud_service_name=>"vagrant-test-
01", :storage_account_name=>"vagranttest01storagegnxa", :tcp_endpoints=>"80,3389:53389", :vm_size=>"ExtraSm
all", :winrm_transport=>["http", "https"]}
ResourceNotFound : The hosted service does not exist.
==> default: Add Role? - false
Creating deploymnent...
Creating cloud service vagrant-test-01.
Creating Storage Account vagranttest01storagegnxa.
# # # # succeeded (200)
Deployment in progress...
# # # # # # succeeded (200)
==> default: Attempting to read state for vagrant-test-01 in vagrant-test-01
==> default: VM Status: RoleStateUnknown
==> default: Waiting for machine to reach state ReadyRole
==> default: Attempting to read state for vagrant-test-01 in vagrant-test-01
仮想マシンを使い終えたら
• vagrant halt … 仮想マシンの停止
• 仮想マシンはシャットダウンした状態。従量課金は続く。
• vagrant destroy … 仮想マシンの破棄
• Azure から仮想マシンやクラウドサービスを削除。
16
ストレージアカウントは手動削除
•ポータル、または Azure PowerShell で削除。
17
PS C:\> Get-AzureDiskPS C:\> Remove-AzureDisk –DiskName (ディスク名)
今日の資料
https://gist.github.com/tsubakimoto/c389925be109239532d6
18
ありがとうございました。
良いお正月を。