Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
191 lines (131 sloc) 6.4 KB
title description keywords services documentationCenter author manager editor ms.assetid ms.service ms.workload ms.tgt_pltfrm ms.devlang ms.topic ms.date ms.author ms.custom
Create ASP.NET Core app on Linux - Azure App Service | Microsoft Docs
Deploy your first .NET Core Hello World app to App Service on Linux in minutes.
azure app service, web app, dotnet, core, linux, oss
app-service
cephalin
jeconnoc
c02959e6-7220-496a-a417-9b2147638e2e
app-service
web
linux
na
quickstart
03/27/2019
cephalin
seodec18

Create an ASP.NET Core app in App Service on Linux

[!NOTE] This article deploys an app to App Service on Linux. To deploy to App Service on Windows, see Create an ASP.NET Core app in Azure.

App Service on Linux provides a highly scalable, self-patching web hosting service using the Linux operating system. This quickstart shows how to create a .NET Core app on App Service on Linux. You create the app using the Azure CLI, and you use Git to deploy the .NET Core code to the app.

Sample app running in Azure

You can follow the steps in this article using a Mac, Windows, or Linux machine.

[!INCLUDE quickstarts-free-trial-note]

Prerequisites

To complete this quickstart:

Create the app locally

In a terminal window on your machine, create a directory named hellodotnetcore and change the current directory to it.

mkdir hellodotnetcore
cd hellodotnetcore

Create a new .NET Core app.

dotnet new web

Run the app locally

Run the application locally so that you see how it should look when you deploy it to Azure.

Restore the NuGet packages and run the app.

dotnet run

Open a web browser, and navigate to the app at http://localhost:5000.

You see the Hello World message from the sample app displayed in the page.

Test with browser

In your terminal window, press Ctrl+C to exit the web server. Initialize a Git repository for the .NET Core project.

git init
git add .
git commit -m "first commit"

[!INCLUDE cloud-shell-try-it.md]

[!INCLUDE Configure deployment user]

[!INCLUDE Create resource group]

[!INCLUDE Create app service plan]

Create a web app

[!INCLUDE Create web app]

Browse to your newly created app. Replace <app name> with your app name.

http://<app name>.azurewebsites.net

Here is what your new app should look like:

Empty app page

[!INCLUDE Push to Azure]

Counting objects: 22, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (22/22), 51.21 KiB | 3.94 MiB/s, done.
Total 22 (delta 1), reused 0 (delta 0)
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '741f16d1db'.
remote: Generating deployment script.
remote: Project file path: ./hellodotnetcore.csproj
remote: Generated deployment script files
remote: Running deployment command...
remote: Handling ASP.NET Core Web Application deployment.
remote: ...............................................................................................
remote:   Restoring packages for /home/site/repository/hellodotnetcore.csproj...
remote: ....................................
remote:   Installing System.Xml.XPath 4.0.1.
remote:   Installing System.Diagnostics.Tracing 4.1.0.
remote:   Installing System.Threading.Tasks.Extensions 4.0.0.
remote:   Installing System.Reflection.Emit.ILGeneration 4.0.1.
remote:   ...
remote: Finished successfully.
remote: Running post deployment command(s)...
remote: Deployment successful.
To https://cephalin-dotnetcore.scm.azurewebsites.net/cephalin-dotnetcore.git
 * [new branch]      master -> master

Browse to the app

Browse to the deployed application using your web browser.

http://<app_name>.azurewebsites.net

The .NET Core sample code is running in App Service on Linux with a built-in image.

Sample app running in Azure

Congratulations! You've deployed your first .NET Core app to App Service on Linux.

Update and redeploy the code

In the local directory, open the Startup.cs file. Make a small change to the text in the method call context.Response.WriteAsync:

await context.Response.WriteAsync("Hello Azure!");

Commit your changes in Git, and then push the code changes to Azure.

git commit -am "updated output"
git push azure master

Once deployment has completed, switch back to the browser window that opened in the Browse to the app step, and hit refresh.

Updated sample app running in Azure

Manage your new Azure app

Go to the Azure portal to manage the app you created.

From the left menu, click App Services, and then click the name of your Azure app.

Portal navigation to Azure app

You see your app's Overview page. Here, you can perform basic management tasks like browse, stop, start, restart, and delete.

App Service page in Azure portal

The left menu provides different pages for configuring your app.

[!INCLUDE cli-samples-clean-up]

Next steps

[!div class="nextstepaction"] Tutorial: ASP.NET Core app with SQL Database

[!div class="nextstepaction"] Configure ASP.NET Core app

You can’t perform that action at this time.