All posts tagged: Templates

Custom Template Deployment Improvements in Azure Portal

When testing ARM templates, I typically use the custom template deployment option in the Azure Portal. This UI option just got better! This deployment option now supports lists the parameters, variables, and resources used in template in a nice treeview navigation. To start a new deployment, you can click on New -> Template Deployment. This opens up the Custom Deployment blade. Click on Edit Template. In the Edit Template blade, copy/paste your template JSON in the editor. In a few seconds, you will see the treeview built for the template. You can expand each node to see the individual elements within each category. Selecting a specific element within a node navigates to the definition for that selection within the JSON template. You can click Save and then proceed to the deployment by completing the remaining steps in the custom deployment. The second enhancement is the option to pull a quick start template from the Github repository and deploy it! In the Load a quickstart template blade, you can select a template listed in the dropdown. …

Building Azure Resource Manager Templates – Forcing WMF 4.0 when using DSC Extension

This subject won’t really need a post of it’s own but I will do it anyway. In the previous part of this ARM series, I showed how we can use the domain join extension instead of DSC to join a VM to an existing AD domain. This resulted is huge savings in time taken to deploy the entire scenario. When I was talking to my good friend, fellow PowerShell MVP and all-things-Azure guru, Ben Gelens, he was quick to point that the delays when using DSC extension here could be due to the install of WMF 5.0. Indeed! When you use Azure DSC extension, it by default installs latest available version of WMF 5.0 (production preview at the time of this writing) which requires a reboot! Therefore, using DSC extension in ARM templates for down-level OS such as Windows Server 2012 or 2012 R2, there will be delays. But, there is a workaround. We can force DSC extension to use WMF 4.0. Here is how we do that.

Observe line number 19. We use the …

Building Azure Resource Manager Templates – Using Domain Join Extension

The scenario that we used to understand and build ARM templates contained a domain controller VM along with one or more VMs that joined the domain service hosted by the DC VM. To make sure the VMs join the domain, we used PowerShell DSC configuration. One of the biggest quirks, at least what I faced, with DSC extension with ARM templates is that it takes little longer to complete. For example, the complete scenario deployment took almost 48 minutes to deploy. I am not making up that number. Here is the proof. Now, 48 minutes may not sound that worse but imagine deploying tens of VMs that need to join the domain using the DSC configuration as we saw in the earlier example in this series. This is where the new JsonADDomainExtension helps! Instead of using DSC configuration to add VMs to a AD domain, we will now use this VM extension. Within the earlier template that deployed this scenario, we will remove the domainJoin resource definition and replace that with JsonADDomainExtension. Here is how that new …

Building Azure Resource Manager Templates – Putting it all together

In this series so far, we looked at building ARM templates by example. The focus was not really on the resource types or how to use resource definitions. Instead, our focus was on learning the basics of template language. To that extent, we have a scenario that we want to deploy and we are incrementally building the template for it. While building an ARM template for this, we looked at how to use parameters and variables. We looked at using copy object to create multiple instances of a resource type without really writing the resource definition multiple times. We went on to find out how we can define dependencies between different resource types so they are orchestrated in the right order. We looked at how we can decompose the template into purpose-specific external templates and how to link them together. While learning these concepts, we created a template that almost built the scenario we started with. We will now add the remaining VMs based on the environmentType selected by the user. So, based on the VM instance count we need, we …

Building Azure Resource Manager Templates – Using Linked Templates

One of the ARM template authoring best practices is to decompose the JSON template, if applicable, into multiple target-specific templates. Think of this as creating re-usable code. You can leverage the re-usable parts of your code within multiple aspects of your application or the deployment. For linking different external templates within the main template, we need to define the Microsoft.Resources/deployments resource instance. Before we proceed let us look at the scenario for which we are building an ARM template. So far in this series, we have looked at building an ARM template that deploys the following components of this scenario: A storage account A virtual network A public IP address A load balancer Virtual network interfaces for the DC and other VMs based on the environment type. Finally, a VM with DNS and Directory Services running in it. By default, the Azure based IaaS deployments use the Azure DNS. If you have deployed the template that we built in the previous part of this series, you will notice that the virtual network us configured to use Azure DNS. Since we …

Building Azure Resource Manager Templates – Defining Resource Dependencies

We will continue learning about building ARM templates by looking at how we can define dependencies between resources. To recap, here is the scenario we are working on. In the earlier parts of this series, we created the storage account, virtual network, a public IP, a load balancer, and added all inbound NAT rules required for the virtual machine RDP access. If you notice, we have components that depend on others. For example, the inbound NAT rules depend on the load balancer. Similarly, VMs depend on network interfaces which in turn depend on the virtual network. In the absence of dependencies, ARM will attempt to deploy these resources in parallel which may result in errors. So, within the resource template, we need to define these dependencies so that ARM can make decisions about the deployment sequence. There are multiple ways of doing this. Using DependsOn If you have noticed in the earlier parts of this series, we have used DependsOn property within the resource element.

If you look at line number 11, we added DependsOn property …

Building Azure Resource Manager Templates – Using Copy Object

If you are following this series, by now you know how to use parameters and variables in ARM template language. We used that knowledge to create a template that creates storage account and virtual network. Let us revisit the scenario. In this part, we will extend the template to add publicIP, load balancer, and RDP endpoints for the virtual machines. Before we do that, let us review what we need. To achieve what we want in this, we will use copy object in the template. What is Copy Object? In our template, we already have the storage account and virtual network configuration defined. What we now need is a load balancer with a public IP so that we can access this deployment from the Internet. Also, we need the inbound NAT rules for enabling RDP access to the VMs in this deployment. But before we create the RDP rules for each VM, we need to know how many VM instances we are deploying. As shown in the scenario diagram, we need to be able to deploy …

Building Azure Resource Manager Templates – Using Variables

If you have been following this series on ARM templates, in the last part, we started with a sample scenario that we are using to build an ARM template. Here it is again. In the last part, we completed creation of storage account required for backing the OS and data disks for virtual machines in the deployment. The next step in our scenario is to create the virtual network for the VM connectivity. A virtual network and any subnets required must exist before the creation of virtual machines. So, in today’s article, we will see how we can use variables in the ARM template language while incrementally building an ARM template for our scenario and add virtual network. Towards the end, we will review some best practices guidance with regards to using parameters and variables in developing ARM templates. Working with Variables Variables in ARM template language can be used to simplify the template. For example, in our template, we will be using the subnet name at multiple places. There is no point repeating the same …