:::: MENU ::::
Monthly Archives: February 2022

Azure Log Analytics / Application Insights – search everywhere

If you have Azure Log Analytics or Application Insights, where you have different data sources, like exceptions, requests, traces, customEvents, you may want to search for some certain phrase everywhere, because you don’t know in which data source you should check or in which column.

There is quite handy way of doing that – search in query.

Quick example:

search in (exceptions, requests, traces, customEvents) "ManagedIdentityCredential"

And details in documentation.


Add tag to your build and use it in release pipeline in Azure DevOps

Adding a tag to your build in Azure DevOps is very useful – you can use it later on with releases to accept only builds with certain tags. That comes in handy when you are building a project with many different configurations which you will, later on, deploy via different releases. For example:

BUILD (tag: client1) -> RELEASE CLIENT 1
BUILD (tag: client2) -> RELEASE CLIENT 2

You can use it on client basis or environment basis like dev, uat, prod.

You can add as tag whatever you want. For example variable value that you can set, when you are starting the build. You can skip next step if you want to use existing variable in your pipeline.

Create variable in your build pipeline

  1. Create or edit your existing pipeline.
  2. Go to Variables/Pipeline variables tab.
  3. Add your variable, for example EnvironmentTag and add default value.
  4. Select Settable at queue time to make sure that you can change it when you are scheduling your build.
Creating variable in build pipeline.

Add a stage to tag your build

  1. Go to the Tasks tab.
  2. It’s good to have 2 stages – one to perform all the tasks related to your build and the other to tag the build.
  3. Add PowerShell or Bash task that will add tag based on EnvironmentTag variable value: Write-Host "##vso[build.addbuildtag]$(EnvironmentTag)"
Adding new stage with Powershell task to tag build.

Execute pipeline

When you go to the build pipeline summary and go to Run pipeline you should be able to go to Variables and change EnvironmentTag value.

Run your pipeline.
Select Variables section.
Change EnvironmentTag value.

Check your tag

Once your build is completed you can go to your build and check if you have your tag in there.

Use tags in release pipelines

Once we have our build tagged, we can use that information on the release pipeline level, and for example trigger, automatic trigger based on branch and tag. Go to your release pipeline and edit the Pre-deployment conditions for your stage. In this example, I want to do an automatic release of Prod stage once the build from branch main and with tag prod is created.

Automatic release once build from main branch with prod tag is created.