Skip to content

Commit 7904289

Browse files
committed
updates
1 parent 7bb56e7 commit 7904289

File tree

1 file changed

+62
-100
lines changed

1 file changed

+62
-100
lines changed

articles/app-service/tutorial-sre-agent.md

Lines changed: 62 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ description: Learn how to use Azure SRE Agent and Azure App Service to identify
44
author: msangapu-msft
55
ms.author: msangapu
66
ms.topic: tutorial
7-
ms.date: 05/15/2025
7+
ms.date: 05/18/2025
88
---
99

1010
# Troubleshoot an App Service app using Azure SRE Agent (preview)
1111

1212
> [!NOTE]
13-
> Site Reliability Engineering (SRE) Agent is in preview.
13+
> Site Reliability Engineering (SRE) Agent is in preview. By using SRE Agent you consent the product-specific terms on this page: [Preview Terms Of Use | Microsoft Azure](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
1414
15-
The Azure SRE (Site Reliability Engineering) Agent helps you manage and monitor Azure resources by using AI-enabled capabilities. Agents guide you in solving problems and aid in building resilient, self-healing systems on your behalf. The sample app includes code meant to exhaust memory and cause HTTP 500 errors, so you can diagnose and fix the problem using Azure SRE Agent. By using SRE Agent you consent the product-specific terms on this page: [Preview Terms Of Use | Microsoft Azure](https://azure.microsoft.com/support/legal/preview-supplemental-terms/)
15+
## Introduction
16+
17+
The Azure SRE (Site Reliability Engineering) Agent uses AI to monitor and manage your Azure resources, helping you quickly diagnose and fix issues.
18+
19+
This sample app demonstrates error detection by simulating HTTP 500 failures in a controlled way. You can safely test these scenarios using Azure App Service **deployment slots**, which let you run different app configurations side by side.
20+
21+
You enable error simulation by setting the `INJECT_ERROR` app setting to `1`. When enabled, the app throws an HTTP 500 error after several button clicks, allowing you to see how the SRE Agent responds to application failures.
1622

1723
In this tutorial, you will:
1824

@@ -31,7 +37,7 @@ In this tutorial, you will:
3137

3238
To complete this tutorial, you need:
3339
- An [Azure subscription](https://azure.microsoft.com/free/).
34-
- To create the Azure SRE Agent, your account needs Microsoft.Authorization/roleAssignments/write permissions using either Role Based Access Control Administrator or User Access Administrator.
40+
- Permissions to create role assignments (Role Based Access Control Administrator or User Access Administrator) for SRE Agent setup.
3541

3642
## 1. Create an App Service app
3743

@@ -58,25 +64,15 @@ In the *Basics* tab, provide the following details:
5864
|-----------------|--------------------------------|
5965
| Name | `my-sre-app` |
6066
| Publish | **Code** |
61-
| Runtime stack | **PHP 8.4** |
67+
| Runtime stack | **.NET 9 (STS)** |
68+
| Operating System| **Windows** |
6269
| Region | A region near you |
6370

6471

6572
1. Select the **Deployment** tab.
66-
67-
1. Under *Authentication settings*, enable **Basic authentication**.
68-
69-
> [!NOTE]
70-
> Basic authentication is used later for a one-time deployment from GitHub. In production, [disable Basic Auth](configure-basic-auth-disable.md?tabs=portal) and use secure deployment methods like GitHub Actions or Azure DevOps.
71-
72-
1. Select **Review and create**.
73-
74-
- If validation passes, the **Create** button becomes active.
75-
- If there are errors, tabs with issues are marked with a red dot. Fix the highlighted fields and try again.
76-
77-
1. Select **Create** to deploy the app.
78-
79-
Once deployment completes, you see the message: *Your deployment is complete*.
73+
1. Under *Authentication settings*, enable **Basic authentication**. Basic authentication is used later for a one-time deployment from GitHub. [Disable Basic Auth](configure-basic-auth-disable.md?tabs=portal) in production.
74+
1. Select **Review and create**, then **Create** when validation passes.
75+
1. Once deployment completes, you see *Your deployment is complete*.
8076

8177
## 2. Deploy the sample app
8278

@@ -92,95 +88,73 @@ Now that your App Service app is created, deploy the sample application from Git
9288
|------------|--------------------------------------------------------------|
9389
| Source | **External Git** |
9490
| Repository | `https://github.com/Azure-Samples/App-Service-Agent-Tutorial`|
95-
| Branch | `working` |
91+
| Branch | `main` |
9692

9793
1. Select **Save** to apply the deployment settings.
9894

99-
## 3. Configure the app
100-
101-
Next, configure your app with a startup command and enable logging to support diagnostics with the SRE Agent.
102-
103-
### Set the startup command
104-
105-
The sample app uses NGINX. The default NGINX configuration expects a `50x.html` file in the `/html` directory. The following startup command copies this file from the `wwwroot` directory to the expected location.
106-
107-
1. In the left menu, browse to the *Settings* section and select **Configuration**.
108-
109-
1. Under the *General settings* tab, locate the **Startup Command** field.
110-
111-
1. Enter the following command:
112-
113-
```bash
114-
/home/site/wwwroot/startup.sh
115-
```
116-
117-
1. Select **Save** to apply the changes.
118-
119-
### Enable App Service logs
120-
121-
Enable logging so the SRE Agent can collect diagnostic data from your app.
122-
123-
1. In the left menu, browse to the *Monitoring* section and select **App Service logs**.
95+
## 3. Verify the sample app
12496

125-
1. Configure the following settings:
126-
127-
| Property | Value | Remarks |
128-
|------------------------|-----------------|----------------------------------------|
129-
| Application logging | **File System** | Enables log collection for diagnostics |
130-
| Retention Period (Days)| `3` | Retains logs for 3 days |
131-
132-
1. Select **Save** to apply the logging configuration.
133-
134-
## 4. Verify the sample app
135-
136-
After deployment and configuration, verify that the sample app is running correctly.
97+
After deployment, confirm that the sample app is running as expected.
13798

13899
1. In the left menu of your App Service, select **Overview**.
100+
2. Select **Browse** to open the app in a new browser tab. (It may take a minute to load.)
101+
1. The app displays a large counter and two buttons:
139102

140-
1. Select **Browse** to open the app in a new browser tab. It may take a minute to load as Azure App Service initializes the app on the first request.
141-
142-
1. Once the app loads, select **Tools** in the app’s navigation bar and select **Convert to PNG**.
143-
144-
![Select Tools and select Convert to PNG](./media/tutorial-azure-monitor/sample-monitor-app-tools-menu.png)
103+
| Button Name | Description |
104+
|------------------------------|---------------------------------------------------------------------------------------------------|
105+
| **Refresh / Throw Exception**| Increments the counter. If error simulation (`INJECT_ERROR` app setting) is enabled, throws an error after a set number of clicks. |
106+
| **Reset Counter** | Resets the counter to zero. |
145107

146-
1. Select the first three images and select **Convert**. The conversion should complete successfully.
108+
1. Click the main button several times to observe the counter increase, and verify error behavior if enabled.
147109

148-
![Select the first two images](./media/tutorial-azure-monitor/sample-monitor-app-convert-two-images.png)
149110

150-
## 5. Create a deployment slot
111+
## 4. Set up a deployment slot for failure simulation
151112

152-
To simulate a failure scenario, create a secondary deployment slot.
113+
To simulate an app failure scenario, add a secondary deployment slot.
153114

154115
1. In the left menu of your App Service, under the *Deployment* section, select **Deployment slots**.
155-
156116
1. Select **Add slot**.
117+
1. Enter the following values:
157118

158-
1. Enter the following values.
119+
| Property | Value | Remarks |
120+
|---------------------|--------------|------------------------------------------------------------------------------------------|
121+
| Name | `broken` | The error scenario will be triggered in this slot. |
122+
| Clone settings from | `my-sre-app` | Copies configuration from the main app. |
159123

124+
1. Scroll to the bottom of the dialog window and select **Add**. Slot creation may take a minute to complete.
160125

161-
| Property           | Value         | Remarks                          |
162-
|--------------------|---------------|----------------------------------|
163-
| Name               | `broken`      | Name of the slot to simulate failure |
164-
| Clone settings from| `my-sre-app`  | Copies configuration from the main app |
126+
### Deploy the sample app to the slot
165127

128+
1. Once the slot is created, select the **broken** slot from the list.
129+
1. In the left menu, under the *Deployment* section, select **Deployment Center**.
130+
1. In the *Settings* tab, configure the following:
166131

167-
1. Scroll to the bottom of the dialog window and select **Add**. The slot creation process may take a minute to complete.
132+
| Property | Value |
133+
|------------|---------------------------------------------------------------|
134+
| Source | **External Git** |
135+
| Repository | `https://github.com/Azure-Samples/App-Service-Agent-Tutorial` |
136+
| Branch | `broken` |
168137

169-
### Configure the deployment slot
138+
1. Select **Save** to apply the deployment settings.
170139

171-
1. After the slot is created, select the **broken** slot from the list.
140+
## 5. Add an app setting to enable error simulation
172141

173-
1. In the left menu, under the *Deployment* section, select **Deployment Center**.
142+
To control error simulation, configure an app setting your app checks at runtime.
174143

175-
In the *Settings* tab, configure the following:
144+
1. In the left menu of your App Service, select **Environment variables** under the *Settings* section.
145+
1. At the top, make sure you have the correct slot selected (for example, **broken**).
146+
1. Under the **App settings** tab, select **+ Add**.
147+
1. Enter the following values:
176148

177-
| Property | Value |
178-
|------------|--------------------------------------------------------------|
179-
| Source | **External Git** |
180-
| Repository | `https://github.com/Azure-Samples/App-Service-Agent-Tutorial`|
181-
| Branch | `broken` |
149+
| Property | Value | Remarks |
150+
|------------|---------------|--------------------------------------------------------------|
151+
| Name | `INJECT_ERROR`| Must be exactly `INJECT_ERROR` (all caps, no spaces). |
152+
| Value | `1` | Enables error simulation in the app. |
182153

183-
1. Select **Save** to apply the deployment settings.
154+
1. Make sure the **Deployment slot setting** box is **not** checked.
155+
1. Select **Apply** to add the setting.
156+
1. At the bottom of the *Environment variables* page, select **Apply** to apply the changes.
157+
1. When prompted, select **Confirm** to confirm and restart the app in the selected slot.
184158

185159
## 6. Create an Azure SRE Agent
186160

@@ -206,9 +180,7 @@ Now, create an Azure SRE Agent to monitor your App Service app.
206180

207181
1. Select **Save**.
208182

209-
1. Back in the *Create agent* window, select **Create**.
210-
211-
> The agent creation process may take a few minutes to complete.
183+
1. Back in the *Create agent* window, select **Create**. The agent creation process may take a few minutes to complete.
212184

213185
## 7. Chat with your agent
214186

@@ -249,15 +221,11 @@ Now simulate a failure scenario by swapping to the broken deployment slot.
249221
250222
1. Once the swap is complete, browse to the app’s URL.
251223
252-
1. Attempt to convert five images using the app interface:
253-
254-
![Select the first five images](./media/tutorial-azure-monitor/sample-monitor-app-working.png)
224+
1. Select the "Throw Exception" button several times and then refresh the page (using Command-R or F5 button).
255225
256-
1. The conversion should fail and return an HTTP 500 error:
257-
258-
![HTTP 500](./media/tutorial-azure-monitor/sample-monitor-app-http-500.png)
226+
1. You should see the app fail and return an HTTP 500 error.
259227
260-
1. Repeat the conversion step a few more times to generate additional HTTP 500 errors. These errors help the SRE Agent detect and diagnose the issue.
228+
1. Refresh the page a few more times to generate additional HTTP 500 errors, which will help the SRE Agent detect and diagnose the issue.
261229
262230
## 9. Fix the app
263231
@@ -303,13 +271,7 @@ After the SRE Agent rolls back the slot swap, confirm that your app is functioni
303271
304272
1. Open your App Service app in a browser by selecting **Browse** from the **Overview** page.
305273
306-
1. In the app interface, select **Tools** in the navigation bar and select **Convert to PNG**.
307-
308-
    ![Select Tools and select Convert to PNG](./media/tutorial-azure-monitor/sample-monitor-app-tools-menu.png)
309-
310-
1. Select all the images and select **Convert**. The conversion should now complete successfully without HTTP 500 errors.
311-
312-
    ![Select the first five images](./media/tutorial-azure-monitor/sample-monitor-app-working.png)
274+
1. Notice the "Throw Exception" button no longer appears and it's been replaced with a "Refresh" button.
313275
314276
## Clean up resources
315277

0 commit comments

Comments
 (0)