nesting modules: how deep do you go? #4995
-
I really like the idea of building solution based on bicep modules. Start with a dummy Azure resource then add one or two smart functions and consume this module in another module... But if I add one more function in next layer... and the story goes on. I can see that possibilities grow together with complexity. But are there any good/bad practises, success story or any technical limitations? (like max 10 nested levels) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
There is no technical limitation on the bicep language side. There may be a deployment runtime limitation lingering out there somewhere, but in practice, I have not heard of folks hitting any limits on this. The main best practice to follow is those of any good software project -- keep files small enough to be maintainable and reusable. If we do our jobs right, you shouldn't need to care how deep you go. That's being optimistic though, I'm sure others have more practical advice on this one. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
I have found the layering and nesting of modules to be super useful.
On average I go 3 layers, however I think my maximum is about 6 layers.
One thing I find useful, is to give your Modules meaningful names, since they become deployment names. So you will want to trace them say in the portal (or with PowerShell) as you dig into the layers/deployments. Plus they have to be unique.
I also found that for things like below I want to call them from more than 1 place. I started naming these: x.modulename.bicep
NIC
Public IP
DNS A Record
File Share or Container
PrivateLink
e.g.
As an example I call the public IP x module from all of these.
I also have some templates that just gen…