* **Access to Sweden Central region**: During preview, the only allowed region for SRE Agent is Sweden Central. Make sure your user account has *owner* or *admin* permissions and permissions to create resources in the Sweden Central region.
## 1. Create an App Service app
Start by creating a web app that the SRE Agent can monitor.
1. Sign in to the https://portal.azure.com.
1. In the top search bar, search for **App Services**, then select it from the results.
1. Select **+ Create** and choose **Web App**.
### Configure the Basics tab
In the *Basics* tab, provide the following details:
**Project details**
| Setting | Value |
|-----------------|--------------------------------|
| Subscription | Your Azure subscription |
| Resource group | **Create new** → `my-app-service-group` |
**Instance details**
| Setting | Value |
|-----------------|--------------------------------|
| Name | `my-sre-app` |
| Publish | **Code** |
| Runtime stack | **.NET 9 (STS)** |
| Operating System| **Windows** |
| Region | A region near you |
1. Select the **Deployment** tab.
1. Under *Authentication settings*, enable **Basic authentication**.
> [!NOTE]
> Basic authentication is used later for a one-time deployment from GitHub. [Disable basic auth](/azure/app-service/configure-basic-auth-disable?tabs=portal) in production.
>
1. Select **Review and create**, then **Create** when validation passes.
1. Once deployment completes, you see *Your deployment is complete*.
## 2. Deploy the sample app
Now that your App Service app is created, deploy the sample application from GitHub.
1. In the Azure portal, navigate to your newly created App Service by selecting **Go to resource**.
1. In the left-hand menu, under the *Deployment* section, select **Deployment Center**.
1. In the *Settings* tab, configure:
| Property | Value |
|------------|--------------------------------------------------------------|
| Source | **External Git** |
| Repository | `https://github.com/Azure-Samples/app-service-dotnet-agent-tutorial`|
| Branch | `main` |
1. Select **Save** to apply the deployment settings.
## 3. Verify the sample app
After deployment, confirm that the sample app is running as expected.
1. In the left menu of your App Service, select **Overview**.
1. Select **Browse** to open the app in a new browser tab. (It might take a minute to load.)
1. The app displays a large counter and two buttons:
:::image type="content" source="media/troubleshoot-azure-app-service/verify-sample-primary-slot.png" alt-text="Screenshot of the .NET sample in the primary slot.":::
1. Select the *Increment* button several times to observe the counter increase.
## 4. Set up a deployment slot for failure simulation
To simulate an app failure scenario, add a secondary deployment slot.
1. In the left menu of your App Service, under the *Deployment* section, select **Deployment slots**.
1. Select **Add slot**.
1. Enter the following values:
| Property | Value | Remarks |
|---------------------|--------------|------------------------------------------------------------------------------------------|
| Name | `broken` | The error scenario is triggered in this slot. |
| Clone settings from | `my-sre-app` | Copies configuration from the main app. |
1. Scroll to the bottom of the dialog window and select **Add**. Slot creation might take a minute to complete.
### Deploy the sample app to the slot
1. Once the slot is created, select the **broken** slot from the list.
1. In the left menu, under the *Deployment* section, select **Deployment Center**.
1. In the *Settings* tab, configure:
| Property | Value |
|------------|---------------------------------------------------------------|
| Source | **External Git** |
| Repository | `https://github.com/Azure-Samples/app-service-dotnet-agent-tutorial` |
| Branch | `main` |
1. Select **Save** to apply the deployment settings.
### Add an app setting to enable error simulation
To control error simulation, configure an app setting your app checks at runtime.
1. In the left menu of your App Service, select **Environment variables** under the *Settings* section.
1. At the top, make sure you have the correct slot selected (for example, **broken**).
1. Under the **App settings** tab, select **+ Add**.
1. Enter the following values:
| Property | Value | Remarks |
|------------|---------------|--------------------------------------------------------------|
| Name | `INJECT_ERROR`| Must be exactly `INJECT_ERROR` (all caps, no spaces). |
| Value | `1` | Enables error simulation in the app. |
1. Make sure the **Deployment slot setting** box is **not** checked.
1. Select **Apply** to add the setting.
1. At the bottom of the *Environment variables* page, select **Apply** to apply the changes.
1. When prompted, select **Confirm** to confirm and restart the app in the selected slot.
## 5. Create an Azure SRE Agent
Now, create an Azure SRE Agent to monitor your App Service app.
1. In the Azure portal, search for and select **Azure SRE Agent**.
1. Select **+ Create**.
1. In the *Create agent* window, enter the following values:
| Property | Value | Remarks |
|------------------|---------------------------|-------------------------------------------------------------------------|
| Subscription | Your Azure subscription | |
| Resource group | `my-sre-agent-group` | New group for the Azure SRE Agent |
| Name | `my-sre-agent`| |
| Region | **Sweden Central** | Required during preview; can monitor resources in any Azure region |
| Choose role | **Contributor** | Grants the agent permission to take action on your behalf |
1. Select **Select resource groups**.
1. In the *Selected resource groups to monitor* window, search for and select `my-app-service-group`.
1. Select **Save**.
1. Back in the *Create agent* window, select **Create**. The agent creation process takes a few minutes to complete.
## 6. Chat with your agent
Once your SRE Agent is deployed and connected to your resource group, you can interact with it using natural language to monitor and troubleshoot your app.
1. In the Azure portal, search for and select **Azure SRE Agent**.
1. From the list of agents, select **my-app-service-sre-agent**.
1. Select **Chat with agent**.
1. In the chat box, enter the following command: