text
stringlengths
0
13.4k
the server you've been using every time you ran dotnet run and
browsed to http://localhost:5000 . When you deploy your application
to a production environment, it'll still use Kestrel behind the scenes.
However, it's recommended that you put a reverse proxy in front of
Kestrel, because Kestrel doesn't yet have load balancing and other
features that more mature web servers have.
On Linux (and in Docker containers), you can use Nginx or the Apache
web server to receive incoming requests from the internet and route
them to your application hosted with Kestrel. If you're on Windows, IIS
does the same thing.
If you're using Azure to host your application, this is all done for you
automatically. I'll cover setting up Nginx as a reverse proxy in the Docker
section.
113
Deploy to Azure
Deploy to Azure
Deploying your ASP.NET Core application to Azure only takes a few
steps. You can do it through the Azure web portal, or on the command
line using the Azure CLI. I'll cover the latter.
What you'll need
Git (use git --version to make sure it's installed)
The Azure CLI (follow the install instructions at
https://github.com/Azure/azure-cli)
An Azure subscription (the free subscription is fine)
A deployment configuration file in your project root
Create a deployment configuration file
Since there are multiple projects in your directory structure (the web
application, and two test projects), Azure won't know which one to
publish. To fix this, create a file called .deployment at the very top of
your directory structure:
.deployment
[config]
project = AspNetCoreTodo/AspNetCoreTodo.csproj
Make sure you save the file as .deployment with no other parts to the
name. (On Windows, you may need to put quotes around the filename,
like ".deployment" , to prevent a .txt extension from being added.)
If you ls or dir in your top-level directory, you should see these
items:
114
Deploy to Azure
.deployment
AspNetCoreTodo
AspNetCoreTodo.IntegrationTests
AspNetCoreTodo.UnitTests
Set up the Azure resources
If you just installed the Azure CLI for the first time, run
az login
and follow the prompts to log in on your machine. Then, create a new
Resource Group for this application:
az group create -l westus -n AspNetCoreTodoGroup