
close
close
In today’s Ask the Admin, I’ll explain how to use linked Azure Resource Manager (ARM) templates to facilitate complex deployment options.
advertisment
There are several choices when deploying resources in Microsoft Azure, among them the classic service model, PowerShell scripts, or ARM templates. If you follow my Azure articles on the Petri IT Knowledgebase, you’ll have noticed that everything I do related to Azure is based on Azure Resource Manager (ARM), although occasionally I still provide how-to articles for beginners on configuring Azure using the web portal.
In Use Visual Studio to Deploy a Virtual Machine on Petri, I showed you how to work with ARM templates in Visual Studio (VS). And today I’d like to extend that theme and show you how to link child templates to a master deployment template, again with the help of Visual Studio.
The ability to link templates enables administrators and developers to simplify complex Azure deployments using targeted templates for specific purposes. For example, rather than putting all the code to deploy resources for a complex app in one template, you can call child templates, based on decisions made at deployment time, to deploy the app from a set of smaller building blocks.
This process is known as decomposition. Developers often use it to separate an application into code classes, enabling easier testing, reuse and deployment.
advertisment
Azure templates can be linked to a ‘master’ template, creating a hierarchy of a master and one or more child templates. Child templates are represented in the master as resources and can be added like any other Azure resource.
Create a new project in Visual Studio to create an Azure Resource Group (Image Credit: Russell Smith)
Add a Nested Deployment resource (Image Credit: Russell Smith)
In the main script pane, the code for the new resource will be highlighted, and two more files will appear in Solution Explorer: one for the JSON code (linkedtemplate1.json) and a second (linkedtemplate1.parameters.json) for parameters. Now let’s add two resources to the linked template.
Add a Web App resource to the linked template (Image Credit: Russell Smith)
“defaultValue”: ” linkedtemplate1serviceplan”
Add a default value parameter (Image Credit: Russell Smith)
As I mentioned in Use Visual Studio to Deploy a Virtual Machine on Petri, VS 2015 must be launched with an administrator account to deploy resources in Azure. So if you haven’t already done so, start VS as an administrator and open the project we just saved from the Start page.
advertisment
Deploy the resource in Azure (Image Credit: Russell Smith)
Azure can read the master template from your local hard disk, but any linked templates must reside in Azure storage so that they can be read, hence the need for an artifact storage account. The storage account is accessed using a Shared Access Signature (SAS).
Once the deployment has completed successfully, you should see a message: ‘Successfully deployed template…’ in the Output pane. To verify that the App Service Plan and Web App have been deployed, open Cloud Explorer from the View menu and check the list of resources.
Check for a successful Azure deployment (Image Credit: Russell Smith)
In this article, I showed you how to deploy resources from a linked template in Azure. In a future article, I’ll show you how to make conditional decisions in an ARM template.
More from Russell Smith
advertisment
Petri Newsletters
Whether it’s Security or Cloud Computing, we have the know-how for you. Sign up for our newsletters here.
advertisment
More in Cloud Computing
Use Azure ExpressRoute Private Peering & Azure Virtual WAN to Connect Privately to Microsoft 365
Apr 21, 2022 | Flo Fox
Microsoft to Make Changes to Cloud Licensing Restrictions after Customer Complaints
Apr 18, 2022 | Rabia Noureen
Most popular on petri
Log in to save content to your profile.
Article saved!
Access saved content from your profile page. View Saved
Join The Conversation
Create a free account today to participate in forum conversations, comment on posts and more.
Copyright ©2019 BWW Media Group