Validate Bicep config during CI/CD with Azure DevOps
Bicep scripts are ideally part of the source code and can also be used as such in the build process of the application.
This allows us to perform potential bugs in bicep scripts and modules during the build, well before the script actually runs and generates Azure resources. This increases quality and reduces error rates.
Bicep build to validate
Conveniently, validation is already built into Bicep and occurs during the build command.
➡ az bicep build --file ./.bicep/main.bicep
C:\source\ba\demo\bicep\main.bicep(8,7) : Warning no-unused-params: Parameter "storageName" is declared but never used.
C:\source\ba\demo\bicep\main.bicep(57,38) : Error BCP052: The type "outputs" does not contain property "planId".
Azure DevOps Pipeline Task
The Azure CLI can now be easily used for example in Azure DevOps to validate via the build command.
- script: az bicep build --file ./.bicep/main.bicep
displayName: Bicep build