If we have the Vnet already created and we need to add NSG and UDR to it can we do it using a new main.bicep file #3752
-
If we have the Vnet already created and we need to add NSG and UDR to it can we do it using a new main.bicep file and can it reference the already created resources using existing while not using the same main.bicep file that was used to create vnets |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
You can call/name your bicep files anything that is useful, they do not have to be called main.bicep if you follow a folder naming structure for different resource types, it's simple enough to use a main.bicep as the entry point to deploy those resource types, however it's just a simple convention, not a requirement. I would recommend to maintain the configuration for your VNET/Subnets in a single place and then also only deploy it in a single place. An ideal place for that VNET//Subnet configuration is in a Parameter file that you use as part of your deployment and is also checked into source control. When you need to either add new subnets or modify NSG's or Route tables on the VNET, simply update the parameter file and then redeploy the VNET, which will also include ALL subnet information. So long as you don't make manual changes to your VNET/Subnet then by following this pattern you will always have a single source of truth to define the configuration, you can roll back to previous configurations via source control (if that was ever required) and you can view change history of the Parameter File over time. If you have different Environments e.g. resource groups, then you will have different Parameter files that represent/reflect those VNET and other configurations. So in that way you can maintain a different set of NSG/RT subnets settings in different files across different VNETS in different resource groups etc. If you have any more specific examples, please feel free to share. |
Beta Was this translation helpful? Give feedback.
-
Answered |
Beta Was this translation helpful? Give feedback.
-
Answered by @brwilkinson |
Beta Was this translation helpful? Give feedback.
Answered