Deploying resources to Azure using Azure DevOps

Recently someone asked me how to deploy an Azure service using Azure DevOps. In this Blog Post a simple howto how to deploy a virtual machine on Azure using DevOps.

Step 1 Create an ARM template

For this first step create an IaaS VM with all the settings you need. Notice in the final step the following options :

ARMDEV01

Choose to download the template for automation.

ARMDEV02

Choose Download. You now a template.zip file with two files (parameters and template). Rename the two files to identify them in the future.

Step 2 Upload the template to the Azure DevOps repository

Go to your DevOps project|Files. In my demo enviroment I’ve created a tree with all my templates.

ARMDEV03

As you can see i’ve renamed the 2 files to demo_vm_parameters and demo_vm_template.

ARMDEV04

After uploading the template, now let’s create a release pipeline!

Step 3 Create a release Pipeline

Go to Pipeline|Releases

ARMDEV05

We are going to create a New release pipeline :

ARMDEV06

Choose to start with an Empty job (we are going to fill it in manually)

ARMDEV07

Give your stage name a name that makes sence 🙂

ARMDEV08

Now choose to add an artificat (the location where your templates are located)

ARMDEV09

Choose the repository you’re using. In my case I’m using an Azure Repo.

ARMDEV10

Select add. Now choose the link with 0 task and add an agent:

ARMDEV11

We are going to deploy an ARM template, so therefore choose the ARM template deployment agent.

ARMDEV12

After you press add, we can configure this agent with all the necessary parameters. Notice the Template and Template parameters. Here you select the 2 files you’ve just uploaded.

ARMDEV13

Ok! Release pipeline created. Check!

Now….

Step 4 Create an release

ARMDEV14

Choose the Create release option and see that your first release (Release-1) has been created:

ARMDEV15

Click the Release-1 link to see the status of your deployment..

Oh oh…. Failed doesn’t seem to look to good….

ARMDEV16

I think we must read the next chapter quickly 🙂

Step 5 Troubleshooting

Click the Failed link to see the error. As you can see, it has something to do with the adminPassword beeing null. That’s correct. For demonstration purposes I’ve intensely uploaded the out-of-the-box template file. For security purposes the Azure portal doesn’t include the admin password when exporting it to an ARM template file. Let’s fix this!

ARMDEV17

Go tho your Repository and edit the parameters file:

ARMDEV18

Change the null to “somethingElseP2Swword” or any other password. Now commit this file.

ARMDEV19

Now let’s try again. Create another release of the Pipeline you’ve just created and click the link immediatly to follow the progress :

ARMDEV20

Et voila! The Stage was succeeded! Congrats! Job well done!

ARMDEV21

As you can see all the steps are completed succesfully:

ARMDEV22

And when you logon to the Azure Portal, you see your demovm IaaS VM running!

ARMDEV23

1 Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.