Quickstart: Create an ASP.NET Core web app in Azure

In this quickstart, you'll learn how to create and deploy your first ASP.NET Core web app to Azure App Service.

When you're finished, you'll have an Azure resource group consisting of an App Service hosting plan and an App Service with a deployed web application.


  • An Azure account with an active subscription. Create an account for free.

  • This quickstart 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.

  • Install Visual Studio 2019 with the ASP.NET and web development workload.

    If you've installed Visual Studio 2019 already:

    • Install the latest updates in Visual Studio by selecting Help > Check for Updates.
    • Add the workload by selecting Tools > Get Tools and Features.

Create an ASP.NET Core web app

Create an ASP.NET Core web app in Visual Studio by following these steps:

  1. Open Visual Studio and select Create a new project.

  2. In Create a new project, select ASP.NET Core Web Application and confirm that C# is listed in the languages for that choice, then select Next.

  3. In Configure your new project, name your web application project myFirstAzureWebApp, and select Create.

    Configure your web app project

  4. You can deploy any type of ASP.NET Core web app to Azure, but for this quickstart, choose the Web Application template. Make sure Authentication is set to No Authentication, and that no other option is selected. Then, select Create.

    Create a new ASP.NET Core web app

  5. From the Visual Studio menu, select Debug > Start Without Debugging to run your web app locally.

    Web app running locally

Publish your web app

To publish your web app, you must first create and configure a new App Service that you can publish your app to.

As part of setting up the App Service, you'll create:

  • A new resource group to contain all of the Azure resources for the service.
  • A new Hosting Plan that specifies the location, size, and features of the web server farm that hosts your app.

Follow these steps to create your App Service and publish your web app:

  1. In Solution Explorer, right-click the myFirstAzureWebApp project and select Publish. If you haven't already signed-in to your Azure account from Visual Studio, select either Add an account or Sign in. You can also create a free Azure account.

  2. In the Pick a publish target dialog box, choose App Service, select Create New, and then select Create Profile.

    Pick a publish target

  3. In the App Service: Create new dialog, provide a globally unique Name for your app by either accepting the default name, or entering a new name. Valid characters are: a-z, A-Z, 0-9, and -. This Name is used as the URL prefix for your web app in the format http://<app_name>.azurewebsites.net.

  4. For Subscription, accept the subscription that is listed or select a new one from the drop-down list.

  5. In Resource group, select New. In New resource group name, enter myResourceGroup and select OK.

  6. For Hosting Plan, select New.

  7. In the Hosting Plan: Create new dialog, enter the values specified in the following table:

    Setting Suggested Value Description
    Hosting Plan myFirstAzureWebAppPlan Name of the App Service plan.
    Location West Europe The datacenter where the web app is hosted.
    Size Free Pricing tier determines hosting features.

    Create new Hosting Plan

  8. Leave Application Insights set to None.

  9. In the App Service: Create new dialog box, select Create to start creating the Azure resources.

    Create new app service

  10. Once the wizard completes, select Publish.

    Publish web app to Azure

    Visual Studio publishes your ASP.NET Core web app to Azure, and launches the app in your default browser.

    Published ASP.NET web app running in Azure

Congratulations! Your ASP.NET Core web app is running live in Azure App Service.

Update the app and redeploy

Follow these steps to update and redeploy your web app:

  1. In Solution Explorer, under your project, open Pages > Index.cshtml.

  2. Replace the entire <div> tag 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>
  3. To redeploy to Azure, right-click the myFirstAzureWebApp project in Solution Explorer and select Publish.

  4. In the Publish summary page, select Publish.

    Publish update to web app

When publishing completes, Visual Studio launches a browser to the URL of the web app.

Updated ASP.NET web app running in Azure

Manage the Azure app

To manage your web app, go to the Azure portal, and search for and select App Services.

Select App Services

On the App Services page, select the name of your web app.

Screenshot of the App Services page with an example web app selected.

The Overview page for your web app, contains options for basic management like browse, stop, start, restart, and delete. The left menu provides further pages for configuring your app.

App Service in Azure portal

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 Azure portal menu or Home page, select Resource groups. Then, on the Resource groups page, select myResourceGroup.

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

Select Delete resource group, type myResourceGroup in the text box to confirm, and then select Delete.

Next steps

In this quickstart, you used Visual Studio to create and deploy an ASP.NET Core web app to Azure App Service.

Advance to the next article to learn how to create a .NET Core app and connect it to a SQL Database:

App Service on Linux provides a highly scalable, self-patching web hosting service using the Linux operating system. This quickstart shows how to create a .NET Core app on App Service on Linux. You create the app using the Azure CLI, and you use Git to deploy the .NET Core code to the app.

Sample app running in Azure

You can follow the steps in this article using a Mac, Windows, or Linux machine.

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


To complete this quickstart:

Having issues? Let us know.

Create the app locally

In a terminal window on your machine, create a directory named hellodotnetcore and change the current directory to it.

mkdir hellodotnetcore
cd hellodotnetcore

Create a new .NET Core app.

dotnet new web

Run the app locally

Run the application locally so that you see how it should look when you deploy it to Azure.

Restore the NuGet packages and run the app.

dotnet run

Open a web browser, and navigate to the app at http://localhost:5000.

You see the Hello World message from the sample app displayed in the page.

Test with browser

In your terminal window, press Ctrl+C to exit the web server. Initialize a Git repository for the .NET Core project.

git init
git add .
git commit -m "first commit"

Having issues? Let us know.

Use Azure Cloud Shell

Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this article without having to install anything on your local environment.

To start Azure Cloud Shell:

Option Example/Link
Select Try It in the upper-right corner of a code block. Selecting Try It doesn't automatically copy the code to Cloud Shell. Example of Try It for Azure Cloud Shell
Go to https://shell.azure.com, or select the Launch Cloud Shell button to open Cloud Shell in your browser. Launch Cloud Shell in a new window
Select the Cloud Shell button on the menu bar at the upper right in the Azure portal. Cloud Shell button in the Azure portal

To run the code in this article in Azure Cloud Shell:

  1. Start Cloud Shell.

  2. Select the Copy button on a code block to copy the code.

  3. Paste the code into the Cloud Shell session by selecting Ctrl+Shift+V on Windows and Linux or by selecting Cmd+Shift+V on macOS.

  4. Select Enter to run the code.

Having issues? Let us know.

Configure a deployment user

FTP and local Git can deploy to an Azure web app by using a deployment user. Once you configure your deployment user, you can use it for all your Azure deployments. Your account-level deployment username and password are different from your Azure subscription credentials.

To configure the deployment user, run the az webapp deployment user set command in Azure Cloud Shell. Replace <username> and <password> with a deployment user username and password.

  • The username must be unique within Azure, and for local Git pushes, must not contain the ‘@’ symbol.
  • The password must be at least eight characters long, with two of the following three elements: letters, numbers, and symbols.
az webapp deployment user set --user-name <username> --password <password>

The JSON output shows the password 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.

Record your username and password to use to deploy your web apps.

Having issues? Let us know.

Create a resource group

A resource group is a logical container into which Azure resources, such as 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 on Linux in Basic tier, run the az appservice list-locations --sku B1 --linux-workers-enabled 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.

Having issues? Let us know.

Create an Azure App Service plan

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

The following example creates an App Service plan named myAppServicePlan in the Free pricing tier (--sku F1) and in a Linux container (--is-linux).

az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku F1 --is-linux

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": "linux",
  "location": "West Europe",
  "maximumNumberOfWorkers": 1,
  "name": "myAppServicePlan",
  <JSON data removed for brevity.>
  "targetWorkerSizeId": 0,
  "type": "Microsoft.Web/serverfarms",
  "workerTierName": null

Having issues? Let us know.

Create a web app

Create a web app in the myAppServicePlan App Service plan.

In the Cloud Shell, you can use 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 -). The runtime is set to DOTNETCORE|3.1. To see all supported runtimes, run az webapp list-runtimes --linux.

# Bash
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app-name> --runtime "DOTNETCORE|3.1" --deployment-local-git
# PowerShell
az --% webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app-name> --runtime "DOTNETCORE|3.1" --deployment-local-git

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

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

You’ve created an empty web app in a Linux container, with git deployment enabled.


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

Browse to your newly created app. Replace <app-name> with your app name.


Here is what your new app should look like:

Empty app page

Push to Azure from Git

Back in the local terminal window, add an Azure remote to your local Git repository. Replace <deploymentLocalGitUrl-from-create-step> with the URL of the Git remote that you saved from Create a web app.

git remote add azure <deploymentLocalGitUrl-from-create-step>

Push to the Azure remote to deploy your app with the following command. When Git Credential Manager prompts you for credentials, make sure you enter the credentials you created in Configure a deployment user, not the credentials you use to sign in to the Azure portal.

git push azure master

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

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 285 bytes | 95.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Deploy Async
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id 'd6b54472f7'.
remote: Repository path is /home/site/repository
remote: Running oryx build...
remote: Build orchestrated by Microsoft Oryx, https://github.com/Microsoft/Oryx
remote: You can report issues at https://github.com/Microsoft/Oryx/issues
remote: Oryx Version      : 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
remote: Build Operation ID: |imoMY2y77/s=.40ca2a87_
remote: Repository Commit : d6b54472f7e8e9fd885ffafaa64522e74cf370e1
remote: Deployment successful.
remote: Deployment Logs : 'https://<app-name>.scm.azurewebsites.net/newui/jsonviewer?view_url=/api/deployments/d6b54472f7e8e9fd885ffafaa64522e74cf370e1/log'
To https://<app-name>.scm.azurewebsites.net:443/<app-name>.git
   d87e6ca..d6b5447  master -> master

Having issues? Let us know.

Browse to the app

Browse to the deployed application using your web browser.


The .NET Core sample code is running in App Service on Linux with a built-in image.

Sample app running in Azure

Congratulations! You've deployed your first .NET Core app to App Service on Linux.

Having issues? Let us know.

Update and redeploy the code

In the local directory, open the Startup.cs file. Make a small change to the text in the method call context.Response.WriteAsync:

await context.Response.WriteAsync("Hello Azure!");

Commit your changes in Git, and then push the code changes to Azure.

git commit -am "updated output"
git push azure master

Once deployment has completed, switch back to the browser window that opened in the Browse to the app step, and hit refresh.

Updated sample app running in Azure

Having issues? Let us know.

Manage your new Azure app

Go to the Azure portal to manage the app you created.

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

Screenshot of the App Services page showing an example Azure app selected.

You see your 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, delete the resource group by running the following command in the Cloud Shell:

az group delete --name myResourceGroup

This command may take a minute to run.

Having issues? Let us know.

Next steps