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.
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.
- 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.
Sign into your Azure Account 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 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.
In VSTS, on the Code hub for your VSTS 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.
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.
- 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 VSTS. This automation allows you to enable CI/CD to Azure for your apps by creating full build and release pipelines in VSTS.
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. 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.
- 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.
- 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 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.
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: