-
Notifications
You must be signed in to change notification settings - Fork 777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added optional module names as an experimental feature #12600
Conversation
Test this change out locally with the following install scripts (Action run 7069477119) VSCode
Azure CLI
|
[DataRow("hello", "hello")] | ||
[DataRow("this______has_________fifty_____________characters", "this______has_________fifty_____________characters")] | ||
[DataRow("this______has_________fifty_one__________characters", "this______has_________fifty_one__________character")] | ||
[DataRow("module_symbolic_name_with_a_super_long_name_that_has_seventy_seven_characters", "module_symbolic_name_with_a_super_long_name_that_h")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D
fdb36cc
to
776b94c
Compare
Test Results 143 files + 11 143 suites +11 5h 49m 2s ⏱️ + 1h 15m 4s For more details on these failures, see this check. Results for commit 776b94c. ± Comparison against base commit edf1324. ♻️ This comment has been updated with latest results. |
Overview
Currently, module names are a required property on
module
declarations. Modules are compiled to nested deployments in the JSON and the name expression is transpiled as-is. With deeply-nested module hierarchies it is very easy to create module names that conflict in grandchild deployments, which causes difficult to diagnose failures at deploy time. This partially fixes #3897.I'm introducing an experimental feature that once enabled, makes the
name
property inmodule
declarations optional. There is no change in behavior if the feature is disabled.With the feature enabled and
name
omitted in amodule
, we generate the following name expression in the JSON:[format('<symbolic name prefix>-{0}-{1}', copyIndex(), uniqueString('<symbolic name>', deployment().name))]
[format('<symbolic name prefix>-{0}', uniqueString('<symbolic name>', deployment().name))]
above represents the full symbolic name of the enclosing
module
declaration. is a substring of that starts at index 0 and takes as many characters as possible to fit within a deployment name.Considerations
uniqueString()
function always returns 13 characterscopyIndex()
serialized to a string is always 3 characters since the max value is 800. While this approach leaves up to 2 characters unused in module loops with 1 or 2-digit iteration counts, it makes the symbolic name prefix consistent, improving readability in the portal.Bicep authors should not take a dependency on the algorithm used to calculate the name. We reserve the right to change it at any time in the future without notice.
We will add a linter for module names in the future, but it is out of scope of this PR.
Portal experience
Module loop
main.bicep
mod.bicep
Azure Portal (count = 500)

Module nesting
main.bicep
mod.bicep
mod2.bicep
Azure Portal (count = 500)

Microsoft Reviewers: Open in CodeFlow