Hesam Seyed Mousavi, January 31, 2019
In this article, we’ll explore several options for deploying an ASP .NET Core web app to Azure App Service in the cloud. From the infamous Right-Click-Publish to fully automated CI/CD, you’ll learn about the latest Deployment Center option in the Azure Portal for App Service for web apps.
NOTE: If you’re looking for information on deploying to Docker or Kubernetes, please check out the following docs instead:
- Host and deploy ASP.NET Core: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy
- Deploy to Azure Kubernetes Service: https://docs.microsoft.com/en-us/azure/devops-project/azure-devops-project-aks
- Host ASP.NET Core in Docker containers: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/docker
- Dockerize a .NET Core application: https://docs.docker.com/engine/examples/dotnetcore/
To quote from the aforementioned MSDN article, “Continuing with the theme of prototyping and experimenting, right click publish is the perfect way for existing Visual Studio customers to evaluate Azure App Service (PAAS). By following the right click publish flow you get the opportunity to provision new instances in Azure and publish your application to them without leaving Visual Studio:”
In other words, you can use this approach for a quick test or demo, as shown in the screenshots below for Visual Studio.
- Right-click your ASP .NET Core web app project in Solution Explorer and select Publish.
- Click the Start button on the screen that appears and follow the onscreen instructions.
- Ensure that you’re logged in to the correct Azure subscription account you want to publish to.
Web Apps in the Azure Portal
In the screenshot above, you may notice an option to “Import Profile” using the button on the lower left. This allows you to import a Web App profile file that was generated by exporting it from an existing Azure Web App. To grab this profile file, simply navigate to your existing Web App in the Azure Portal and click on “Get publish profile” in the top toolbar of your Web App, shown below:
If you want to create a new Web App in Azure starting with the Azure Portal, follow the instructions below:
- Log in to the Azure at https://portal.azure.com
- On the top left, click + Create a resource
- Select “Web App” or search for it if you don’t see it.
- Enter/select the necessary values:
- App name (enter a unique name)
- Subscription (select a subscription)
- Resource Group (create or use existing to group resources logically)
- OS (Windows or Linux)
- Publish (Code or Docker Image)
- App Service Plan (create or use existing to set location and pricing tier)
- Application Insights (now enabled by default)
- Click the Create button to complete the creation of your new Web App.
Now you can deploy to this Web App using any method you choose.
If you like to stay ahead of ASP .NET Core releases, you may be using a pre-release version of the runtime. As of this writing, the latest stable version of ASP .NET Core is version 2.2, but there is a preview of version 3.0 available. Fortunately, Azure App Service also has an option to install an Extension for preview runtimes.
To find the proper runtime:
- Navigate to your Web App in the Azure Portal.
- Click on Extensions under Development Tools.
- Click + Add to add a new extension.
- Choose an extension to configure required settings.
- Accept the legal terms and complete the installation.
Your options may include both 32-bit (x86) and 64-bit (x64) versions of the ASP .NET Core runtime and any preview versions of future releases. When planning ahead for multiple environments, you also have the option to deploy to Deployments Slots. This feature is available in Standard, Premium or Isolated App Service Plan tiers and will covered in a future blog post in this series.
If you’re interested in Deployment Slots right now, check out the official docs at:
- Set up staging environments for web apps in Azure App Service: https://docs.microsoft.com/en-us/azure/app-service/deploy-staging-slots
In the list of features for your Web App, you will find an option to open up the new Deployment Center. Note that this is replacing the old Deployment Options (now labeled as Classic). Let’s go over each of these options:
- Azure Repos
- Local Git
If you choose Azure Repos, you can set up your web app’s CI (Continuous Integration) system with an Azure Repo, which is part of Microsoft’s Azure DevOps services (formerly known as VSTS, aka Visual Studio Team Services). You will have options for using App Service as a Kudu build server or Azure Pipelines as your CI build system.