Skip to content

Commit 5307c8b

Browse files
authored
Merge pull request #288217 from jeffwmartinez/jefmarti-error-pages
configure error pages
2 parents 941649e + ba8ef3a commit 5307c8b

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Configure error pages on App Service
3+
description: Learn how to configure a custom error page on App Service
4+
author: jefmarti
5+
ms.topic: how-to
6+
ms.custom: linux-related-content
7+
ms.date: 10/14/2024
8+
ms.author: jefmarti
9+
---
10+
11+
# Configure error pages on App Service (preview)
12+
13+
This article explains how to configure custom error pages on your web app. With App Service you can configure an error page for specific errors that will be presented to users instead of the default error page.
14+
15+
### Prerequisite
16+
In this tutorial, we're adding a custom 403 error page to our web app hosted on App Service and test it with an IP restriction. To do so, you need the following:
17+
- a web app hosted on App Service w/ a Premium SKU
18+
- an html file under 10 kb in size
19+
20+
## Upload an error page
21+
For this example, we're uploading and testing a 403 error page to present to the user. Name your html file to match the error code (for example, `403.hmtl`). Once you have your html file prepared, you can upload it to your web app. In the configuration blade, you should see an **Error pages (preview)** tab. Click on this tab to view the error page options. If the options are greyed out, you need to upgrade to at least a Premium SKU to use this feature.
22+
23+
Select the error code that you'd like to upload an error page for and click **Edit**. On the next screen, click the folder icon to select your html file. The file must be in html format and within the 10 kb size limit. Find your .html file and click on the **Upload** button at the bottom of the screen. Notice the Status in the table updates from Not Configured to Configured. Then click **Save** to complete the upload.
24+
25+
## Confirm error page
26+
Once the custom error page is uploaded and saved, we can trigger and view the page. In this example, we can trigger the 403 error by using an IP restriction.
27+
28+
To set an IP restriction, go to the **Networking** blade and click the **Enabled with access restrictions** link under **Inbound traffic configuration**.
29+
30+
Under the **Site access and rules** section, select the **+Add** button to create an IP restriction.
31+
32+
In the form that follows, you need to change the Action to **Deny** and fill out the **Priority** and **IP Address Block**. In this example, we use the **Inbound address** found on the Networking blade and we're setting it to /0 (for example, `12.123.12.123/0`). This disables all public access when visiting the site.
33+
34+
Once the Add rule form is filled out, select the **Add rule** button. Then click **Save**.
35+
36+
Once saved, you need to restart the site for the changes to take effect. Go to your overview page and select **browse**. You should now see your custom error page load.
37+
38+
## Error codes
39+
App Service currently supports three types of error codes that are available to customize:
40+
41+
| Error code | description |
42+
| ------------- | ------------- |
43+
| 403 | Access restrictions |
44+
| 502 | Gateway errors |
45+
| 503 | Service unavailable |
46+
47+
## FAQ
48+
1. I've uploaded my error page, why doesn't it show when the error is triggered?
49+
50+
Currently, error pages are only triggered when the error is coming from the front end. Errors that get triggered at the app level should still be handled through the app.
51+
52+
2. Why is the error page feature greyed out?
53+
54+
Error pages are currently a Premium feature. You need to use at least a Premium SKU to enable the feature.

articles/app-service/includes/deploy-intelligent-apps/deploy-intelligent-apps-linux-dotnet-pivot.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ For OpenAI, see this [documentation](https://platform.openai.com/docs/api-refere
7575
- `apiKey`
7676
- `modelId`
7777

78-
Since we are deploying to App Service, we can secure these secrets in **Azure Key Vault** for protection. Follow the [Quickstart](/azure/key-vault/secrets/quick-create-cli#create-a-key-vault) to set up your Key Vault and add the secrets you saved from earlier.
78+
Since we're deploying to App Service, we can secure these secrets in **Azure Key Vault** for protection. Follow the [Quickstart](/azure/key-vault/secrets/quick-create-cli#create-a-key-vault) to set up your Key Vault and add the secrets you saved from earlier.
7979
Next, we can use Key Vault references as app settings in our App Service resource to reference in our application. Follow the instructions in the [documentation](../../app-service-key-vault-references.md?source=recommendations&tabs=azure-cli) to grant your app access to your Key Vault and to set up Key Vault references.
8080
Then, go to the portal Environment Variables blade in your resource and add the following app settings:
8181

@@ -190,11 +190,11 @@ var kernel = builder.Build();
190190

191191
### Secure your app with managed identity
192192

193-
If youre using Azure OpenAI, it's highly recommended to secure your application using [managed identity](../../overview-managed-identity.md) to authenticate your app to your Azure OpenAI resource. This enables your application to access the Azure OpenAI resource without needing to manage API keys. If you're not using Azure OpenAI, your secrets can remain secure using Azure Key Vault outlined above.
193+
If you're using Azure OpenAI, it's highly recommended to secure your application using [managed identity](../../overview-managed-identity.md) to authenticate your app to your Azure OpenAI resource. This enables your application to access the Azure OpenAI resource without needing to manage API keys. If you're not using Azure OpenAI, your secrets can remain secure using Azure Key Vault outlined above.
194194

195195
Follow the steps below to secure your application with managed identity:
196196

197-
Add the identity package `Azure.Identity`. This package enables using Azure credentials in your app. Install the package using Nuget package manager and add the using statement to the top of the OpenAI.razor file.
197+
Add the identity package `Azure.Identity`. This package enables using Azure credentials in your app. Install the package using NuGet package manager and add the using statement to the top of the OpenAI.razor file.
198198

199199
```c#
200200
@using Azure.Identity
@@ -215,7 +215,7 @@ var kernel = Kernel.CreateBuilder()
215215
Once the credentials are added to the application, you'll then need to enable managed identity in your application and grant access to the resource.
216216

217217
1. In your web app resource, navigate to the **Identity** blade and turn on **System assigned** and click **Save**
218-
2. Once System assigned identity is turned on, it register's the web app with Microsoft Entra ID and the web app can be granted permissions to access protected resources.
218+
2. Once System assigned identity is turned on, it registers the web app with Microsoft Entra ID and the web app can be granted permissions to access protected resources.
219219
3. Go to your Azure OpenAI resource and navigate to the **Access control (IAM)** blade on the left pane.
220220
4. Find the Grant access to this resource card and click on **Add role assignment**
221221
5. Search for the **Cognitive Services OpenAI User** role and click **Next**

articles/app-service/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
- name: Use settings from App Configuration
4242
href: app-service-configuration-references.md
4343
- name: App settings reference
44-
href: reference-app-settings.md
44+
href: reference-app-settings.md
45+
- name: Configure error pages
46+
href: configure-error-pages.md
4547
- name: Configure specific languages
4648
items:
4749
- name: Configure ASP.NET

0 commit comments

Comments
 (0)