Azure ARM Template : Create Resource Group

BlindSniper picture BlindSniper · Dec 6, 2017 · Viewed 7.9k times · Source

We are new to ARM (Azure Resource Manager) templates. While working on a template, I observed that we have to supply a resource group when deploying our template. Is it is possible to create a resource group through a template like other resources?

Answer

Kasun Kodagoda picture Kasun Kodagoda · Aug 6, 2018

Now you can create a resource group using ARM templates. You can use the following template

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "rgLocation": {
      "type": "string",
      "defaultValue": "Southeast Asia"
    },
    "rgName": {
      "type": "string",
      "defaultValue": "myResourceGroup"
    }
  },
  "variables": {},
  "resources": [
    {
      "type": "Microsoft.Resources/resourceGroups",
      "apiVersion": "2018-05-01",
      "location": "[parameters('rgLocation')]",
      "name": "[parameters('rgName')]"
    }
  ],
  "outputs": {}
}

You can run this using the Azure CLI. But you have to have the latest CLI version installed. I have version 2.0.43 installed. This includes subscription level deployments using the az deployment command.

To execute this run the following command.

az deployment create --name <deployment_name> --location <resource_location> --template-file .\azuredeploy.json