DEV Community

Cover image for Versioned Bicep templates- Deployment
Kinga
Kinga

Posted on • Edited on

Versioned Bicep templates- Deployment

To take full advantage of versioning implemented in the previous steps, the deploy.yml file needs to be updated to create versioned Template Specs and release annotations. It will allow you to maintain a clear and organized version history of each template deployment.

We will now:

  • create versioned Template Specs
  • create release annotations to provide release insights

Image description

Release annotations are a feature of the cloud-based Azure Pipelines service of Azure DevOps. It requires provisioned resources to be linked to Application Insights

Automated deployment

This sample project generates Template Specs, and to tag them with the version number, update the Pipelines\deploy.yml file using the contents of the following file: Pipelines/deploy.yml.
This new version, instead of overriding the template, detects whether the current version exists and either creates new version, or updates existing one (useful in development environments).

Release annotations

The last task in the Pipelines\deploy.yml file uses the TemplateSpec version to annotate the new release:

    - task: AzurePowerShell@5
      name: Annotations
      inputs:
        azureSubscription: ${{ parameters.serviceConnectionName }}
        azurePowerShellVersion: latestVersion
        ScriptType: 'FilePath'
        ScriptPath: '$(scriptsPath)\CreateReleaseAnnotation.ps1'
        ScriptArguments: 
          -aiResourceId "$(TemplateSpecDeploy.applicationInsightsId)" 
          -releaseName "$(getConfig.templateVer)" 
          -releaseProperties @{"ReleaseDescription"="Rush for IaC";"TriggerBy"="$(Build.RequestedForEmail)" }  
Enter fullscreen mode Exit fullscreen mode

Release annotations

It uses the Application Insights created by the Deploy Template Spec task. If needed, update the script to use add an aiResourceId parameter and provide Id of another Application Insights service.

Minimum required permissions

Remember to assign appropriate permissions to the Service Principal used by the pipeline:

  • Creating Template Specs requires Template Spec Contributor role
  • If the script will create resource groups, it will need Contribute rights on the subscription level. Otherwise, ensure it has Contribute rights on the resource group level.
  • You may also refine permissions and assign only roles required to deploy the Bicep templates in your solution. See Required permissions

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay