Azure ARM Template : Create Resource Group
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
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
The accepted solution is wrong. Resource groups are deployed on the subscription level not on the resource group level. No wonder it is not working.
Note the $schema difference. it should be subscriptionDeploymentTemplate instead.
{ "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], "variables": {}, "resources": [ { "name": "string", "type": "Microsoft.Resources/resourceGroups", "apiVersion": "2020-10-01", "location": "string", "tags": {}, "properties": { } } ], "outputs": {}}