Deploy your ASP.NET Core app as a container
Azure Pipelines 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.
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.
- You need an Azure DevOps organization. If you don't have one, you can create one for free. If your team already has one, then make sure you're an administrator of the Azure DevOps project that you want to use. (An Azure DevOps organization is different from your GitHub organization. Give them the same name if you want alignment between them.)
- Visual Studio 2017
- Continuous Delivery Tools for Visual Studio
Create an Azure Container Registry
You can use Azure Container Registry to host the Docker image that is published by the CI pipeline. Follow the steps below to create and configure a registry. In later steps, you use Azure Pipelines to deploy the image to an Azure Web App for Containers.
Sign into Azure at https://portal.azure.com.
In the Azure Portal, choose New, Containers, then choose Azure Container Registry.
Enter a Registry name, Resource Group, and select a Location.
For Admin user, choose Enable and then choose Create.
Wait for the Azure Container Registry deployment to finish.
Import code for sample app into Azure Repos
Azure Repos 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 an Azure Repos Git repository. This is the app that you will configure CI/CD for.
In Azure Repos, on the Code page for your Azure DevOps project, select the option to Import repository.
In the Import a Git repository dialog box, paste the following URL into the Clone URL textbox.
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.
Ensure the import of the code completes successfully. In the top right-hand corner of your browser Select clone. Select Clone in Visual Studio.
Visual Studio 2017 will launch and prompt for credentials.
After authenticating, choose a directory and Select clone to finish cloning the code to your local environment.
Install Continuous Delivery (CD) Tools for Visual Studio 2017
Continuous Delivery (CD) Tools for Visual Studio 2017 helps automate the creation of Azure Pipelines to Azure release pipelines. Optionally, you can extend the generated pipeline to further enhance your CI/CD workflows.
In Visual Studio 2017 Select Tools then Select Extensions and Updates.
In the dialogue, Select Online and search for Continuous Delivery Tools for Visual Studio.
Select Download, and once it finishes close Visual Studio to finish the install process.
Restart Visual Studio and open your solution.
In solution explorer Right Select your solution and verify you see a Configure Continuous Delivery 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 Azure Pipelines. This automation allows you to enable CI/CD to Azure for your apps by creating full build and release pipelines in Azure Pipelines.
In Visual Studio, right Select your solution and Select Configure Continuous Delivery.
Choose App Service (Linux) as your Host Type.
Choose the Container Registry you created earlier.
Accept the default App Service name or Select edit to choose a new name.
Select ok, and monitor the output window for results.
Azure resources including the App Service will be created. Azure Pipelines resources such as a build pipeline, and a release pipeline 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.
A build and release will then execute. Navigate to the organization and monitor the builds and releases until they complete. This may take several minutes.
When the deployment finishes, verify that your changes are live in your web browser: http://your-app-name.azurewebsites.net.
Make changes to the web app code and push them to Azure Pipelines. 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 pipeline that automatically deploys your latest work to your Azure App Service.
You've just put your own CI/CD processes in place. You can modify these build and release pipelines to meet the needs of your team. To learn more see this tutorial: