Azure ARM Template Guide

Follow

Azure ARM Template Guide

 ARM templates allow you to provision common infrastructure across your Azure Subscriptions. With Kion, you can apply ARM templates automatically across your entire Azure presence, even across Azure Tenants.

Creating an ARM template

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

ClosedSample ARM template

                
{
                  
    "$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."  
            }  
        }  
    ]  
}  
            

To create an ARM template:

  1. In Kion, navigate to Cloud Management > Azure ARM Templates.
  2. Click Create Azure ARM Template.
  3. Enter a name for your ARM template. This is what the template will be called within Kion.
  4. (Optional) Enter a description for your ARM template.
  5. Enter 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 to the same resource group.
    • If the resource group already exists in the subscription where this template is applied, it will attempt to use that resource group for deployment.
  6. Select the region where the resource group should be placed.
  7. Select the deployment mode for the ARM template.
  • In Incremental mode, the template updates resources that exist within the resource group or inserts new ones, but it will not delete anything.
  • In Complete mode, the template attempts 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 use the sample ARM template above to deploy a virtual network locked with a resource lock into a subscription.
  • If your ARM template has parameters, enter them in the Parameters section, or click Pre-fill Parameters to pre-fill the values. The parameters should be in the following format:
    {
                      
    	"Display Name":  {  
    		"value":  "Cloudtamer VNET"  
    	}  
    }       
  • Select at least one user to have ownership over this ARM template.
  • Click Create Template.
  • Applying an ARM template to a Cloud Rule

    To apply ARM templates to your resources, add them to a cloud rule.

    To add an ARM template to a cloud rule:

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

    Choosing the order in which ARM templates deploy

    Kion deploys 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 multiple cloud rules.

    To change the deployment order of ARM templates on a cloud rule:

    1. Go to Cloud Management > Cloud Rules.
    2. Click the ellipsis menu on a cloud rule, and select Edit.
    3. Click and drag the handle on a selected ARM template to move it in the ARM template deployment order.

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

    Removing an ARM template from a Cloud Rule

    When you remove an ARM template from a cloud rule, the change is applied across all subscriptions where the cloud rule is applied and Kion deletes the resource group created for the ARM template deployment.

    To remove an ARM template from a cloud rule:

    1. Go to Cloud Management > Cloud Rules.
    2. Click the ellipsis menu on a Cloud Rule, and select Edit.
    3. Click the Azure ARM Templates dropdown menu and deselect the ARM templates you want to remove.
    4. Click Update Cloud Rule

    Deleting an ARM template

    When you delete an ARM template, it is removed from any Azure subscriptions where it was applied through a cloud rule.

    To delete an ARM template:

    1. Go to Cloud Management > Azure ARM Templates.
    2. Click the ellipsis menu on the ARM template you want to delete, and select Delete.