Skip to content
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

Best practices for Bicep #446

Closed
slavizh opened this issue Sep 4, 2020 · 10 comments
Closed

Best practices for Bicep #446

slavizh opened this issue Sep 4, 2020 · 10 comments
Labels
documentation Improvements or additions to documentation Needs: Author Feedback Awaiting feedback from the author of the issue revisit

Comments

@slavizh
Copy link
Contributor

slavizh commented Sep 4, 2020

Is your feature request related to a problem? Please describe.
As I see discussions like #410 may be it is good to setup some best practices for writing bicep code in advance and not be the wild west like in ARM Templates. For example camelCase usage for parameters and variables, etc. Of course anyone will be free to adopt or not these. And of course they should not be too restrictive so if you want to adopt them you do not have to make big effort.

@slavizh slavizh added the enhancement New feature or request label Sep 4, 2020
@ghost ghost added the Needs: Triage 🔍 label Sep 4, 2020
@alex-frankel
Copy link
Collaborator

wondering if we can combine this with #443

@majastrz
Copy link
Member

majastrz commented Sep 5, 2020

Some of the formatting best practices can be captured in a formatter as well (#220).

@alex-frankel alex-frankel added documentation Improvements or additions to documentation and removed Needs: Triage 🔍 enhancement New feature or request labels Oct 7, 2020
@alex-frankel
Copy link
Collaborator

Related to #441

@alex-frankel alex-frankel added this to the v0.3 milestone Oct 14, 2020
@shenglol
Copy link
Contributor

I think this is also related to #428. Things like always using camelCase for identifier names and removing unused parameters and variables can be linter rules and can be auto fixed.

@JustinGrote
Copy link

To throw in my thought, it should be PascalCase for parameters and camelCase for variables, both to easily distinguish between the two, and because using tools like new-azvmdeployment make dynamic parameters based on the parameters, so they will look more "powershell-like" if they are PascalCase.

@alex-frankel
Copy link
Collaborator

We have this doc, which may or may not go far enough: https://github.com/Azure/bicep/blob/main/docs/arm2bicep.md

@slavizh / @JustinGrote - can you take a look and let me know what is missing?

@JustinGrote
Copy link

@alex-frankel this request is less around "how to convert from arm to bicep" and more about best practices for templates that are typically open to interpretation. Examples:

  1. Standard naming conventions for parameters, module parameters, variables, and functions so there is a "visual contract" so people who work or consume multiple bicep templates don't come across the same parameter named MYPARAMETER, my_parameter, MyParameter, my-parameter, etc. in different modules.
  2. When newline syntax gets relaxed, general guidelines about how to structure or indent functions and expressions across multiple lines
  3. Naming of modules and how to structure modules in directories or files within a repository.

For example, the current document just recommends "use consistent casing", it should probably be expounded into a default recommendation, but of course people can do whatever they want, it would just be a recommendation that would probably become a de-facto standard.

There is probably a minimal amount of this stuff to cover since Bicep mostly takes the 'one and only one right way to do it' approach similar to Python and unlike Powershell :)

@stan-sz
Copy link
Contributor

stan-sz commented Mar 9, 2021

Can the scope of this work also include best practices for particular resource types, like storageAccounts with https and tls1.2 enabled-by-default (the former is on-by-default with 2019-04-01, the latter is still at 1.0)?

@slavizh
Copy link
Contributor Author

slavizh commented Mar 9, 2021

The intent of the work item is best practices for writing Bicep code so the code when written by different people have some common similarity. The above is proposal for best practices for deploying Azure services so it is not related to Bicep. The above is probably for documents like CAF.

@alex-frankel
Copy link
Collaborator

We now have this best practices doc - can folks take a look? Any enhancements/changes can be provided through the feedback channels provide in ms docs. Going to close this thread in the meantime, but feel free to continue the discussion here:

@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2023
@StephenWeatherford StephenWeatherford added Needs: Author Feedback Awaiting feedback from the author of the issue and removed awaiting response labels Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation Needs: Author Feedback Awaiting feedback from the author of the issue revisit
Projects
None yet
Development

No branches or pull requests

7 participants