I found the documentation of how to get the vagrant-azure plugin working quite lacking, so here are some more complete instructions for those out there who might be starting out with Vagrant and Azure who aren't running Windows as their desktop.
This project was developed on OSX Mavericks, creating an Ubuntu Trusty Tahr 14.04 LTS VM on Azure.
- Vagrant
- Vagrant-azure plugin
- Microsoft Azure account
- Node package manager
- Azure Command line tools
- Various X.509 certs and keys that Azure requires
Download and install vagrant from here
Install the plugin with the command vagrant plugin install vagrant-azure
If you don't already have an Azure account you can sign up for a trial here
If you're using homebrew you can just perform brew install node
. Alternatively you can install node using these directions. You really only need this for the Node package manager, npm.
Install the Azure CLI tools npm install azure-cli -g
. The full list of available commands can be viewed here.
Here are the directions to setup the Azure CLI tools, generate the necessary keys and find out the correct information about the Azure environment that you need for you Vagrantfile. You should perform all of the commands below.
azure account download
Download your account details. This comes in a file and contains sentitive information. Keep it safe.azure account import publishsettings.publishsettings
Import your account details from the file you just downloaded.azure account list
Note down the ID of the account where you want to create your vagrant VM.azure vm image list
Note down the name of the base image from which you'd like to create your VM.azure vm location list
Decide what location to create the machine.
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout cert.pem -out cert.pem
Create an X.509 certificate to authenticate with Azure. You can leave all the identification information blank if you wish. Azure doesn't care.openssl pkcs12 -export -out cert.pfx -in cert.pem -name "My Cert"
Create a pkcs12 archive (~Microsoft Parallel FX) from the X.509 cert. Enter an encryption password if you wish.openssl x509 -inform pem -in cert.pem -outform der -out cert.cer
Create .cer certificate to upload to Azure.
I'll assume you already have an RSA pub/private ssh key to log into *nix machines. You may not have an X.509 key that Azure requires however. You could use the one you just created, however you may prefer to create one from your existing RSA private key so that you can log in with your normal credentials.
openssl req -new -x509 -key ~/.ssh/id_rsa -out ~/.ssh/ssh-cert.pem
Download this dummy box that vagrant need to use the azure provider.
vagrant box add azure https://github.com/msopentech/vagrant-azure/raw/master/dummy.box
Finally you're ready to start creating your Vagrantfile. Clone this repo and update the vagrant file with the necessary details from the instructions above.
Parameter | Explanation |
---|---|
azure.mgmt_certificate | created in step step 6 |
azure.subscription_id | from step 3 |
azure.vm_image | from step 4 |
azure.vm_location | from step 5 |
azure.ssh_private_key_file | your private rsa key for the vagrant-azure plugin |
azure.ssh_certificate_file | from step 9 |
config.ssh.private_key_path | your private rsa key for vagrant |
Now you should be ready to create your vagrant box on Azure.
vagrant up --provider=azure