Let’s begin our series simple. Just grab a template. No more, no less.

Start!

Where to get a template?

The guys at Microsoft documented a few ways to get started with templates. Below, we will discuss 2 ways to get ready to use templates.

Search the Azure Quickstart Templates library

As a first option, you can search the “Azure Quickstart Templates” website for ready to deploy templates. These are great if you have an already existing solution you want to deploy.

Whut? You want to create an Azure VM that automatically takes the role of Domain Controller in a new forest? Here you go!

Export a template containing existing resources

Secondly, Microsoft gives us some options to export existing infrastructure.

  • Deployment based
  • Resource group based

1. Export the actual template used for deployment

The exported template includes all the parameters and variables exactly as they appeared in the original template.

When you deploy a resource to Azure, a deployment record is documented. After provisioning a resource, you will see a history of all items you successfully deployed before.

  • Go to Resource groups, and select your resource group of choice.
  • Click Deployments.
  • Select the deployment you need.
  • Click View template.


Let’s view that template!

The Download button will generate a .zip file containing several files including a template.json and a parameters.json file. Also, you will see some deployment scripts (PowerShell, Ruby, Azure CLI).

  1. Template – The template that defines the infrastructure for your solution. When you created the storage account through the portal, Resource Manager used a template to deploy it and saved that template for future reference.
  2. Parameters – A parameter file that you can use to pass in values during deployment. It contains the values that you provided during the first deployment. You can change any of these values when you redeploy the template.

DO IT YOURSELF:

  • Create a new test resource group.
  • Then, deploy a VM.
  • Finally, export the .zip file containing the template

2. Export a generated template that represents the current state of the resource group

But maybe you created a bunch of resources and adjusted several parameters. This time an initial deployment template will not be enough.

I hear you. Enter Resource Group exports.

A few things to keep in mind, however.

  • You cannot export a template containing more than 200 resources.
  • The created template is intended as a snapshot of the resource group, which you can use to redeploy to the same resource group.
  • There is more hardcoded information contained in the generated template. Fewer options are available in the parameters file.
  • More work to adjust options.

Are you still in your resource group blade?

  • Go to Resource groups, and select your resource group of choice.
  • This time, select Automation script.
  • Next, click Download.


DO IT YOURSELF:

  • Create a new test resource group.
  • Then, deploy 2 virtual machines.
  • Make some adjustments.
  • Finally, export the .zip file containing the automation script template.

Next time we will have a look at adjusting and deploying some of our templates. A bit of a deeper dive in the structure of JSON.