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?
5 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

- 98,240
- 88
- 296
- 433

- 3,956
- 5
- 31
- 54
-
This doesn't work for me. I'm getting the foollowing (UUID redacted) ```{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"NotFound","message":"{\r\n \"message\": \"No HTTP resource was found that matches the request URI 'https://management.azure.com/subscriptions/
/resourcegroups/MyResourceGroup/providers/Microsoft.Resources/resourceGroups/myResourceGroup?api-version=2018-05-01'.\"\r\n}"}]}``` – lorenzo Apr 15 '20 at 20:18 -
This solution is wrong and not working, it is using wrong schema, the solution bellow is right. – Jan Jan 28 '21 at 14:51
-
1The `az` CLI gives a warning stating that [`deployment create`](https://learn.microsoft.com/en-us/cli/azure/deployment?view=azure-cli-latest#az_deployment_create) has been deprecated and will be removed in a future release. [`deployment sub create`](https://learn.microsoft.com/en-us/cli/azure/deployment/sub?view=azure-cli-latest#az_deployment_sub_create) should be used instead – tuomastik Feb 01 '21 at 10:21
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

- 216,225
- 63
- 350
- 396
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": {}
}

- 437
- 4
- 15
-
This worked for me! If you are using Azure CLI, remember to run it using `az deployment sub create`, so you will create new resource group inside your subscription. – Wojciech X Oct 17 '22 at 07:29
Is it is possible to create resource group through template like other resources ??
For now, we can't use arm template to create Azure resource group.

- 13,710
- 2
- 16
- 25
-
1
-
By default, we will use Azure powershell or Azure CLI to create a new deployment with json file, here is the powershell command, like this: `New-AzureRmResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName ExampleResourceGroup -TemplateFile c:\Users\Desktop\jasontest2.json` , in this script, we have specify the resource group. – Jason Ye Dec 06 '17 at 09:51
the subscriptionDeploymentTemplate.json schema must be used.
-
1try including a relevant code block or steps to help out the original poster. – Jay Sep 21 '20 at 17:12