Microsoft Azure Account: If you do not have an active account, sign-up here: Sign-up
Visual Studio Dev Essentials: If you do not have Visual Studio subscription, check this out: Visual Studio
Let's get started.
What is DevOps Starter?
DevOps Starter makes it easy to get started on Azure using either GitHub actions or Azure DevOps. It helps you launch your favorite app on the Azure service of your choice in just a few quick steps from the Azure portal.
DevOps Starter sets up everything you need for developing, deploying, and monitoring your application. You can use the DevOps Starter dashboard to monitor code commits, builds, and deployments, all from a single view in the Azure portal.
What are the advantages of DevOps Starter?
DevOps starter the following supports 2 CI/CD providers, to automate your deployments:
1) GitHub Actions
2) Azure DevOps
DevOps Starter automates the setup of an entire continuous integration (CI) and continuous delivery (CD) for your application to Azure. You can start with existing code or use one of the provided sample applications. Then you can quickly deploy that application to various Azure services such as Virtual Machines, App Service, Azure Kubernetes Services (AKS), Azure SQL Database, and Azure Service Fabric.
DevOps Starter does all the work for the initial configuration of a DevOps pipeline including everything from setting up the initial Git repository, configuring the CI/CD pipeline, creating an Application Insights resource for monitoring, and providing a single view of the entire solution with the creation of a DevOps Starter dashboard in the Azure portal.
Key benefits of using DevOps Starter:
- Quickly deploy your application to Azure.
- Automate the setup of a CI/CD workflow or pipeline.
- View and understand how to properly set up a CI/CD workflow or pipeline.
- Further customize the release pipelines based on your specific scenarios.
What is CI/CD pipeline and what is the purpose of CI/CD pipeline?
A CI/CD pipeline automates your software delivery process. The pipeline builds code, runs tests (CI), and safely deploys a new version of the application (CD). Automated pipelines remove manual errors, provide standardized feedback loops to developers, and enable fast product iterations.
Set up a sample ASP.NET project using DevOps Starter project
Sign into the Microsoft Azure portal: https://portal.azure.com/
In the search box, type DevOps and select DevOps Starter. Then click on Create DevOps Starter.
- By default, DevOps Starter project setup with GitHub. Click on change settings to change the destination to Azure DevOps and click Done.
- Select the .NET sample application and click Next.
- The .NET samples include a choice of either the open source ASP.NET framework or the cross-platform .NET Core framework. Select the .NET Core application framework. This is an ASP.NET Core MVC application. Enable Add a database toggle to add the database to the application. When you’re done, choose Next.
- Web App on Windows is the default deployment target. We can optionally choose Virtual Machine. Click Next.
- Select your Azure DevOps organization and choose a name for your project and Web app. Click Review + Create.
- Click on Additional Settings if you would like to edit web app and database parameters.
- Click Go to resource.
- We can now work on ASP.NET Core app with a CI/CD process that automatically deploys our latest work to our web site. On the right side of the dashboard, select Browse to view our running application.
Let's check and validate CI/CD pipelines configuration for the Azure DevOps project.
- Select Build Pipelines from the top of the Azure DevOps project dashboard. This link opens a browser tab and the Azure DevOps build pipeline.
- Click on Edit.
- This build pipeline performs various tasks such as fetching sources from the Git repository, restoring dependencies, compile the application, run tests and publishing outputs used for deployments.
Go to pipeline name, select History. We can see an audit trail of our recent changes for the build. Azure DevOps keeps track of any changes made to the build definition and allows us to compare versions.
Select Triggers. The Azure DevOps project automatically created a CI trigger and every commit to the repository initiates a new build.
- Click Releases under Pipelines section.
- Now select the release pipeline. Click Edit.
- Under Artifacts, select Drop.
- To the right-hand side of the Drop icon, select the Continuous deployment trigger. This release pipeline has an enabled CD trigger, which executes a deployment every time there is a new build artifact available. Disable this trigger, when our deployments require manual execution.
- Select Tasks. The tasks are the activities your deployment process performs.
- On the right-hand side of the browser, select View releases.
- Now click on the release number.
- Click Logs. The logs contain information about the deployment process.
Write code. Commit & Push the code changes and execute CI/CD.
- Click on Repos to view the created Git repository by Azure DevOps project.
- To view the repository, first clone URL by selecting Clone from the top right of the browser.
- Go to left-hand side of the browser, navigate to the Application/aspnet-core-dotnet-core/Pages/Index.cshtml file. Select Edit, and make a change.
Make some changes and commit the code.
Go to Pipelines. Notice, build is in progress. The changes are automatically built and deployed via Azure DevOps CI/CD pipelines.
- Once the Build and Release are completed in your browser, navigate to the Azure DevOps project dashboard. On the right side of the dashboard, select Browse to view your updated running application.
In this blog we have learned how we can set up a CI/CD pipeline for the sample .NET project in Microsoft Azure DevOps with step by step guide. Hope it helps someone out there. Thank you.