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.

Prerequisites

  • 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 on Linux.

  • 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>
    </div>
    
  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.

Portal navigation to Azure app

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, and 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: