Access Artifact BuildNumber in Azure DevOps Release Pipeline

It might be useful to push artifact or build variables to your Azure websites environment variables in Release pipelines. 

In this article, I'm going to show you how to add build number in Build pipeline to your Azure website when publishing using Release pipeline in Azure DevOps. For this website, the build number is also shown in page footer for reference. 

Available variables

Refer to the following link to find out the complete list of available environment variables that you can use in Release pipelines.

For build number, we will use this particular variable:


The build number or the commit identifier.

Azure pipelines example: 20170112.1

Jenkins/TeamCity example: 20170112.1

TFVC example: Changeset 3

Git example: 38629c964

GitHub example: 38629c964

Use variable

In Azure App Service Deploy task in my release job, update App settings in Application and Configuration Settings section to add the following value:


This step will add an environment variable named KONTEXT_BUILD_NUMBER to my ASP.NET Core application settings when doing the deployment.

Please note 'Starlink-ASP.NET Core-CI' is the artifact alias for my website build artifact. You need to replace it accordingly to your own artifact alias. 

Run the release pipeline

And then you can run the release pipeline. In the output logs, you can see the application settings is added. 

2019-12-01T11:16:31.9073238Z ##[section]Starting: Azure App Service Deploy: kontext
2019-12-01T11:16:31.9280133Z ==============================================================================
2019-12-01T11:16:31.9280240Z Task         : Azure App Service deploy
2019-12-01T11:16:31.9280327Z Description  : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2019-12-01T11:16:31.9280408Z Version      : 4.157.4
2019-12-01T11:16:31.9280454Z Author       : Microsoft Corporation
2019-12-01T11:16:31.9280535Z Help         :
2019-12-01T11:16:31.9280606Z ==============================================================================
2019-12-01T11:16:32.6839383Z Got service connection details for Azure App Service:'kontext'
2019-12-01T11:16:33.9921958Z Updating App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"1"}
2019-12-01T11:16:34.5066167Z Updated App Service Application settings and Kudu Application settings.
2019-12-01T11:16:42.2346930Z Package deployment using ZIP Deploy initiated.
2019-12-01T11:16:47.2178269Z Successfully deployed web package to App Service.
2019-12-01T11:16:47.2181086Z Updating App Service Application settings. Data: {"KONTEXT_BUILD_NUMBER":"20191201.2"}
2019-12-01T11:16:59.4388373Z Updated App Service Application settings and Kudu Application settings.
2019-12-01T11:17:00.0648701Z App Service Application URL:
2019-12-01T11:17:00.0730976Z ##[section]Finishing: Azure App Service Deploy: kontext

Check the application settings in Azure App Service

In Azure portal, you can also find the new settings in Settings > Configurations > Application Settings


Build number is just one of the artifact variables that you can use in release pipelines and you can use any other available variables in your Release pipelines. You can also configure this in pipeline yml file instead of using the Classic UI.

If you want to use the environment variables in PowerShell, the naming will be slightly different. For example, the build number environment name for my artifact is:


To save your time, you can find all the available environment variable names in Initialize Job step in your release pipeline as the following screenshot shows:

info Last modified by Raymond at 8 months ago copyright This page is subject to Site terms.

More from Kontext

Entity Framework Core Code-First - Generate Covering Index with Columns Included

local_offer entity-framework local_offer core local_offer Azure local_offer C#

visibility 40
thumb_up 0
access_time 2 months ago

In SQL Server or some other relational databases, it is a very common requirement to create covering index with columns included in index pages beside the index key columns. With Entity Framework Core, you can also easily generate covering indexes using purely C# code. Scenario For ...

open_in_new ASP.NET Core

local_offer Azure local_offer kontext

visibility 9
thumb_up 0
access_time 4 months ago

In the past few months, Kontext's DNS server was not very stable as it went offline several times accidentally. When the DNS server is down, our domain ( cannot be parsed successfully to the IP address of Azure App Service (the service that hosts this website); thus it became unreach...

open_in_new Kontext Information

Modern Web Application - Azure Blob Storage for Uploaded Files

local_offer Azure local_offer core local_offer dotnetcore

visibility 504
thumb_up 0
access_time 4 months ago

With cloud platforms like Azure, we can totally separate user content storage from web application storage to decouple components from each other and to make the application easy to scale and deploy. This article provides detailed information with code snippets about how to use Azure server-less product Blob Storage and App Service to enable horizontally scalable web application for users to upload files (BLOBs).

open_in_new Azure

Azure SQL Database Automated Backup Strategy

local_offer Azure local_offer SQL Server

visibility 139
thumb_up 0
access_time 4 months ago

When designing the architecture of Kontext platform, Azure SQL Database is chosen as the storage for relational data. TDE and other advanced security features are always enabled to protect the database. Backup plans are also employed to ensure I can always restore the database for as point of tim...

open_in_new Azure

comment Comments (0)

comment Add comment

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

No comments yet.

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.

Learn more arrow_forward