This is Part 1 of a Blog Post Series:

 

Introduction

If you have ever had to provision and configure a service in Azure (WepApps, VMs, Networks, SQL Instances.. etc..), you know the pain it can bring to do it from the portal and how is difficult to replicate it over and over again.

Powershell Scripts are often the solution to performing repetitive tasks, but even there, scripting has its limitations, because scripts are mostly linear if-then statements that don’t have the strength and capabilities of application code.

This is where Infrastructure as Code (IaC) comes in. IaC—sometimes referred to Software Defined infrastructure (SDI)—is a type of IT setup to automatically manage and provision the technology stack from virtual hardware through the software layers, with greater automation than scripting.

The IAC enabler in Azure and Azure Stack is Azure Resource Manager.

 

What is Azure Resource Manager

Azure Resource Manager (ARM) is the deployment and management layer (API) for Azure. It provides a consistent management layer that enables you to create, update, and delete resources in your Azure subscription. You can use its access control, auditing, and tagging features to secure and organize your resources after deployment.

When you take actions through the portal, PowerShell, Azure CLI, REST APIs, or client SDKs, the Azure Resource Manager API handles your request. Because all requests are handled through the same API, you see consistent results and capabilities in all the different tools.

Azure Resource Manager is:

  • Template-driven – Using templates to deploy all resources.
  • Declarative – You declare the resources you want to have instead of imperative where you need to define how the resource are deployed.
  • Idempotent – You can deploy the template over and over again without affecting the current state of resources already deployed.
  • Multi-service – All Azure services can be deployed using Azure Resource Manager.
  • Extensible – Azure Resource Manager is extensible with more resource providers and thus resources.

Azure Resource Manager use Templates to declare the resources to deploy.

 

What is Azure Resource Template

An Azure Resource Manager (ARM) Template is a JSON file.

You can deploy a resource template using the Azure Portal, PowerShell or Azure CLI, REST APIs, or client SDKs. From an ITPro prospective my suggestion is to use now on the new AzureCLI (Az module in PowerShell Core 6.x) as the existing AzureRM module for PowerShell will no longer receive new cmdlets or features but is still officially maintained and will get bug fixes up through at least December 2020.

The basic JSON schema of an ARM Template has the following elements:

 

 

  • $schema: specify the location of the JSON schema file that describes the version of the template language.
  • contentVersion: specify any value for this element to document significant changes in your template.
  • parameters: specify the values that are provided when deployment is executed to customize resource deployment.
  • variables: specify the values that are used as JSON fragments in the template to simplify template language expressions.
  • resources: specify the resource types that are deployed or updated in a resource group.
  • outputs: specify the values that are returned after deployment.

You have also some limitation related to the size and number of artifacts you can include in your Template:

  • 4MB in size with parameter file of 64KB
  • 256 parameters
  • 256 variables
  • 800 resources (including copy count)
  • 64 output values
  • 24,576 characters in a template expression

You can rid out of some of these limitations using nested templates but for now we are fine with that.

 

Where to start for creating your ARM Templates

To start creating your ARM template you can use your notepad 🙂 but for a better experience my suggestion is

The best thing here is that this environment can be installed in Linux, MacOS or Windows.

When you have your environment ready, you can start creating your Template JSON file but creating a Resource Manager template from scratch is not an easy task, especially if you are new to Azure deployment and you are not familiar with the JSON format. So you have two better options:

 

We will see how to Export the JSON from the Azure Portal in the Part 2 of this Post Series.

Comments are closed.