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

Heroku

Amplify your impact where it matters most — building exceptional apps.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay