Inside Out

And a VM in the clouds

So we got our shiny new box setup with vagrant-azure. It was as easy as a few commands…

sudo pacman -S vagrant vagrant plugin install vagrant-azure vagrant box add azure https://github.com/msopentech/vagrant-azure/raw/master/dummy.box# create our configurationmkdir azure-vm vagrant init gvim VagrantFile# create bunch of certificates for azure management and winrm# see https://github.com/MSOpenTech/vagrant-azure#using-openssl-linuxmacvagrant up --provider=azure

Here's the gist for a [sample config](https://gist.github.com/codito/aec6a5bd2d704f930350).

If you're not sure which `vm_image` to use, you can get the list with `azure vm image list` after installing [azure command line tools for linux/mac](http://azure.microsoft.com/en-us/documentation/articles/command-line-tools/).

**Two diagnostics tips that saved my morning :)**

- If you see error messages from `vagrant`, enable the [diagnostic logging](http://docs.vagrantup.com/v2/other/debugging.html) with `export VAGRANT_LOG=debug`, rerun `vagrant up`
  • Now we’re onto the part where azure throws cryptic messages like InvalidXmlRequest :) With all the calmness, we monkeypatch and enable Net::HTTP.set_debug_output and examine the REQUEST and RESPONSE xmls. It takes a little trial and error to figure out winrm_https_port was empty in the configuration! This gist has a sample of monkey patch in the VagrantFile, just remove the comment from Net::HTTP.enable_debug!() (thanks to https://gist.github.com/kaiwren/591601). Config as code for the win!

**OK, the final awesomeness is...**

Linux host executing a powershell command on remote windows virtual machine on Azure

![Vagrant + Azure + Powershell + Chocolatey](/content/images/2015/02/vagrant_azure_powershell_chocolatey.jpg)

Wish there were a tool for Linux/Mac to create a persistent remote powershell session (just like ssh) to azure vm with WinRM!