Build and deploy to an Azure Web App
Visual Studio Team Services (VSTS) provides a highly customizable continuous integration (CI) and continuous deployment (CD) pipeline to automatically deliver your ASP.NET Core web app to Azure App Services. In this quickstart you will use the Azure portal to configure an entire CI/CD pipeline, and then see it build and deploy your app.
For example, you can continuously deliver your app to Azure.
After you commit and push a code change, it is automatically built and then deployed. 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.
- An Azure subscription. You can get one free through Visual Studio Dev Essentials.
Get the sample code
To configure a CI build process for your app, the source code needs to be in a version control system. You can use VSTS as your version control system, since VSTS provides a full-featured Git server. Alternatively, you can use GitHub.
For a simple way to follow this quickstart, get the following sample app code and put it into your own version control repository:
To import the sample app into a Git repo in VSTS or TFS:
On the Code hub for your team project in VSTS/TFS, select the option to Import repository.
In the Import a Git repository dialog box, paste the above URL into the Clone URL text box.
Click Import to copy the sample code into your Git repo.
Create an Azure web app using the portal
If you already have a web app that you want to use, you can skip this and move to the next section.
Sign into the Microsoft Azure portal.
Choose the + icon in the left navigation bar, then choose Web App.
If you don't see Web App in the list, use the search box to find it.
At the bottom of the introduction page, choose Create.
Enter a name for the new web app. You'll see a green checkmark when the name is unique. Then choose Create.
Choose the App Services icon in the left navigation bar. After a few minutes, you'll see the new web app appear in the list. Ensure that it is running.
You're now ready to start using your new web app.
Configure continuous delivery
In the Azure portal, open your web app's blade. Choose Continuous Delivery and then choose Configure.
Select Choose repository and select VSTS for the code repository. Select the project, repository, and branch into which your imported the sample code. When you're done, choose OK.
Select Configure Continuous Delivery and choose ASP.NET Core. When you're done, choose OK.
Skip the other two steps - Test and Deploy - and choose OK to complete the configuration of continuous delivery. You'll see how to use the test and deployment options in other tutorials.
When you choose OK, Azure Continuous Delivery configures and kicks off a build and deployment in VSTS. When the build completes, the deployment is automatically initiated. After a while, the deployment is completed. Choose Refresh Logs to see this in the Activity Log.
Open a new browser window and navigate to your new web at http://your-app-name.azurewebsites.net.
Edit the code and see it deployed
Now that you have a completely automated CI/CD pipeline, any changes that you make to the app are automatically built and deployed by VSTS. To try this, make a change to the app and commit that change to the Git repository.
Both VSTS and GitHub feature a full code editor within the web browser. Using the browser, navigate to Views/Homes/Index.cshtml file in your repository.
Make a simple change above the slide carousel
<h1>Demo of CI/CD!!</h1>
Commit your changes to trigger a CI build. When the build completes, it triggers an automatic deployment.
It takes several minutes for the build and deployment to execute. Wait until the deployment is done, then verify that your changes are live in your web browser: http://your-app-name.azurewebsites.net.
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 web site.
When you configured your CI/CD process in this quickstart, a build and release definition were automatically created in your VSTS project. You can modify these build and release definitions to meet the needs of your team. To learn more see one of these tutorials: