This repository hosts our library of re-useable Bicep modules.
- 'UseExisting' pattern
- Include resource in outputs (workaround until this feature is released: https://github.com/Azure/bicep/issues/2245)
- The
bicepconfig.jsonfiles configures the linting rules for all templates in this repository - Use the
#disable-next-linedirective to ignore any invalid linter errors (e.g. errors with the built-in type validation) - Use camelCase for variable, parameter and output names
- Use snake_case for resource references
- Avoid returning secrets as output parameters
- Use built-in ARM functions if available (e.g. getSecrets)
- Store the required secret in Key Vault and return its
secretUriWithVersion
Additional advice can be found here: https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/best-practices
This repository includes an automated build process that performs the following tasks:
- Ensures all Bicep files pass the configured linting rules
- Runs the Pester-based integration tests used to validate the templates
- Optionally publishes the Bicep templates to a private Bicep registry (i.e. an Azure Container Registry)
The build can be run locally by executing the build.ps1 script.
-
Clone the repo.
-
Create and checkout a new feature branch.
-
Run the
build.ps1script.- This will validate you have the correct versions of the Bicep CLI and Bicep Registry Module (BRM) tooling.
- If you do not have the correct version of the Bicep CLI, you will need to manually update to the correct version.
-
Create a new folder for the module in the
modulesfolder- If it is a general purpose module, the module should go under the
generalsubfolder. - If it is an opinionated module, the module should go under the
opinionssubfolder.
- If it is a general purpose module, the module should go under the
-
In the terminal, set the working directory to the new module folder and run
brm generate- This will scaffold the new files required for the module
- The file structure will be:
testmain.test.bicepmain.test.json
main.bicepmain.jsonmetadata.jsonREADME.mdversion.json
-
Fill in the properties in the
metadata.jsonfile. -
Add a version (in
major.minorformat) in theversion.jsonfile. Initial version should be1.0unless there a strong reason to set it otherwise. -
Add the parameters/variables/resources/outputs to the
main.bicepfile.- Note: you can reference other modules using relative paths.
- Ensure that all parameters and outputs have description attributes.
-
Add tests to the
main.test.bicepfile- The resources in this file are expected to be deployed successfully as part of running the test suite.
- Instantiate the module with as many combinations of parameters as are necessary to test the module's functionality.
-
Run the
build.ps1script- This will compile the ARM templates from the Bicep files and validate the files.
- If the build shows any errors, make any necessary changes and repeat.
-
The
README.mdwill be partially auto-generated based on themain.bicepandmetadata.jsonfiles.- Fill in the
DescriptionandExamplessections of the README manually.
- Fill in the
-
Commit the changes and push up the branch.
-
Open a pull request with the changes.