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.
Azure App Service provides a highly scalable, self-patching web hosting service.
This quickstart shows how to deploy your first ASP.NET Core web app to Azure App Service. When you're finished, you'll have a resource group that consists of an App Service plan and an App Service app with a deployed web application.
To complete this tutorial, 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 by following these steps:
Open Visual Studio and then select Create a new project.
In Create a new project, find and choose ASP.NET Core Web Application for C#, then select Next.
In Configure your new project, name the application myFirstAzureWebApp, and then select Create.
For this quickstart, choose the Web Application template. Make sure authentication is set to No Authentication and no other option is selected. Select Create.
You can deploy any type of ASP.NET Core web app to Azure.
From the Visual Studio menu, select Debug > Start Without Debugging to run the web app locally.
Publish your web app
In Solution Explorer, right-click the myFirstAzureWebApp project and select Publish.
Choose App Service and then select Publish.
In App Service Create new, your options depend on whether you're signed in to Azure already and whether you have a Visual Studio account linked to an Azure account. Select either Add an account or Sign in to sign in to your Azure subscription. If you're already signed in, select the account you want.
If you're already signed in, don't select Create yet.
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.
For Resource group, select New.
In New resource group name, enter myResourceGroup and select OK.
An App Service plan specifies the location, size, and features of the web server farm that hosts your app. You can save money when hosting multiple apps by configuring the web apps to share a single App Service plan.
App Service plans define:
- Region (for example: North Europe, East US, or Southeast Asia)
- Instance size (small, medium, or large)
- Scale count (1 to 20 instances)
- SKU (Free, Shared, Basic, Standard, or Premium)
For to Hosting Plan, select New.
In the Configure Hosting Plan dialog, enter the values from the following table, and then select OK.
Setting Suggested Value Description App Service Plan myAppServicePlan Name of the App Service plan. Location West Europe The datacenter where the web app is hosted. Size Free Pricing tier determines hosting features.
In Name, enter a unique app name that includes only the valid characters are
-. You can accept the automatically generated unique name. The URL of the web app is
<app_name>is your app name.
Select Create to start creating the Azure resources.
Once the wizard completes, it publishes the ASP.NET Core web app to Azure, and then launches the app in the default browser.
The app name specified in the App Service Create new page is used as the URL prefix in the format
Congratulations! Your ASP.NET Core web app is running live in Azure App Service.
Update the app and redeploy
In Solution Explorer, under your project, open Pages > Index.cshtml.
Replace the two
<div>tags 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>
To redeploy to Azure, right-click the myFirstAzureWebApp project in Solution Explorer and select Publish.
In the Publish summary page, select Publish.
When publishing completes, Visual Studio launches a browser to the URL of the web app.
Manage the Azure 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 app.
You see your web app's Overview page. Here, you can do basic management like browse, stop, start, restart, and delete.
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.
Laster inn tilbakemelding ...