CI/CD to Linux, Docker, and Azure Container Registry (ACR)

[ad_1]




Visual Studio Team Services (VSTS) provides a highly customizable continuous integration (CI) and continuous deployment (CD) pipeline for your ASP.NET Core apps. This quickstart shows how to set up CI and CD to deploy an ASP.NET Core application to Linux App Service using Docker and Azure Container Registry.

A typical release pipeline for web applications

With your CI/CD processes in place, you’ll push a change into your team’s git repo and the results will automatically show up on your site.

Screenshot showing ASP.NET Core web app

Prerequisites

  • A VSTS account. If you don’t have one, you can create one for free. If your team already has one, then make sure you are an administrator of the team project you want to use.

Create an Azure Container Registry

You can use Azure Container Registry to host the Docker image that is published by the CI process. Follow the steps below to create and configure a registry. In later steps, you use VSTS to deploy the image to an Azure Web App for Containers.

  1. Sign into your Azure Account at https://portal.azure.com.

  2. In the Azure Portal, choose New, Containers, then choose Azure Container Registry.

  3. Enter a Registry name, Resource Group, and select a Location.

    Container Registry settings

  4. For Admin user, choose Enable and then choose Create.

  5. Wait for the Azure Container Registry deployment to finish.

Import code for sample app into VSTS

VSTS is a full-featured Git server for hosting your team’s source code. You’ll import code for a sample ASP.NET Core app into VSTS Git repository. This is the app that you will configure CI/CD for.

  1. In VSTS, on the Code hub for your VSTS project, select the option to Import repository.

    import repository menu item

  2. In the Import a Git repository dialog box, paste the following URL into the Clone URL textbox.

    https://github.com/adventworks/dotnetcore-docker-sample
    
  3. Click Import to copy the sample code into your Git repo.

Clone the solution

Use the following steps to clone the sample solution and open it in Visual Studio 2017. This allows you to work with the solution in a local development environment. In upcoming steps, you use Visual Studio 2017 to configure continuous integration and continuous delivery for the web app.

  1. Ensure the import of the code completes successfully. In the top right-hand corner of your browser Select clone. Select Clone in Visual Studio.

    Clone from browser
    Clone in Visual Studio

  2. Visual Studio 2017 will launch and prompt for credentials.
  3. After authenticating, choose a directory and Select clone to finish cloning the code to your local environment.

Continuous Delivery (CD) Tools for Visual Studio 2017 helps automate the creation of VSTS to Azure release pipelines. Optionally, you can extend the generated pipeline to further enhance your CI/CD workflows.

  1. In Visual Studio 2017 Select Tools then Select Extensions and Updates.
  2. In the dialogue, Select Online and search for Continuous Delivery Tools for Visual Studio.
  3. Select Download, and once it finishes close Visual Studio to finish the install process.
  4. Restart Visual Studio and open your solution.
  5. In solution explorer Right Select your solution and verify you see a Configure Continuous Delivery icon.

    Connfigure CD icon

Configure and execute Continuous Delivery (CD) for your app

Visual Studio 2017 can automate the creation of a CI/CD pipeline. The CD tooling quickly creates various services in Azure and VSTS. This automation allows you to enable CI/CD to Azure for your apps by creating full build and release pipelines in VSTS.

  1. In Visual Studio, right Select your solution and Select Configure Continuous Delivery.

    Connfigure CD from Visual Studio

  2. Choose App Service (Linux) as your Host Type.
  3. Choose the Container Registry you created earlier.
  4. Accept the default App Service name or Select edit to choose a new name.
  5. Select ok, and monitor the output window for results.
  6. Azure resources including the App Service will be created. VSTS resources such as a build definition, and a release definition will be created in the same project that contains your source code. You can monitor the configuration progress in the Output window in Visual Studio.

    Visual Studio output window

  7. A build and release will then execute. Navigate to the VSTS account and monitor the build and release processes until they complete. This process may take several minutes.
  8. When the deployment finishes, verify that your changes are live in your web browser: http://your-app-name.azurewebsites.net.
  9. Make changes to the web app code and push them to VSTS. A new build and release will execute and deploy the changes.

You’re now ready to collaborate with a team on an ASP.NET Core app with a CI/CD process that automatically deploys your latest work to your Azure App Service.

Next Steps

You’ve just put your own CI/CD processes in place. You can modify these build and release definitions to meet the needs of your team. To learn more see this tutorial:

[ad_2]

source_link
https://www.asp.net