You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#customer intent: As an app designer, I want to learn how to configure my ASP.NET Core app to use Azure App Service.
11
12
---
12
13
13
14
# Configure an ASP.NET Core app for Azure App Service
@@ -17,7 +18,7 @@ ms.author: cephalin
17
18
18
19
ASP.NET Core apps must be deployed to Azure App Service as compiled binaries. The Visual Studio publishing tool builds the solution and then deploys the compiled binaries directly. The App Service deployment engine deploys the code repository first and then compiles the binaries.
19
20
20
-
This guide provides key concepts and instructions for ASP.NET Core developers. If this is your first time using Azure App Service, first follow the [ASP.NET Core quickstart](quickstart-dotnetcore.md) and [ASP.NET Core with SQL Database tutorial](tutorial-dotnetcore-sqldb-app.md).
21
+
This guide provides key concepts and instructions for ASP.NET Core developers. If this article is your first time using Azure App Service, first follow [Deploy an ASP.NET web app](quickstart-dotnetcore.md) and [Deploy an ASP.NET Core and Azure SQL Database app to Azure App Service](tutorial-dotnetcore-sqldb-app.md).
21
22
22
23
::: zone pivot="platform-windows"
23
24
@@ -55,7 +56,7 @@ az webapp list-runtimes --os linux | grep DOTNET
55
56
56
57
## Set .NET Core version
57
58
58
-
::: zone pivot="platform-windows"
59
+
::: zone pivot="platform-windows"
59
60
60
61
Set the target framework in the project file for your ASP.NET Core project. For more information, see [Select the .NET Core version to use](/dotnet/core/versions/selection).
61
62
@@ -128,7 +129,7 @@ namespace SomeNamespace
128
129
}
129
130
```
130
131
131
-
If you configure an app setting with the same name in App Service and in `appsettings.json`, for example, the App Service value takes precedence over the `appsettings.json` value. By using the local `appsettings.json` value, you can debug the app locally, but by using the App Service value, you can run the app in production with production settings. Connection strings work the same way. By using this method, you can keep your application secrets outside your code repository and access the appropriate values without changing your code.
132
+
If you configure an app setting with the same name in App Service and in `appsettings.json`, the App Service value takes precedence over the `appsettings.json` value. By using the local `appsettings.json` value, you can debug the app locally. By using the App Service value, you can run the app in production with production settings. Connection strings work the same way. By using this method, you can keep your application secrets outside your code repository and access the appropriate values without changing your code.
132
133
133
134
> [!NOTE]
134
135
> You can also consider more secure connectivity options that don't require connection secrets. For more information, see [Secure connectivity to Azure services and databases from Azure App Service](tutorial-connect-overview.md).
@@ -154,7 +155,7 @@ az webapp config appsettings set --name <app-name> --resource-group <resource-gr
154
155
155
156
## Deploy multi-project solutions
156
157
157
-
When a Visual Studio solution includes multiple projects, the Visual Studio publish process automatically selects the project to deploy. When you deploy to the App Service deployment engine, such as with Git, or with ZIP deploy [with build automation enabled](deploy-zip.md#enable-build-automation-for-zip-deploy), the App Service deployment engine picks the first website or web application project that it finds as the App Service app. You can specify which project App Service should use by specifying the `PROJECT` app setting. For example, run the following command in [Cloud Shell](https://shell.azure.com):
158
+
When a Visual Studio solution includes multiple projects, the Visual Studio publish process selects the project to deploy. When you deploy to the App Service deployment engine, such as with Git, or with ZIP deploy [with build automation enabled](deploy-zip.md#enable-build-automation-for-zip-deploy), the App Service deployment engine picks the first website or web application project that it finds as the App Service app. You can specify which project App Service should use by specifying the `PROJECT` app setting. For example, run the following command in [Cloud Shell](https://shell.azure.com):
158
159
159
160
```azurecli-interactive
160
161
az webapp config appsettings set --resource-group <resource-group-name> --name <app-name> --settings PROJECT="<project-name>/<project-name>.csproj"
@@ -177,23 +178,23 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
177
178
});
178
179
```
179
180
180
-
You can then configure and generate logs with the [standard .NET Core pattern](/aspnet/core/fundamentals/logging).
181
+
You can then configure and generate logs with the standard .NET Core pattern. See [Logging in .NET Core and ASP.NET Core](/aspnet/core/fundamentals/logging).
For more information on troubleshooting ASP.NET Core apps in App Service, see [Troubleshoot ASP.NET Core on Azure App Service and IIS](/aspnet/core/test/troubleshoot-azure-iis).
185
186
186
187
## Access a detailed exceptions page
187
188
188
-
When your ASP.NET Core app generates an exception in the Visual Studio debugger, the browser displays a detailed exception page, but in App Service that page is replaced by a generic "HTTP 500" or "An error occurred while processing your request." To display the detailed exception page in App Service, add the `ASPNETCORE_ENVIRONMENT` app setting to your app by running the following command in <atarget="_blank"href="https://shell.azure.com" >Cloud Shell</a>.
189
+
When your ASP.NET Core app generates an exception in the Visual Studio debugger, the browser displays a detailed exception page. In App Service, a generic "HTTP 500" or "An error occurred while processing your request" message replaces that page. To display the detailed exception page in App Service, add the `ASPNETCORE_ENVIRONMENT` app setting to your app by running the following command in <atarget="_blank"href="https://shell.azure.com" >Cloud Shell</a>.
189
190
190
191
```azurecli-interactive
191
192
az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings ASPNETCORE_ENVIRONMENT="Development"
192
193
```
193
194
194
195
## Detect HTTPS session
195
196
196
-
In App Service, [TLS/SSL termination](https://wikipedia.org/wiki/TLS_termination_proxy) happens at the network load balancers, so all HTTPS requests reach your app as unencrypted HTTP requests. If your app logic needs to know if user requests are encrypted, configure the Forwarded Headers Middleware in `Startup.cs`:
197
+
In App Service, [TLS termination](https://wikipedia.org/wiki/TLS_termination_proxy) happens at the network load balancers. All HTTPS requests reach your app as unencrypted HTTP requests. If your app logic needs to know if user requests are encrypted, configure the Forwarded Headers Middleware in `Startup.cs`:
197
198
198
199
- Configure the middleware with [`ForwardedHeadersOptions`](/dotnet/api/microsoft.aspnetcore.builder.forwardedheadersoptions) to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers in `Startup.ConfigureServices`.
199
200
- Add private IP address ranges to the known networks, so that the middleware can trust the App Service load balancer.
@@ -245,12 +246,12 @@ To rewrite or redirect a URL, use the [URL-rewriting middleware in ASP.NET Core]
245
246
246
247
## Related content
247
248
248
-
*[Tutorial: ASP.NET Core app with SQL Database](tutorial-dotnetcore-sqldb-app.md)
249
+
-[Tutorial: Deploy an ASP.NET Core and Azure SQL Database app](tutorial-dotnetcore-sqldb-app.md)
249
250
250
251
::: zone pivot="platform-linux"
251
252
252
-
*[App Service Linux FAQ](faq-app-service-linux.yml)
253
+
-[Azure App Service on Linux FAQ](faq-app-service-linux.yml)
253
254
254
255
::: zone-end
255
256
256
-
*[Environment variables and app settings reference](reference-app-settings.md)
257
+
-[Environment variables and app settings reference](reference-app-settings.md)
0 commit comments