0
votes

When we deploy a Custom template in Azure then few parameters like Resource Group and Region are automatically popped up in the Azure portal (see the attached screenshot). I want to know that how can we customize or restrict the list of Region using ARM templates?

ARM Template Deployment Screenshot

Edit

Modified ARM Template

New parameter Region is added rather than re-using the existing one

1
Could you please describe your issue in detail? Is that you want to know how to implement azure resource can only be deployed to certain regions?Jim Xu
The attached screenshot is for the case when I deployed the empty ARM template. The parameter Region is automatically added which is having all possible values. I want to control this list like if I need to have only "uksouth" and "eastus" in the Region dropdown. Since this parameter region is not controlled by the ARM template then how can I control it? Is there a way to do that? On a side note, I am aware about how to deploy a Azure resource in a particular region.Navlok Mishra
You can define the region value in the parameter :docs.microsoft.com/en-us/azure/azure-resource-manager/templates/…Jim Xu
I tried it and it doesn't help me. It adds up a new parameter in the GUI rather than controlling the existing one which gets added automatically. I have edited the post to include the sample template and the output GUI. Could you please take a look and let me know if I did something different than what you had suggested.Navlok Mishra

1 Answers

0
votes

The first "region" dropdown is for the resourceGroup's location - it's required when creating a new one, disabled when using an existing one. For a custom template, you cannot customize or remove that control unless you provide your own ui definition file.

That said, there's also nothing that requires you to use the value from that control in your deployment. If you want to use that value you'd reference it using resourceGroup().location in your template. That would allow you to remove the "duplicate" but also requires that the resources are deployed to the same region as the resourceGroup.

For your own "region" control, you can use the allowedValues property on the parameter in the template and that will restrict the items in the list to what you provide - that's the link that Jim provided in the comment above.

If you supply your own ui definition file there are more things you can do to restrict the list, but requires you to write a bit more code. This would be the starting point:

https://docs.microsoft.com/en-us/azure/azure-resource-manager/managed-applications/create-uidefinition-overview

The docs talk about managedApplications, but the ui is a generic construct that you can use for template deployments, here's a generic example:

https://github.com/Azure/azure-quickstart-templates/tree/master/100-marketplace-sample

[edits post comment]

If you want to leverage the "built-in" region control you can customize the list of locations that appear there by setting the config in the createUiDefintion.json file. More on that here:

https://docs.microsoft.com/en-us/azure/azure-resource-manager/managed-applications/create-uidefinition-overview#config