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 (An HTTP-based service for hosting web applications, REST APIs, and mobile back-end applications.). App Service supports .NET 5.0 apps.
When you're finished, you'll have an Azure resource group (A logical container for related Azure resources that you can manage as a unit.) consisting of an App Service plan (The plan that specifies the location, size, and features of the web server farm that hosts your app.) and on App Service app (The representation of your web app, which contains your app code, DNS hostnames, certificates, and related resources.) with a deployed sample ASP.NET Core application.
1. Prepare your environment
- Get an Azure account with an active subscription (The basic organizational structure in which you manage resources in Azure, typically associated with an individual or department within an organization.). Create an account for free.
- Install Visual Studio 2019 with the ASP.NET and web development workload.
Already have Visual Studio 2019?If you've installed Visual Studio 2019 already:
- Install the latest updates in Visual Studio by selecting Help > Check for Updates. The latest updates contain the .NET 5.0 SDK.
- Add the workload by selecting Tools > Get Tools and Features.
2. Create an ASP.NET Core web app
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.
For a .NET 5.0 app, select ASP.NET Core 5.0 in the dropdown. Otherwise, use the default value.
You can deploy any type of ASP.NET Core web app to Azure, but for this quickstart, choose the ASP.NET Core Web App 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.
3. Publish your web app
In Solution Explorer, right-click the myFirstAzureWebApp project and select Publish.
In Publish, select Azure and select Next.
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.
To the right of App Service instances, select +.
For Subscription, accept the subscription that is listed or select a new one from the drop-down list.
For 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 Hosting Plan myFirstAzureWebAppPlan Location West Europe Size Free
In Name, enter a unique app name.
Which characters can I use?Valid characters are a-z, A-Z, 0-9, and -. You can accept the automatically generated unique name. The URL of the web app is http://
<app-name>is your app name.
Select Create to create the Azure resources.
Wait for the wizard to finish creating Azure resources. Select Finish to close the wizard.
In the Publish page, select Publish to deploy your project.
What's Visual Studio doing?Visual Studio builds, packages, and publishes the app to Azure, and then launches the app in the default browser.
4. Update the app and redeploy
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.
5. Manage the Azure 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.
6. Clean up resources
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.
Advance to the next article to learn how to create a .NET Core app and connect it to a SQL Database:
This quickstart shows how to create a .NET Core app on App Service on Linux (App Service on Linux provides a highly scalable, self-patching web hosting service using the Linux operating system.). You create the app using the Azure CLI, and you use Git to deploy the .NET Core code to the app.
1. Prepare your environment
- Get an Azure account with an active subscription. Create an account for free.
- Install the latest .NET Core 3.1 SDK or .NET 5.0 SDK.
- Install the latest Azure CLI.
2. Create the app locally
mkdir hellodotnetcoreto create the directory.
cd hellodotnetcoreto change the directory.
dotnet new webto create a new .NET Core app.
dotnet new web
3. Run the app locally
dotnet runto see how it looks when you deploy it to Azure.
Open a web browser, and navigate to the app at
4. Sign into Azure
az login to sign into Azure.
5. Deploy the app
az webapp upin your local folder. Replace <app-name> with a globally unique name.
az webapp up --sku F1 --name <app-name> --os-type linux
- If the
azcommand isn't recognized, be sure you have the Azure CLI installed as described in Prepare your environment.
<app-name>with a name that's unique across all of Azure (valid characters are
-). A good pattern is to use a combination of your company name and an app identifier.
--sku F1argument creates the web app on the Free pricing tier. Omit this argument to use a faster premium tier, which incurs an hourly cost.
- You can optionally include the argument
<location-name>is an available Azure region. You can retrieve a list of allowable regions for your Azure account by running the
az account list-locationscommand.
- If the
Wait for the command to complete. It may take a few minutes, and ends with "You can launch the app at http://<app-name>.azurewebsites.net".
az webapp updoing?
az webapp upcommand does the following actions:
6. Browse to the app
Browse to the deployed application using your web browser.
7. Update and redeploy the code
Open the Startup.cs file in the local directory.
Make a small change to the text in the method call
await context.Response.WriteAsync("Hello Azure!");
Save your changes.
az webapp upto redeploy:
az webapp up --os-type linux
What'sThe first time you ran the command, it saved the app name, resource group, and App Service plan in the .azure/config file from the project root. When you run it again from the project root, it uses the values saved in .azure/config, detects that the App Service resources already exist, and performs Zip deploy again.
az webapp updoing this time?
Once deployment has completed, hit refresh in the browser window that previously opened.
8. Manage your new Azure app
Go to the Azure portal.
From the left menu, select App Services, and then select the name of your Azure app.
The Overview page is where you can perform basic management tasks like browse, stop, start, restart, and delete. The left menu provides different pages for configuring your app.
9. Clean up resources
az group delete --name myResourceGroup to delete the resource group.
az group delete --name myResourceGroup