Failing to create resource using subscription level ARM template

Varma 1,495 Reputation points
2025-04-08T06:53:26.98+00:00

I am using following subscription level scope ARM template, but it is failing with following error. I am trying to create Resource group, Key vault and then ACR. but what not sure what is missing.

here is the main deploy file:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-11-01/subscriptionDeploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "resourceGroupName": {
      "type": "string"
    },
    "location": {
      "type": "string"
    },
    "acrName": {
      "type": "string"
    },
    "keyVaultName": {
      "type": "string"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Resources/resourceGroups",
      "apiVersion": "2021-04-01",
      "name": "[parameters('resourceGroupName')]",
      "location": "[parameters('location')]",
      "properties": {}
    },
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2021-04-01",
      "name": "nestedDeployment",
      "resourceGroup": "[parameters('resourceGroupName')]",
      "dependsOn": [
        "[resourceId('Microsoft.Resources/resourceGroups', parameters('resourceGroupName'))]"
      ],
      "properties": {
        "mode": "Incremental",
        "template": {
          "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {
            "acrName": {
              "type": "string"
            },
            "keyVaultName": {
              "type": "string"
            },
            "location": {
              "type": "string"
            }
          },
          "resources": [
            {
              "type": "Microsoft.ContainerRegistry/registries",
              "apiVersion": "2019-05-01",
              "name": "[parameters('acrName')]",
              "location": "[parameters('location')]",
              "sku": {
                "name": "Standard"
              },
              "properties": {}
            },
            {
              "type": "Microsoft.KeyVault/vaults",
              "apiVersion": "2019-09-01",
              "name": "[parameters('keyVaultName')]",
              "location": "[parameters('location')]",
              "properties": {
                "sku": {
                  "family": "A",
                  "name": "standard"
                },
                "tenantId": "[subscription().tenantId]",
                "accessPolicies": [],
                "enabledForDeployment": true,
                "enabledForTemplateDeployment": true,
                "enabledForDiskEncryption": false
              }
            }
          ]
        },
        "parameters": {
          "acrName": {
            "value": "[parameters('acrName')]"
          },
          "keyVaultName": {
            "value": "[parameters('keyVaultName')]"
          },
          "location": {
            "value": "[parameters('location')]"
          }
        }
      }
    }
  ]
}


and below is the param file:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "resourceGroupName": {
      "value": "DRG"
    },
    "location": {
      "value": "eastus"
    },
    "acrName": {
      "value": "myacrshyam12345"
    },
    "keyVaultName": {
      "value": "mykv890"
    }
  }
}

I am seeing following error :

PS I:\ARMTemplates\DevOps\ACR-KV> az deployment sub create --location eastus --template-file azuredeploy.json --parameters "@azuredeploy.parameters.json"

{"code": "InvalidTemplate", "message": "Deployment template validation failed: 'The template resource 'myacrshyam12345' at line '16' and column '5' is not valid: The template function 'RESOURCEGROUP' is not expected at this location. Please see https://aka.ms/arm-functions for usage details.. Please see https://aka.ms/arm-functions for usage details.'.", "additionalInfo": [{"type": "TemplateViolation", "info": {"lineNumber": 16, "linePosition": 5, "path": "properties.template.resources[0]"}}]}

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,349 questions
{count} votes

Accepted answer
  1. Vinod Pittala 1,505 Reputation points Microsoft External Staff
    2025-04-08T10:10:07.02+00:00

    Hello Varma,

    It has been identified that the provided 'Template schema' is currently not supported.

    The schema 'https://schema.management.azure.com/schemas/2019-11-01/subscriptionDeploymentTemplate.json#'

    Please use one of the supported versions instead: '2015-01-01', '2018-05-01', '2019-04-01', or '2019-08-01'. For your convenience, we have added the supported version. Kindly use the API below.

    "$schema": "https://schema.management.azure.com/schemas/2019-08-01/subscriptionDeploymentTemplate.json#",
    

    And also identified that you are trying to create a RG inside another resource group, which is incorrect. Microsoft.Resources/resourceGroups

    For your ease of reference, please use below template

    {
      "$schema": "https://schema.management.azure.com/schemas/2019-08-01/subscriptionDeploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "resourceGroupName": {
          "type": "string"
        },
        "location": {
          "type": "string"
        },
        "acrName": {
          "type": "string"
        },
        "keyVaultName": {
          "type": "string"
        }
      },
      "resources": [
        {
          "type": "Microsoft.Resources/deployments",
          "apiVersion": "2021-04-01",
          "name": "nestedDeployment",
          "resourceGroup": "[parameters('resourceGroupName')]",
          "dependsOn": [],
          "properties": {
            "mode": "Incremental",
            "template": {
              "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
              "contentVersion": "1.0.0.0",
              "parameters": {
                "acrName": {
                  "type": "string"
                },
                "keyVaultName": {
                  "type": "string"
                },
                "location": {
                  "type": "string"
                }
              },
              "resources": [
                {
                  "type": "Microsoft.ContainerRegistry/registries",
                  "apiVersion": "2019-05-01",
                  "name": "[parameters('acrName')]",
                  "location": "[parameters('location')]",
                  "sku": {
                    "name": "Standard"
                  },
                  "properties": {}
                },
                {
                  "type": "Microsoft.KeyVault/vaults",
                  "apiVersion": "2019-09-01",
                  "name": "[parameters('keyVaultName')]",
                  "location": "[parameters('location')]",
                  "properties": {
                    "sku": {
                      "family": "A",
                      "name": "standard"
                    },
                    "tenantId": "[subscription().tenantId]",
                    "accessPolicies": [],
                    "enabledForDeployment": true,
                    "enabledForTemplateDeployment": true,
                    "enabledForDiskEncryption": false
                  }
                }
              ]
            },
            "parameters": {
              "acrName": {
                "value": "[parameters('acrName')]"
              },
              "keyVaultName": {
                "value": "[parameters('keyVaultName')]"
              },
              "location": {
                "value": "[parameters('location')]"
              }
            }
          }
        }
      ]
    }
    
    
    

    Please try and let us know the results. If the provided answer helps your query, please click Upvote it.

    Thanks

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.