ARM Basics

Skip this section if you are already familiar with ARM Templates

This won’t be an introduction to Azure Resource Manager or ARM templates. Instead let’s go through the main parts that are important for creating a new resource.

The main parts of ARM Templates can be broken into resources, outputs, variables, and parameters. Farmer has limited support for parameters and no support for variables, so we will not cover them.

So a generated ARM Template from Farmer will have the following structure.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "outputs": {},
  "parameters": {},
  "resources": []
}

When building a new resource in Farmer you are providing the means for a user of Farmer to generate a new resource type, or configure a new property on an existing resource. These resources are added by Farmer to the resources array you can see above.

When building up a resource it will have a schema that looks something like this.

{
  "name": "my-example-resource",
  "type": "Microsoft.ContainerRegistry/registries",
  "apiVersion": "2019-05-01",
  "location": "westeurope",
  "tags": {},
  "sku": {
    "name": "S1"
  },
  "properties": {
    "adminUserEnabled": true,
  },
  "resources": []
}

Your resource you create will have a type of service that it represents. Each service has many versions, represented by a date. Typically your builder will at first focus on adding properties to the properties field to configure a service to be deployed in a certain state.

Where can I find docs on ARM templates schemas themselves?

There are three good sources to learning about specific ARM resources and what parts need to be used in creating an equivalent Farmer resource:

  • Reference Docs: The reference documentation contains details on the schema for every resource and every version e.g. Container Registry reference.
  • Sample Template: The Azure Quickstart Templates github repository contains many examples of real-world ARM templates e.g. Container Registry with Geo Replication sample.
  • Reverse engineer: You can manually create a required resource in Azure, and then use Azure’s export ARM template functionality to create an ARM template. It’s important that you test out the exported template yourself before porting it to Farmer, because Azure sometimes exports invalid templates!