Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

Implementing Azure Resource Manager Templates

.

Now that you have a good understanding of Azure Resource Manager, you are ready to learn how to implement and deploy Azure Resource Manager templates. This step demonstrates how to implement Azure Resource Manager templates using a variety of tools.

Deploying Templates from the Azure Portal

Deploying templates from Marketplace:

From the Azure Portal, you can deploy using a template from the Marketplace:

  1. Select New from the portal, then the type of resource you wish to deploy, and then the version of the resource.
  2. Set the properties and deploy.
  3. Add more resources by using the Add command on the resource group blade.

Deploying Custom Templates:

From the portal, you can also deploy a custom template that defines the infrastructure for your solution.

  1. After your template is created, select New from the portal and search for Template Deployment
  2. Select it from the available resources.
  3. After launching template deployment, open a blank template and in the editor, add the JSON syntax that defines the resources you wish to deploy.
  4. Select Save.

Deploying Azure Quickstart Templates:

You can also select a template contributed by the community from the Azure quickstart templates.

  1. To deploy resources from a template already saved to your account, browse your saved templates.
  2. Select the one you wish to work on, and deploy it:
NOTE: If you have new ideas or templates that you created and would like to share to open source, submit a pull request on GitHub to the Microsoft Repo.

Deploying Templates from the Azure CLI:

Use the following commands to quickly create a resource group, and deploy a template to that resource group from the CLI if both the template and parameter files are local:
azure group create -n examplegroup -l "West US"

**azure group deployment create -f

c:MyTemplatesexample.json -e

c:MyTemplatesexample.params.json -g examplegroup -n exampledeployment
When deploying your resources, specify that the deployment is either an incremental update or a complete update. By default, Azure Resource Manager handles deployments as incremental updates to the resource group.
With the incremental deployment, Resource Manager:
  • Leaves unchanged resources that exist in the resource group but are not specified in the template.
  • Adds resources that are specified in the template but do not exist in the resource group.
  • Does not reprovision resources that exist in the resource group in the same condition defined in the template.
  • Reprovisions existing resources that have updated settings in the template.
With the complete deployment, Resource Manager:
  • Deletes resources that exist in the resource group but are not specified in the template.
  • Adds resources that are specified in the template but do not exist in the resource group.
  • Does not reprovision resources that exist in the resource group in the same condition defined in the template.
  • Reprovisions existing resources that have updated settings in the template.

Deploying Templates with PowerShell:

The following commands create a resource group and deploy a template to that resource group. The template file and parameter file are both local files:
New-AzureRmResourceGroup -Name ExampleResourceGroup -Location "West US"

New-AzureRmResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName ExampleResourceGroup -TemplateFile

c:MyTemplatesexample.json -TemplateParameterFile

c:MyTemplatesexample.params.json

NOTE: There are more options available to you for specifying the resources to deploy. For more options on how to specify the resources to deploy with Azure PowerShell, see Deploy resources with Resource Manager templates and Azure PowerShell.

Deploying Templates with Rest API:

After setting common parameters and headers, validate your deployment by running a validate operation, providing the parameters exactly as you would when executing a deployment.
Next, create a deployment by providing your subscription ID, the name of the resource group, the name of the deployment, and a link to your template. The mode in the following request method is set to Incremental. To run a complete deployment, remember to set the mode to Complete.
PUT https://management.azure.com/subscriptions/<YourSubscriptionId>/resourcegroups/<YourResourceGroupName>/providers/Microsoft.Resources/deployments/<YourDeploymentName>?api-version=2015-01-01

<common headers>

{

"properties": {

"templateLink": {

"uri": "http://mystorageaccount.blob.core.windows.net/templates/template.json",

"contentVersion": "1.0.0.0",

},

"mode": "Incremental",

"parametersLink": {

"uri": "http://mystorageaccount.blob.core.windows.net/templates/parameters.json",

"contentVersion": "1.0.0.0",

}

}

}

GitHub Resource Manager QuickStart Templates

You can leverage GitHub as another resource to help build and deploy solutions on Azure. This repo contains all currently available Azure Resource Manager templates contributed by the community. There is a searchable template index, contribution guide, template best practices, and usage Git tutorial.

Azure Resource Manager Template Visualiser Tool

To map your existing Azure Resource Manager resources visually, you can use the Azure Resource Manager Template Visualiser Tool, an open-source tool that allows you to visualise, customise, and edit your templates from a UI rather than via script.
  1. From the Azure portal, select Resource Groups.
  2. Select the resource group name that you want to export.
  3. Select Export template.

    Exporting Azure Resource Manager Template graphical representation

    You should see a JSON template from the Resource Group.

    JSON template graphical representation

  4. Click Save to file and provide a filename: filename.JSON
  5. Visit the Azure Resource Manager visualiser and import the JSON template to visualise it:

Join the discussion

In the last two steps you’ve learned about the structure of Azure Resource Manager Templates and how to implement and deploy ARM templates. Use the structure provided in the previous section to write an ARM template that you can deploy in your environment. Share your ARM template with the group.
Use the Discussion section below and let us know your thoughts. Try to respond to at least one other post and once you’re happy with your contribution, click the Mark as complete button to move on to the next step.
This article is from the free online

Microsoft Future Ready: DevOps Development, Implementation and Azure Automation

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now