Skip to main content

.NET - Azure DevOps Pipeline

The pipeline will automate provisioning and updating the .NET REST API with CQRS infrastructure in Azure.

Pipeline Diagram

Feature branch -> Dev sequence

Dev .NET REST API - Azure DevOps Pipeline

Main branch -> Production sequence

Prod .NET REST API - Azure DevOps Pipeline

Setting up Azure DevOps

Variables

A variable file located at build/azDevOps/azure/ci-vars.yml will contain the majority of the variables required for the pipeline. This file should be manually checked and updated where required before first deployment. If the project was generated using the Stacks CLI then the file will be updated with the information provided.

Variable groups will need creating for storing some sensitive variables to be used by the pipeline. Instructions for creating a variable group can be found here. Two variable groups are used by default, one for Azure credentials and one for any application specific variables.

Azure Credentials

Create a variable group called azure-sp-creds, add a description and make sure the Allow access to all pipelines option is checked.

Add the following variables:

Variable NameDescriptionRequired for
ARM_CLIENT_IDAzure Service Principal Client IDTerraform and application deployment
ARM_CLIENT_SECRETAzure Service Principal Client SecretTerraform and application deployment
ARM_SUBSCRIPTION_IDAzure Subscription IDTerraform and application deployment
ARM_TENANT_IDAzure Tenant IDTerraform and application deployment

Application Specific

Create a the variable group, add a description and make sure the Allow access to all pipelines option is checked. Update the - group: replaceme in the build/azDevOps/azure/ci-vars.yml file to match the name of your variable group.

Add the following variables:

Variable NameDescriptionRequired for
SONAR_TOKENSonarCloud TokenStatic Code Analysis

Create the pipeline

Follow the steps below to create the pipeline and trigger the initial run.

  1. In the pipelines section of Azure DevOps, select New Pipeline.
  2. Select your repository.
  3. Select the Existing Azure Pipelines YAML files option and enter the path build/azDevops/azure/ci.yml
  4. Click run and wait for the pipeline to complete.