Forum Discussion

vigneshkrcegmailcom's avatar
vigneshkrcegmailcom
Brass Contributor
Nov 11, 2020
Solved

ARM Template To create Multiple NSG's associate with existing Subnet

Hi All,   I am trying to create Multiple NSG with multiple rules associate with subnets. Can anyone give me the Template file which is used as single Template file for Multiple NSG. Attached is th...
  • StefanIvemo's avatar
    Nov 17, 2020

    vigneshkrcegmailcom 

    Hi!

     

    I've put together a template for you that solves your problem using copy loops for both the NSGs and the subnet association. You can find it here: https://gist.github.com/StefanIvemo/31cda6faa214824b2049a1e98f0e279b

     

    I've created a parameter called NSGs of the type array in the template. Take a look at the example parameter file and adjust it to your needs. All you have to do is add/remove objects to the array and fill in NSGName, SubnetName and your SecurityRules. 

     

    The template will first deploy all the NSGs and then do a nested deployment to do the subnet association.

     

    Good luck with your deployment!

     

Resources