Setting up CI and CD pipeline in Azure DevOps for ASP.NET Core and Azure Web Apps


In the last post I talked about Azure DevOps, now we will look into a practical use case of Azure DevOps where we will setup a complete continuous integration (CI) and continuous deployment/delivery(CD) pipeline for a ASP.NET Core project hosted on Azure Web Apps. We will host our project solution on Azure Repo. The basic idea is that we will create an Azure Web app, setup our project on Azure Repo, create CD & CD pipeline on Azure DevOps, and see things in action when we push our code to master branch. Let's get started:

Open Azure portal and go to App Services and click on Create app service


From the Marketplace templates, choose Web App.


Click Create.


Choose an app service name that is available, select OS be Windows, Publish by code, then choose an app service plan that fits your budget and click Create.


Once the service is deployed, you will get a ntoification, open it and click Go to resource.


Here you can see live link to your azure web app service. Click and open the link.


By default azure web app hosts a default html page indicating its hosted on azure service app. We are pretty much done here with Azure service app.


Now lets setup our project on Azure Repos. Open Azure Repos, if you don't already have an organization go ahead and click on New Organization and once you have created one Click on Create project.


Give the project a name and descripiton, keep it private and then click on Advanced.



Chose a version control system (Git is the most popular so I always choose that) and then choose a working process like Agile or Scrum and click Create.


This will create a repository and take you to its summary page like the one below.


Goto  Repos > Files then you will see a link to your repository. You can also directly clone this repo on your Visual Studio IDE. Choose Visual Studio and click Clone in Visual Studio.


This will open up your visual studio, ask you to login via OAuth OpenId process and once clone on your PC, you will see something like that on Solution Explorer windows. We can see that we are connected to a remote repository's master branch.


Now we will add a new ASP.NET Core solution on our local master branch. Go to File > New > Project and under the InstalledVisual C# > .NET Core choose  a ASP.NET Core Web Application  and a name for the project. Make sure the path is pointing inside clone repository.   


Select Web Application (Model-View-Controller) and click OK.


Open Team Explorer, if you have any bin, obj or vs folder items you need to add them to  git ignore file. Commit and push the changes with a message.


Go back to Azure DevOps portal of your project and click on Pipelines. Then New pipeline.


Select a source, in our case Azure Repo Git. Select your project, repository and branch. Click Continue.


Select Azure Web App for ASP.NET and click Apply.


Choose a name, select Agent pool, selection all .sln files, select the Azure Subscription on which Azure Web app was create and click Authorize


Your browser might show you an error notification saying to enable pop-up notification as shown below.


Click on notification icon and select to show pop-up notification always then click Done


Once you authorize and give access to Azure Subscription, you will be able to see all Azure App service in the drop-down below. Finally click Save & queue.


Click on Save & Queue again while selecting Hosted VS2017 and master branch. 


This will setup CI & CD pipeline and your build is schedule for compilation, release and deploy. 


Once build is successful, you will see a green tick showing all build steps have been successful. Click on the check-in to see logs.


We can see that all jobs have been successful including Azure App Service Deploy. Ideally, we should have deployed it to a pre-release/pre-deploy slot to make sure everything works correctly but for the purpose of demo I have chosen to directly deploy on web app service which will cause a down time, you should always deploy to Slot first and then swap it with production build.


Now if we open the link to our Azure Web app, we can see latest build is deployed with our check-in 


There are much more details that you can find here. The demo was for a quick demonstration of the how you can setup CI & CD pipeline with ASP.NET Core and Azure Web Apps.

Comments

  1. I was dazzled by this post, this site has consistently been wonderful data about azure. you especially for such a fascinating post, and I meet them all the more regularly then I visited this site. Oracle fusion instance access

    ReplyDelete
  2. Thank you for writing this informative post. High Technologies Solutions providing best coaching classes in south delhi. Otherwise If any one who want to learn dot-net contact us on 9311002620 or visit:- https://htsindia.com/Courses/microsoft-courses/dotnettraininginstituteinsouthdelhi

    ReplyDelete
  3. Thank you for the informative blog provided regarding azure cloud migration services. I got lots of information from this blog about azure cloud migration.
    azure cloud migration services

    ReplyDelete
  4. This is the excellent piece of information which you had provided, there is lot of value rich information added in your blog ,go through our website if some readers wishes to get more insights on Devops as a services (DAAS) and all latest advancement in this field;.

    ReplyDelete
  5. Thank you for the informative blog provided regarding azure cloud migration services. I got lots of information from this blog about azure cloud migration.
    azure cloud migration services

    ReplyDelete
  6. Absolutely knowledgeable content. Thanks for sharing this kind of content. It is very helpful and very informative and I really learned a lot from it. Further More Information About Dot Net Training Institute in Delhi So Contact Here-+91-9311002620 Or Visit Website- https://htsindia.com/Courses/microsoft-courses/dotnettraininginstituteinsouthdelhi

    ReplyDelete
  7. Such a useful blog with needed information and thanks for sharing this amazing blog.
    AWS Course in Chennai
    DevOps Certification in Chennai

    ReplyDelete
  8. This post is so helpfull and informative.Keep updating more information...
    Best Spoken English
    Spoken English Class Videos

    ReplyDelete
  9. Good Post!!! Thanks for sharing this most useful blog with us...
    Benefits of Tableau
    Purpose of Tableau

    ReplyDelete

Post a Comment

Popular posts from this blog

Implementing Basic and JWT Token authentication with C# .NET

Setting up Free Custom Domain on Microsoft Azure Web App Service

.NET Core 3 officially comes to Windows IoT Core

Microsoft Azure DevOps : A Complete CI & CD solution in the cloud

Microsoft Azure Blob Storage - Managing Blobs and storage containers from C#

Xamrin Android Push Notification using Firebase Cloud Messaging

Securing Powershell Scripts with Code-Signing Certificate

Understanding Powershell ExecutionPolicy and securing Powershell CmdLets/Scripts with Code-Signing Certificate

Fundamental of Powershell Scripting