Microsoft Azure

In this post, I’m going to explain how to create a pipeline and a release in Azure DevOps that releases into AppServices. This is quite important step to go forward a digital transformation in your company to improve and optimize the developer’s process.

In the pipeline Azure DevOps builds the solution (projects and tests) and create an artifact. Then, with the release, it publishes the artifact into to a AppService in Azure. Now I show step by step how to create both.

Pipeline

First, you have to create a New pipeline and then select where your code is. If you select one of the elements in the list, Azure DevOps will create an YAML file. This wizard is not suitable for me; then I want to “Use the classic editor

Azure DevOps - Where is your code?
Azure DevOps – Where is your code?

After this choice, I have to select my repository. My repository is in Azure Repos Git and then some fields are already prepopulated.

Azure DevOps - Select your repository
Azure DevOps – Select your repository

In this step I have to select:

  • Team project
  • Repository
  • Default branch for manual and scheduled builds

If you want to implement Git Flow branches for your deployment, please read the post I created about it.

Azure DevOps - Choose a template
Azure DevOps – Choose a template

Then, I have to choose a template: I search and add ASP.NET Core. Now, I have to add 4 steps before publishing the artifact.

dotnet restore

Restore the Nuget packages for the solution. In the Path to project(s) I explicitly say what project I want to build.

**/MyProject.csproj
**/MyProject.Tests.csproj

Pipeline - dotnet restore
Pipeline – dotnet restore

dotnet test

Run the tests for the solution, if there are exists.

Pipeline - dotnet test
Pipeline – dotnet test

dotnet build

This step is building all projects. Add in Path to project(s):

**/*.csproj

Pipeline - dotnet build
Pipeline – dotnet build

dotnet publish

Publish the compiled project(s) in a zip file in a particular directory, so, I can read it later. For that, add in Arguments this text:

-o $(Build.ArtifactStagingDirectory)

Pipeline - dotnet publish
Pipeline – dotnet publish

Publish Artifact: drop

Finally, I publish the artifact from a specific directory in Path to publish:

$(Build.ArtifactStagingDirectory)

Also, check:

  • Publish web projects
  • Zip published projects
Pipeline - Publish Artifact: drop
Pipeline – Publish Artifact: drop

Release

The release takes the artifact and publish it in an Azure AppService. First, select from where it has to take the artifact and remember to enable the continuous deployment.

Release - Artifacts
Azure DevOps Release – Artifacts
Azure DevOps Release - Enable Continuous deployment
Azure DevOps Release – Enable Continuous deployment
Release - Tasks
Azure DevOps Release – Tasks

Change the Package or folder in $(System.DefaultWorkingDirectory)/*/.zip

Conclusion

So, in this short post I explained how to create a process in Azure DevOps to release AppServices.

By Enrico

My greatest passion is technology. I am interested in multiple fields and I have a lot of experience in software design and development. I started professional development when I was 6 years. Today I am a strong full-stack .NET developer (C#, Xamarin, Azure)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.