Skip to content

Latest commit

 

History

History
94 lines (67 loc) · 3.29 KB

File metadata and controls

94 lines (67 loc) · 3.29 KB

Avanade DevOps HOL - Lab 1 - Create a CI/CD pipeline for .NET with the Azure DevOps Project

In this lab, we setup our DevOps Project in Azure to create our CI/CD pipeline. This will provide us with a standard code base to work with.

Based on this tutorial.

Prerequisites

Tasks

  1. Go to your Azure Portal and create a new DevOps Project. Make sure it meets the following demands:

    • ASP.NET Core Web App on Windows
    • Linked to your existing VSTS account
  2. When the azure resources are created, go to your VSTS account and make sure that:

    • The first Build and Release are successful
    • The App is deployed and accessable
  3. Clone your code repository to your development environment and open your solution in Visual Studio:

    • Upgrade the project to ASP.NET Core 2.0 (Right-click project > Properties)
    • Update all NuGet packages to their 2.x counterparts (Right-click project > Manage NuGet packages)
  4. Right-click the project and Unload it. Now edit your project file:

    • Remove the line "<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>"
  5. Add a new MSTest Test Project (.NET Core) and add a unit test class named "HomeControllerTest"

    • Click here to expand the sample unit test code
       [TestClass]
       public class HomeControllerTest
       {
           [TestMethod]
           public void Index()
           {
               // Arrange
               HomeController controller = new HomeController();
      
               // Act
               ViewResult result = controller.Index() as ViewResult;
      
               // Assert
               Assert.IsNotNull(result);
           }
      
           [TestMethod]
           public void About()
           {
               // Arrange
               HomeController controller = new HomeController();
      
               // Act
               ViewResult result = controller.About() as ViewResult;
      
               // Assert
               Assert.IsNotNull(result);
               Assert.AreEqual("Your application description page.", result.ViewData["Message"]);
           }
      
           [TestMethod]
           public void Contact()
           {
               // Arrange
               HomeController controller = new HomeController();
      
               // Act
               ViewResult result = controller.Contact() as ViewResult;
      
               // Assert
               Assert.IsNotNull(result);
           }
       }
  6. Build your solution and run the unit tests. Make sure that the tests pass

  7. In VSTS, edit your build definition to support .NET Core 2.0.3

    • Open task "NET Core Tool Installer" and change the version field to 2.0.3 (Do not change task version) Lab 1 netcore version
  8. Push your code to trigger a build/release

Stretch goals

  1. Add custom logging to Application Insights through your Web App

  2. Export the ARM template to set up the Web App in Azure, integrate it in your Release definition

Next steps

Continue with Lab 2 - Add QA environment and define your multi-stage continuous deployment process with approvals and gates.