LoginSignup
21
23

More than 5 years have passed since last update.

Vagrant と Azure と Windows

Posted at

Vagrant と Azure で使い捨て開発環境をさくっと作る の続き。

なんとなく vagrant と言った時に操作される対象は Linux を想定しているのが暗黙の了解な気がするし、普段の開発環境は Mac か Linux なので、それで事足りる。でも Azure なら Windows も使えるし、というかそっちが本業だろうし、vagrant から Windows な VM を操作できたら便利だなーと思ってやってみたら案外簡単だった。

準備

Mac なら Microsoft Remote Desktop をインストールしておく。Linux は... どうなんだろう。

Vagrantfile

# vi: set ft=ruby :

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'azure'

Vagrant.configure('2') do |config|

  config.vm.provider :azure do |provider, override|
    provider.subscription_id      = 'abcdefgh-1234-5678-9abc-d123456789ab'
    provider.mgmt_certificate     = '/Users/zakkie/azure-api/azure.pem'
    provider.mgmt_endpoint        = 'https://management.core.windows.net/'

    # vm settings
    provider.vm_image             = 
      'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201403.01-en.us-127GB.vhd'
    provider.vm_location          = 'Japan East'
    provider.vm_size              = 'Small'
    provider.vm_name              = 'zakkie-test017'
    provider.cloud_service_name   = 'zakkie-test017'
    provider.tcp_endpoints        = '3389:53389'

    override.ssh.private_key_path = '/Users/zakkie/.ssh/azure.key'
    override.vm.box               = 'azure'
    override.vm.box_url           = 'https://github.com/msopentech/vagrant-azure/raw/master/dummy.box'
  end
end

provider.tcp_endpoints = '3389:53389' を設定しておかないと Remote Desktop 接続が出来ないので注意。

あとは vm_image が Windows のものになったのと、SSH 関連の設定が無くなった以外は前回の設定と同じ。

なお、Azure の Web Console で Windows Server を選択すると、サイズは A0 - A7 の中から選ぶようになっているが、A0 - A4 を vm_size に指定するとエラーになる。
A0 - A4 は以下のように読み替える必要がある。

  • A0: ExtraSmall
  • A1: Small
  • A2: Medium
  • A3: Large
  • A4: ExtraLarge

起動

% vagrant up
% vagrant rdp
# Remote Desktop クライアントが起動するので、パスワードを入力する。
# ログインまでやってくれると楽なんだけど出来ないぽい。
(do something)
% vagrant destroy

vagrant up からログインまで 3 分ちょっと。3 分ちょっとでまっさらな Windows 環境を作ることができる。素晴らしい。

まあ欲を言えば、windows server だけでなく vista とか 7 とか クライアント OS が標準イメージで揃っているとテストが捗るな、とか、IE も各バージョン揃っているといいなとか、色々あるけど、azure のユースケース的に難しいのかなと想像。

あとは chef みたいにプロビジョニングまで出来るといいんだけど、Windows は門外漢すぎてさっぱり分からない。

21
23
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
21
23