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 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:
Open Visual Studio and select Create a new project.
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.
In Configure your new project, name your web application project myFirstAzureWebApp, and select Create.
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.
From the Visual Studio menu, select Debug > Start Without Debugging to run your web app 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:
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.
In the Pick a publish target dialog box, choose App Service, select Create New, and then select Create Profile.
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:
-. This Name is used as the URL prefix for your web app in the format
For Subscription, accept the subscription that is listed or select a new one from the drop-down list.
In Resource group, select New. In New resource group name, enter myResourceGroup and select OK.
For Hosting Plan, select New.
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.
Leave Application Insights set to None.
In the App Service: Create new dialog box, select Create to start creating the Azure resources.
Once the wizard completes, select Publish.
Visual Studio publishes your ASP.NET Core web app to Azure, and launches the app in your default browser.
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:
In Solution Explorer, under your project, open Pages > Index.cshtml.
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>
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
To manage your web app, go to the Azure portal, and search for and select App Services.
On the App Services page, select the name of your web 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.
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.
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:
Want to optimize and save on your cloud spending?