Click here to Skip to main content
15,936,902 members
Articles / DevOps / Git

Continuous Integration and Deployment (CI/CD) of ASP.NET Core Application on Azure Web App using Jenkins – Day 4

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
28 Nov 2019CPOL6 min read 11.4K   69   2   3
In this article, we’ll learn the CI/CD of ASP.NET Core application on Azure using Jenkins Azure Pipeline.


In the first article of the series, we learned about the concepts, terminology, technologies involved, installing Jenkins, creating ASP.NET Core application and continuous integration of ASP.NET Core application using Jenkins via two approaches, i.e., pipeline approach and freestyle project approach. In the second article, we published the ASP.NET Core application to Azure App Service and Configured Jenkins on Azure. In the third article of the series, we focused on Azure Active Directory and Service Principal and how to integrate Jenkins with Azure Service Principal.

In this last article of learning CI and CD of ASP.NET Core application using Jenkins, we’ll learn the CI/CD of ASP.NET Core application on Azure using Jenkins Azure Pipeline.


This article series will explain using Jenkins for CI and CD of an ASP.NET Core web application on the local development environment, publishing the web application to Azure Web App Service and configuring Jenkins on Azure for continuous integration and continuous deployment of the hosted application. GitHub will DevOps as a source control repository. We’ll create a pipeline using Jenkins that fetches the code from GitHub, builds the code, runs the tests and deploy the package. This will be a repetitive task on each commit to the code located on GitHub.

Following is the roadmap we would be following to completely learn end to end development and configurations of Continuous Integration and Deployment (CI/CD) of ASP.NET Core Application on Azure Web App using Jenkins.


Jenkins being an open-source tool for automation helps a team/developer to build and test the software code continuously. It makes it easy for a developer to integrate and test the code without manual intervention. The tool could be set up to create a deployment pipeline that includes continuous integration of the code at each code commit, continuously testing the build, publishing artifacts and documents and deploying the code. Jenkins could be configured on the servers, say it be development, staging or production as per the deployment needs.

Image 1


Go through the first two articles of the series before starting this article.

The following are the prerequisites for the developers to have on their machines before getting started.

  1. Visual Studio 2017/2019
  2. Dotnet 2.1 SDK installed
  3. Azure Subscription Free/Paid
  4. Java 1.5 or higher
  5. Git account
  6. Git for Windows

CI/CD of ASP.NET Core Application on Azure using Jenkins Azure Pipeline

This section will explain how we can enable continuous integration and deployment of our application. All the required setup has been done. We just need to configure Jenkins now to make it happen. We’ll do this by using a pipeline project approach.

Image 2

Create New Pipeline Job

On the Jenkins home page, create a new job.

Image 3

Give a meaningful name (e.g., Jenkins-on-Azure) to the pipeline project and select “Pipeline” as the project type.

Image 4

Add Parameters

On the General tab, check the option saying, “This project is parameterized”. We’ll add a few parameters here.

Image 5

Add three string parameters named git_repo to provide URL of the git repository, res_group to provide the name of the resource group and JenkinsIntegration, this would be the name of our web application project. You can provide the default values here, or else you would be asked to provide those while running the build.

Image 6

Add a credentials parameter named azure_cred_id and choose credential type as “Microsoft Azure Service Principal”, the default value will be the id service principal we created earlier.

Image 7

Add Pipeline Script

In the Pipeline script section, provide the pipeline script for git check out, build, publish and deploy.

node {
    stage('Checkout git repo') {
      git branch: 'master', url: params.git_repo
    stage('build and publish') {
        sh(script: "dotnet publish JenkinsIntegration -c Release ", returnStdout: true)
    stage('deploy') {
        azureWebAppPublish azureCredentialsId: params.azure_cred_id,
            resourceGroup: params.res_group, appName: params.JenkinsIntegration, 

Image 8

Run the Build

Save the configurations and go to the home page. You can manually trigger the build and since we did not provide the default values in parameters, it asks to provide the values. Provide the values and click the “Build” button.

Image 9

We were expecting a clean and successful build, but we see below that our build failed. The reason it says is it could not find the “dotnet” command while publishing. Since Jenkins here runs under Linux workspace. Our Linux server should have the dotnet installed.

Image 10

Install Dotnet

Let’s install dotnet SDK 2.1 on Linux. Go back to the terminal where the tunnel was running and run the following commands one by one to register Microsoft key and feed.

  • wget -q -O packages-microsoft-prod.deb
  • sudo dpkg -i packages-microsoft-prod.deb

Now run the following commands to install the .NET Core 2.1 SDK.

  • sudo apt-get install apt-transport-https
  • sudo apt-get update
  • sudo apt-get install dotnet-sdk-2.1

Image 11

This will install the .NET Core 2.1 SDK on the Linux server.

Schedule a Build

Go to the home page of Jenkins and again try to trigger the build.

Image 12

We see our build succeeded.

Image 13

Build Automatic Polling

Let’s set the build triggers for automatic polling, i.e., as soon as the code is committed in a git repository, the build should fire. Check Poll SCM and schedule value should be “* * * * *”.

Image 14

Continuous Deployment

Open the browser and browse to the deployed application on Azure. We see the application running.

Image 15

Now make some changes in the cshtml file to check if the automatic build fires. So, I changed the text from “Getting Started with Jenkins” to “Getting Started with Jenkins on Azure” in the Index.cshtml file.

Image 16

And, change the version of the application to 2.0.

Image 17

Commit the code and push to the origin.

Image 18

We see, as soon as the code is pushed to the repository, within one second, build triggers automatically.

Image 19

Check if the build succeeds.

Image 20

Go back to the browser, and refresh it, we see that our changes are reflected here that means our application automatically got deployed on Azure.

Image 21


In this article series, we learned about the use of Jenkins and how useful it could be in our software development life cycle. We learned using Jenkins for CI and CD of an ASP.NET Core web application on the local development environment, publishing the web application to Azure Web App Service and configuring Jenkins on Azure for continuous integration and continuous deployment of the hosted application. Jenkins is a vast topic and while working with it, a lot of patience is needed for things to get set up, but once set up, it works seamlessly.


  • 27th November, 2019: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
India India
Akhil Mittal is two times Microsoft MVP (Most Valuable Professional) firstly awarded in 2016 and continued in 2017 in Visual Studio and Technologies category, C# Corner MVP since 2013, Code Project MVP since 2014, a blogger, author and likes to write/read technical articles, blogs, and books. Akhil is a technical architect and loves to work on complex business problems and cutting-edge technologies. He has an experience of around 15 years in developing, designing, and architecting enterprises level applications primarily in Microsoft Technologies. He has diverse experience in working on cutting-edge technologies that include Microsoft Stack, AI, Machine Learning, and Cloud computing. Akhil is an MCP (Microsoft Certified Professional) in Web Applications and Dot Net Framework.
Visit Akhil Mittal’s personal blog CodeTeddy (CodeTeddy ) for some good and informative articles. Following are some tech certifications that Akhil cleared,
• AZ-304: Microsoft Azure Architect Design.
• AZ-303: Microsoft Azure Architect Technologies.
• AZ-900: Microsoft Azure Fundamentals.
• Microsoft MCTS (70-528) Certified Programmer.
• Microsoft MCTS (70-536) Certified Programmer.
• Microsoft MCTS (70-515) Certified Programmer.

This is a Collaborative Group

780 members

Comments and Discussions

PraiseMy Vote 5 - With question Pin
Member 145940759-Jan-20 3:23
Member 145940759-Jan-20 3:23 
GeneralMy vote of 5 Pin
Anil Chauhan 25081-Dec-19 18:35
professionalAnil Chauhan 25081-Dec-19 18:35 
GeneralRe: My vote of 5 Pin
Akhil Mittal2-Dec-19 0:02
professionalAkhil Mittal2-Dec-19 0:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.