Microsoft Azure

Quickstart: Deploy a .NET Web App to Azure App Service

This guide will walk you through the steps to deploy a simple .NET web application to Azure App Service using Visual Studio and the Azure CLI.

Prerequisites

Step 1: Create a New ASP.NET Core Web App

1.1 Open Visual Studio

Launch Visual Studio 2022.

1.2 Create a new project

Click on "Create a new project".

1.3 Select a project template

Search for "ASP.NET Core Web App" and select it. Click "Next".

Visual Studio New Project Template
1.4 Configure your project

Enter a project name (e.g., MyDotNetApp), choose a location, and click "Next".

1.5 Additional information

Select ".NET 7.0 (Long Term Support)" or a later version. Ensure "Use top-level statements" and "Do not use top-level statements" are checked as per your preference. Click "Create".

Step 2: Run the App Locally

2.1 Build and run

Press F5 or click the "Run" button in Visual Studio to build and run your application locally. A browser window will open with your running app.

Step 3: Deploy to Azure App Service

3.1 Right-click the project

In the Solution Explorer, right-click on your project (e.g., MyDotNetApp).

3.2 Publish to Azure

Select "Publish...".

3.3 Choose Target

In the Publish dialog, select "Azure" and then "Azure App Service". Click "Next".

3.4 Select Azure App Service

Choose "Create new".

Visual Studio Azure Publish Target
3.5 Create App Service

Click "Create new..." next to the App Service field.

  • Subscription: Select your Azure subscription.
  • Resource Group: Click "New" and create a new resource group (e.g., rg-dotnet-app-qs).
  • Name: Enter a globally unique name for your app (e.g., my-dotnet-app-unique-name).
  • Operating System: Choose "Linux" or "Windows".
  • Region: Select a region close to you.
  • App Service Plan: Click "New" to create a new App Service plan. Choose a pricing tier (e.g., "F1 Free" for testing, or "B1 Basic" for more features).
Click "OK".

3.6 Finalize and Publish

Once the App Service and plan are created, click "Finish". Visual Studio will prepare the publish profile. Click the "Publish" button.

Step 4: Verify Deployment

4.1 Access your app

After the publish process completes, Visual Studio will automatically open a browser window to your deployed Azure App Service URL (e.g., https://my-dotnet-app-unique-name.azurewebsites.net/).

Tip: You can also manage your App Service through the Azure portal, where you can view logs, scale, and configure various settings.

Next Steps