Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure ARM Template : Create Resource Group

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?

like image 337
BlindSniper Avatar asked Dec 06 '17 09:12

BlindSniper


Video Answer


2 Answers

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

like image 138
Kasun Kodagoda Avatar answered Sep 28 '22 11:09

Kasun Kodagoda


It is now published in the microsoft docs,

az deployment create \
  -n demoEmptyRG \
  -l southcentralus \
  --template-uri https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/azure-resource-manager/emptyRG.json \
  --parameters rgName=demoRG rgLocation=northcentralus
like image 20
Sajeetharan Avatar answered Sep 28 '22 13:09

Sajeetharan