Best way to handle constant values? #1601
-
I have a set of (constant) variables for group IDs, app IDs, built-in role definition IDs, etc. that I need to use in various modules for applying RBAC settings. Is there a good way to handle this, as opposed to adding those variables in every single module that will need them? I suppose I could define them at the top-level bicep file and include them as parameters in every child module, but that feels too heavy. I tried creating a module which was nothing but output variable definitions for them, but that generated nested deployments wherever I referenced that module and also didn't allow those output variables to be used in functions like guid(). I guess what I'd like is something like an include file, unless there's already a better way to accomplish this. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
One option would be to concat files together at build time, but that would sacrifice the tooling experience because you would see shared variables/parameters as missing in VS code. Another option would be to write your own preprocessor that injects the parameters at the top or bottom of the file synchronized with some source of truth file. This would allow the tooling to function normally, but would be fragile as changes made to the shared section wouldn't propagate back out. There isn't a good native solution for this problem at this time. #893 is tracking this problem however. |
Beta Was this translation helpful? Give feedback.
-
@JadedATB I added a comment over here that maybe helpful. |
Beta Was this translation helpful? Give feedback.
-
@JadedATB given that we now have loadTextContent() I think that would be the answer here moving forward, at least for now. var config = json(loadTextContent('../bicepconfig.json'))
var item = config.analyzers Notice you get intellisense/property discovery. Let us know if this works for you and I will mark this discussion as answered? |
Beta Was this translation helpful? Give feedback.
@JadedATB given that we now have loadTextContent() I think that would be the answer here moving forward, at least for now.
Notice you get intellisense/property discovery.
Let us know if this works for you and I will mark this discussion as answered?