can we limit the Azure region/location of deployment in ARM createUIdefinition.json?

Viewed 348

Is it possible to allow a deployment of ARM template in only selected regions/locations of Azure. If so how we can achieve it in createUIdefinition.json ARM template?

2 Answers

I found the answer from: https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-resource-manager/managed-applications/create-uidefinition-overview.md

For location, specify the properties for the location control you wish to override. Any properties not overridden are set to their default values. resourceTypes accepts an array of strings containing fully qualified resource type names. The location options are restricted to only regions that support the resource types. allowedValues accepts an array of region strings. Only those regions appear in the dropdown. You can set both allowedValues and resourceTypes. The result is the intersection of both lists. Lastly, the visible property can be used to conditionally or completely disable the location dropdown.

I tested this and it works:

 "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "config": {
      "isWizard": true,
      "basics": {      
        "location": {
          "resourceTypes": [
            "microsoft.insights/components",
            "microsoft.insights/components/CurrentBillingFeatures", 
            "Microsoft.Sql/servers",
            "Microsoft.Web/sites",
            "Microsoft.Web/serverfarms"
          ]
        }
      }
    },

"microsoft.insights/components" is not available in West Central US currently and it was removed from the Location options.

I assume that I understand your question correctly. You want to deployment in a selected region.

Azure Resource Manager templates enable you to deploy and manage these resources as a group, using a JSON description of the resources and their deployment settings. When you create the template you can define the region of the resources with the "location" property. The code just like this:

{
      "condition": "<true-to-deploy-this-resource>",
      "apiVersion": "<api-version-of-resource>",
      "type": "<resource-provider-namespace/resource-type-name>",
      "name": "<name-of-the-resource>",
      "location": "<location-of-resource>",
      ...
}

If you want to create all the resources in the template in one selected region, you can set the "location" all with the same value. And then use the CLI command az group deployment create or PowerShell command New-AzureRmDeployment to deploy the template to Azure.

Related