0

I am working on an ARM template for deploying resources in Azure, and I would like to add some validation in the parameters the user can specify.

In my deployment, the user can specify that he wants to deploy the resources in a certain virtual network and in a certain subnet.

Right now, it is possible to specify a subnet which does not exist and the deployment of the resources will launch, only to fail afterwards.

Is there any way to validate that the subnet is indeed within that virtual network, so that the validation occurs straightaway and the deployment does not start in the first place?


In AWS, this can be achieved with the Constraints rule: https://docs.aws.amazon.com/servicecatalog/latest/adminguide/reference-template_constraint_rules.html

Is there an equivalent for ARM templates? I didn't find anything in the docs for ARM.

Paolo
  • 21,270
  • 6
  • 38
  • 69

1 Answers1

1

no, there is nothing like that in the ARM Template syntax, you need to create a script and run it before invoking the template to check that. alternatively you can create a list of possible values and define all the subnets the person can deploy his stuff using the allowedvalues property of a parameter.

https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authoring-templates#parameters

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Thanks, I was hoping I had missed something but doesn't look like it. Seems very limiting... What would a script look like? Is there some sort of preprocessor that can be defined in an ARM template? If so, could you provide an example in your answer? Thanks again. – Paolo Sep 09 '19 at 15:06
  • no, you cant define preprocessor in the template, but you can have a script that tests these values and if they pass - deploys the template. – 4c74356b41 Sep 09 '19 at 15:17
  • The templates are deployed directly in Azure though, from the portal. So looks like there is no solution? – Paolo Sep 09 '19 at 15:19
  • from the portal - well, no easy solution, you can do some sort of hacking, but it wont be pretty, really its easier to make people use custom ways of deploying them – 4c74356b41 Sep 09 '19 at 15:21