Azure ARM Template Guide

Follow

 ARM templates allow you to provision common infrastructure across your Azure Subscriptions. With cloudtamer.io, you can apply ARM templates automatically across your entire Azure presence, even across Azure Tenants. Let's see how that works.

Creating an ARM template

In this example, we'll be using this sample ARM template which deploys a virtual network locked with a resource lock into a subscription:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "variables": {
        "vnetName": "cloudtamerVnet"
    },
	"parameters": {
		"Display Name": {
			"type": "string",
			"metadata": {
				"description": "The human-readable name of the VNET in Azure"
			}
		}
	}
    "resources": [
        {
            "name": "[variables('vnetName')]",
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2018-08-01",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "[parameters('Display Name')]"
            },
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "10.0.0.0/16"
                    ]
                },
                "subnets": [
                    {
                        "name": "Subnet-1",
                        "properties": {
                            "addressPrefix": "10.0.0.0/24"
                        }
                    }
                ]
            }
        },
        {
            "type": "Microsoft.Network/virtualNetworks/providers/locks",
            "apiVersion": "2017-04-01",
            "name": "[concat(variables('vnetName'), '/Microsoft.Authorization/vnetLock')]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
            ],
            "properties": {
                "level": "CanNotDelete",
                "notes": "Do not delete the vnet."
            }
        }
    ]
}

In order to create the ARM template, do the following:

  1. Navigate to Cloud Management in the sidebar and select Azure ARM Templates.
  2. Either click Create Azure ARM Template or the + button to create a new Azure ARM Template.
  3. On the ARM template create screen, do the following:
    • Write in a name for your ARM template. This is just so you can find it in cloudtamer.io
    • Optionally, write a description for your ARM template so you can keep track of what the ARM template does.
    • Write in the name of the resource group where this ARM template should be applied. Avoid re-using names if possible. You can apply multiple ARM templates on the same resource group.
      • Note: if the resource group already exists in the subscription where this template is applied, it will attempt to use that resource group for deployment.
    • Select the region where the resource group should be placed.
    • Select the deployment mode for the ARM template. In Incremental mode, the ARM template will update resources that exist within the resource group or insert new ones but it will not delete anything. In Complete mode, ARM templates will attempt to make the resource group's resources match what's in the template, deleting resources that are not mentioned. Use Complete mode with caution!
    • Paste in the Azure ARM template you want to be deployed. For example, you could deploy a virtual network into your resource group with this template:
{ 
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "variables": {
        "vnetName": "cloudtamerVnet"
    },
    "resources": [
        {
            "name": "[variables('vnetName')]",
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2018-08-01",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "cloudtamerVnet"
            },
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "10.0.0.0/16"
                    ]
                },
                "subnets": [
                    {
                        "name": "Subnet-1",
                        "properties": {
                            "addressPrefix": "10.0.0.0/24"
                        }
                    }
                ]
            }
        },
        {
            "type": "Microsoft.Network/virtualNetworks/providers/locks",
            "apiVersion": "2017-04-01",
            "name": "[concat(variables('vnetName'), '/Microsoft.Authorization/vnetLock')]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
            ],
            "properties": {
                "level": "CanNotDelete",
                "notes": "Do not delete the vnet."
            }
        }
    ]
}
  • If your ARM template has parameters, you may write them in the Parameters section here, or click Pre-fill Parameters to pre-fill the values. The parameters should be in the following format:
{
	"Display Name": {
		"value": "Cloudtamer VNET"
	}
}
  • Select the users and user groups who should have ownership over this ARM template.
  • Click "Create Template" to add the ARM template to cloudtamer.io.

Here is what the ARM template create form looks like:Create-Azure-ARM-Template-cloudtamer-io__1_.png

Editing an ARM template

To edit an existing ARM template, do the following:

  1. Go to Cloud Management > Azure ARM templates. You can move through the pages of the list with the > button, and you can apply filters with the Filter button.
  2. Click the ellipsis menu on the ARM template you want to edit.
  3. Select Edit.
  4. Make any changes to fields you want to make.
  5. Click Update Template at the bottom of the page.

Deleting an ARM template

When you delete an ARM template, it will be removed from any Azure Subscriptions where it was applied through a cloud rule. Here is how you remove an ARM template:

  1. Go to Cloud Management > Azure ARM templates. You can move through the pages of the list with the > button, and you can apply filters with the Filter button.
  2. Click the ellipsis menu on the ARM template you want to delete
  3. Click Delete.

Applying an ARM template to a Cloud Rule

To apply ARM templates to your resources, you'll need to add them to a Cloud Rule. To add one to a Cloud Rule, do the following:

  1. Go to Cloud Management > Cloud Rules.
  2. Click the ellipsis menu on a Cloud Rule and select Edit.
  3. Scroll down to the Azure Settings section.
  4. Click the Azure ARM Templates dropdown menu and select the ARM templates you want to deploy with this Cloud Rule.
  5. Click Update Cloud Rule.

A cloud rule with ARM templates applied:

Edit-Cloud-Rule-cloudtamer-io.png

Choosing the order in which ARM templates deploy

cloudtamer.io will deploy ARM templates in order, waiting for the previous deployment to complete before deploying the next one. You may choose the order in which ARM templates deploy for a single cloud rule, but the order is not guaranteed across cloud rules.

To change the deployment order, do the following while you are editing the Cloud Rule:

  1. Scroll down to the Azure Settings section
  2. Click and drag the handle on a selected ARM template to move it in the ARM template order

When you save the cloud rule, the ARM template order will be saved as well. On future deployments, the ARM templates will be deployed in the order specified.

Removing an ARM template from a Cloud Rule

The process for removing ARM templates from cloud rules is similar to that of adding them. When you remove an ARM template from a cloud rule, the change will be applied across all subscriptions where the cloud rule is applied. This means that cloudtamer.io will delete the resource group created for the ARM template deployment.

To remove the ARM template from the Cloud Rule, do the following:

  1. Go to Cloud Management > Cloud Rules
  2. Click the ellipsis menu on a Cloud Rule and select Edit
  3. Scroll down to the Azure Settings section
  4. Click the Azure ARM Templates dropdown menu and unselect the ARM templates you want to remove from this Cloud Rule
  5. Click Update Cloud Rule
Was this article helpful?
0 out of 0 found this helpful