Paolo
Paolo

Reputation: 25989

Validate that subnet is within vnet in ARM template

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.

Upvotes: 0

Views: 753

Answers (1)

4c74356b41
4c74356b41

Reputation: 72151

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

Upvotes: 1

Related Questions