Azure: Setup a development environment part 2

code,test,code,test,deploy <3

Azure has a free tier for the first year, however be aware certain thing do cost money. By each resource that will cost you money I will show you the $ sign. Do not forget to remove/disabled/shutdown resources you don’t use anymore!!!

In part 1 we setup up the Azure prerequisites and confirmed that we’re able to connect to Azure with Ansible. In this part I will show you how to deploy a vm with Docker on it. It is pretty straight forward. First git clone my azure git repositorie

$ git clone https://github.com/maikell/azure.git

Setup up vm prerequisites

Before you can deploy a VM you will need to setup some things. To have a better understanding how and why I encourage you to read the following document of Microsoft: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/create-cli-complete

The following things needs be in place before we can deploy a VM:

  • Resource group
  • Virtual network
  • Subnet
  • Request a public ip-address ($$$)
  • Security group
  • Network interface that attaches the public ip-address

Manually this would be quite some work. Lucky for you I automated this with the following Ansible script: https://github.com/maikell/azure/blob/master/vm_provision/create_resource_and_network.yml

As you might have noticed I include a var file and that can be found at:
https://github.com/maikell/azure/blob/master/vm_provision/vars/main.yml
Run the following playbook the setup all the resources:

$ ansible-playbook vm_provision/create_resource_and_network.yml

Deploying an Azure VM

Now that all the resources are in place we can request a VM. For requesting the VM define a list of new values:

If you git cloned the Azure repo the VM can be easily deployed with:

$ ansible-playbook vm_provision/create_vm.yml
Output of a successfully deployment

Remove all resources and the VM

I can’t stress this part enough: When ever you are done with playing around and want to stop: Remove all resources. This prevents unforeseen costs. A resource group can be deleted within the Azure portal or fairly easily. Just be aware this will throw away the complete resources and the group: development.

$ ansible-playbook vm_provision/destroy_all.yml

Leave a Comment