Create an ASP.NET Core web app in Azure


This article deploys an app to App Service on Windows. To deploy to App Service on Linux, see Create a .NET Core web app in App Service on Linux.

If you're looking for steps for an ASP.NET Framework app, see Create an ASP.NET Framework web app in Azure.

Azure Web Apps provides a highly scalable, self-patching web hosting service. This quickstart shows how to deploy your first ASP.NET Core web app to Azure Web Apps. When you're finished, you'll have a resource group that consists of an App Service plan and an Azure web app with a deployed web application. You can watch a video that demonstrates how to perform these steps entirely from within Visual Studio 2017.

If you don't have an Azure subscription, create a free account before you begin.


To complete this tutorial:

  • Install Visual Studio 2017 with the following workloads:

    • ASP.NET and web development
    • Azure development

      ASP.NET and web development and Azure development (under Web & Cloud)

Create an ASP.NET Core web app

In Visual Studio, create a project by selecting File > New > Project.

In the New Project dialog, select Visual C# > Web > ASP.NET Core Web Application.

Name the application myFirstAzureWebApp, then select Create new Git repository, and then select OK.

New Project dialog box

You can deploy any type of ASP.NET Core web app to Azure. For this quickstart, select the Web Application template, and make sure authentication is set to No Authentication.

Select OK.

New ASP.NET Project dialog box

Once the ASP.NET Core project is created, the ASP.NET Core welcome page is displayed, providing numerous links to resources to help you get started.

Welcome Page

From the menu, select Debug > Start without Debugging to run the web app locally.

Run app locally

Launch Azure Cloud Shell

The Azure Cloud Shell is a free interactive shell that you can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your account. Just click the Copy button to copy the code, paste it into the Cloud Shell, and then press enter to run it. There are a few ways to launch the Cloud Shell:

Click Try It in the upper right corner of a code block. Cloud Shell in this article
Open Cloud Shell in your browser.
Click the Cloud Shell button on the menu in the upper right of the Azure portal. Cloud Shell in the portal

Create a deployment user

In the Cloud Shell, create deployment credentials with the az webapp deployment user set command. This deployment user is required for FTP and local Git deployment to a web app. The user name and password are account level. They are different from your Azure subscription credentials.

In the following example, replace <username> and <password> (including brackets) with a new user name and password. The user name must be unique within Azure. The password must be at least eight characters long, with two of the following three elements: letters, numbers, symbols.

az webapp deployment user set --user-name <username> --password <password>

You should get a JSON output, with the password shown as null. If you get a 'Conflict'. Details: 409 error, change the username. If you get a 'Bad Request'. Details: 400 error, use a stronger password.

You create this deployment user only once; you can use it for all your Azure deployments.


Record the user name and password. You need them to deploy the web app later.

Create a resource group

A resource group is a logical container into which Azure resources like web apps, databases, and storage accounts are deployed and managed. For example, you can choose to delete the entire resource group in one simple step later.

In the Cloud Shell, create a resource group with the az group create command. The following example creates a resource group named myResourceGroup in the West Europe location. To see all supported locations for App Service in Free tier, run the az appservice list-locations --sku F1 command.

az group create --name myResourceGroup --location "West Europe"

You generally create your resource group and the resources in a region near you.

When the command finishes, a JSON output shows you the resource group properties.

Create an Azure App Service plan

In the Cloud Shell, create an App Service plan with the az appservice plan create command.

The following example creates an App Service plan named myAppServicePlan in the Free pricing tier:

az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku FREE

When the App Service plan has been created, the Azure CLI shows information similar to the following example:

  "adminSiteName": null,
  "appServicePlanName": "myAppServicePlan",
  "geoRegion": "West Europe",
  "hostingEnvironmentProfile": null,
  "id": "/subscriptions/0000-0000/resourceGroups/myResourceGroup/providers/Microsoft.Web/serverfarms/myAppServicePlan",
  "kind": "app",
  "location": "West Europe",
  "maximumNumberOfWorkers": 1,
  "name": "myAppServicePlan",
  < JSON data removed for brevity. >
  "targetWorkerSizeId": 0,
  "type": "Microsoft.Web/serverfarms",
  "workerTierName": null

Create a web app

In the Cloud Shell, create a web app in the myAppServicePlan App Service plan. You can do it by using the az webapp create command. In the following example, replace <app_name> with a globally unique app name (valid characters are a-z, 0-9, and -).

az webapp create --name <app_name> --resource-group myResourceGroup --plan myAppServicePlan --deployment-local-git

When the web app has been created, the Azure CLI shows information similar to the following example:

Local git is configured with url of 'https://<username>@<app_name><app_name>.git'
  "availabilityState": "Normal",
  "clientAffinityEnabled": true,
  "clientCertEnabled": false,
  "cloningInfo": null,
  "containerSize": 0,
  "dailyMemoryTimeQuota": 0,
  "defaultHostName": "<app_name>",
  "deploymentLocalGitUrl": "https://<username>@<app_name><app_name>.git",
  "enabled": true,
  < JSON data removed for brevity. >

You’ve created an empty web app, with git deployment enabled.


The URL of the Git remote is shown in the deploymentLocalGitUrl property, with the format https://<username>@<app_name><app_name>.git. Save this URL as you need it later.

Browse to the newly created web app.


Here is what your new web app should look like:

Empty web app page

Push to Azure from Visual Studio

Back in Visual Studio, from the View menu, click Team Explorer. The Team Explorer is displayed.

In the Home view, click Settings > Repository Settings.

Team Explorer home view

In the Remotes section of the Repository Settings, select Add. The Add Remote dialog box is displayed.

Set the Name field to Azure, and then set the Fetch field to the URL that you saved from Create a web app. Click Save.

Team Explorer home view

This setting is equivalent to the Git command git remote add Azure <URL>.

Click the Home button at the top.

Select Settings > Global Settings. Confirm that the name and email address are set. Select Update if necessary.

Visual Studio already committed all the files into the Git repository when it created the project. All you need to do now is to push the files to Azure.

Click the Home button at the top. Select Sync > Actions > Open Command Prompt.

Enter the following command in the command window, and enter the deployment password when prompted:

git push Azure master

This command may take a few minutes to run. While running, it displays information similar to the following example:

Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 349 bytes | 349.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '9e20345e9c'.
remote: Generating deployment script.
remote: Project file path: .\myFirstAzureWebApp\myFirstAzureWebApp.csproj
remote: Solution file path: .\myFirstAzureWebApp.sln
remote: Generated deployment script files
remote: Running deployment command...
remote: Handling ASP.NET Core Web Application deployment.
remote:   Restoring packages for D:\home\site\repository\myFirstAzureWebApp\myFirstAzureWebApp.csproj...
remote:   Restoring packages for D:\home\site\repository\myFirstAzureWebApp\myFirstAzureWebApp.csproj...
remote: Finished successfully.
remote: Running post deployment command(s)...
remote: Deployment successful.
To https://<app_name><app_name>.git
 * [new branch]      master -> master

Browse to the app

In a browser, navigate to the Azure web app URL: http://<app_name>

The page is running as an Azure App Service web app.

Published ASP.NET web app in Azure

Congratulations, your ASP.NET Core web app is running live in Azure App Service.

Update the app and redeploy

From the Solution Explorer, open Pages/Index.cshtml.

Find the <div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000"> HTML tag near the top, and replace the entire element with the following code:

<div class="jumbotron">
    <h1>ASP.NET in Azure!</h1>
    <p class="lead">This is a simple app that we’ve built that demonstrates how to deploy a .NET app to Azure App Service.</p>

From the Solution Explorer, right-click Pages/Index.cshtml and click Commit. Enter a commit message for your change and click Commit All.

Back in the command prompt window, push the code changes to Azure.

git push Azure master

When deployment completes, navigate to http://<app_name> again.

Updated ASP.NET web app in Azure

Manage the Azure web app

Go to the Azure portal to manage the web app.

From the left menu, select App Services, and then select the name of your Azure web app.

Portal navigation to Azure web app

You see your web app's Overview page. Here, you can perform basic management tasks like browse, stop, start, restart, and delete.

App Service page in Azure portal

The left menu provides different pages for configuring your app.

Clean up resources

In the preceding steps, you created Azure resources in a resource group. If you don't expect to need these resources in the future, you can delete them by deleting the resource group.

From the left menu in the Azure portal, select Resource groups and then select myResourceGroup.

On the resource group page, make sure that the listed resources are the ones you want to delete.

Select Delete, type myResourceGroup in the text box, and then select Delete.


Next steps