Azure Basics Part 6 – Template Deployment

In my last post I mentioned ‘Deployment scripts’ and after that I got few comments and e-mails about this subject. So I decided to make it subject of my next post.

Template deployment is one of the benefits of ARM (Azure Resource Manager). ARM enables you to bind different resources into resource group and view those resources as one entity. Then you can save deployment template of whole resource group and redeploy all resources in this resource group together. I will explain more as we move from one step to another.

If you open resource groups in Azure portal, you will see list of all resource groups in your account. In my last post I created resource group named ‘demo’ and I will use this resource group again.

1

After you select your resource group, you will see overview of this group. It will show list of all resources that belong to this specific group. In my case it will show my primary database server (demotoroman), database on this server (AzureDemo), secondary database server (demoreplication), database used for replication (AzureDemo) and storage used for logs (sqldemologs). I will now go to ‘Automation scripts’.

2

Automation script (deployment template) will be auto-generated. You can choose to download it, add to library or re-deploy from this window. Final result of all three options will be same. If you choose to download, it will create zip file for you that you’ll be prompted where to save on your PC. I would recommend to either save template or add it to library. If you do those two you’ll have no problem to redeloy in any situation. On other hand, you’ll have big problem if you want to redeploy your resource group from automation script window becouse something is missing or it’s been deleted. It will be deleted in this template as well. So, once you have your solution working, SAVE TEMPLATE.

3

If you choose to add to library, new tile will open where you have to give name to this template and to write some description.

4

Now if you added your template to library or downloaded it, you can do new deployment whenever you want. This can be useful in many situations. Maybe someone messed with your resource group, accidently deleted something and you can’t fix it. This template enables you to do new deployment of working resource group in few steps. Go to add new resource and write ‘template deployments’ in search.

5

Now select ‘Template deployments’ and wait for new tile to open.

6

Click create and wait for another new tile.

7

First select edit template.

8

This tile will be similar to one that we saw when we selected automation script.

9

Open JSON file you downloaded before in your deployment script and copy entire content.

10

Go back to template in portal and paste this content. It will automatically sort everything and recognize parameters, variables and resources. Note that all passwords are set to ‘null’ in templates and you’ll have to edit those values or deployment will fail.

11

After you’re done with template, go to edit parameters. As some resources must have unique name you’ll have to rename them. For example, you can’t have two Azure SQL Server with same name. Same goes with all services that use FQDN to access (cloud services, web sites…), those have to have unique name on Azure level. I also like to name resources different so I can tell them apart easier. In this case I will simply add b letter on all parameters so I know this is replica of my original deployment.

12

All that’s left to do is select your subscription, name your resource group, select region and accept legal terms. Then click ‘Create’.

13

After deployment is complete, go to resource groups again. You will see new resource group that you just created.

14

When you open resource group, you will see that all resources that were in original group are created here as well. Best thing is that with resources all settings are transferred as well.

15

I hope you can see benefits of this deployment. Once you create resource group with all resources and settings that work for solution you’re building, you can save this template and use it over and over again. In this example solution isn’t too complicated. We have Azure SQL database (with firewall rules, data masking and some other setting) and geo-replica of this database. Still it takes some time to configure all these setting and it takes about 10 minutes to redeploy everything. Imagine if you created more complex solution with bunch of VNets, VMs, Load balancers etc. It would take you less than 5 minutes to set up re-deployment with template and then wait some time so all resources are created. It would take more time then 10 minutes as in this demo but it would still take far less than in case you would manually create resources one by one and then configuring all settings that are specific for your solution.

 

Article by Mustafa Toroman

I’m System Engineer at Authority Partners. I love to test and explore new technologies. Have over 20 active MS certificates such as MCSA for Windows Server and SQL Server, MCSE Private Cloud, Data Platform, Business Intelliegence and Server Infrastracture. Lately most interested in BI and Azure solutions. MCT since 2012. From 2016 MVP for Microsoft Azure.

Comments are closed.