# AI SRE Azure integration

Connect Azure to give AI SRE read-only access to the logs, metrics, activity log and resource changes of your Azure subscriptions during an investigation.

## Connect your tenant

An admin of your Microsoft Entra tenant approves the app from their own Better Stack account, then someone who can assign roles on the subscription gives it access.

1. If your Entra admin isn't in your Better Stack team yet, [invite them](https://betterstack.com/docs/uptime/inviting-team-members/) first.
2. Open [Integrations](https://chat.betterstack.com/team/0/integrations/popular ";_blank") in **AI SRE**.
3. Click **Add** next to **Azure**.
4. Click **Connect Azure tenant**.
5. Sign in to Microsoft as a Global Administrator, Cloud Application Administrator or Application Administrator of the tenant, with a Privileged Identity Management role already activated, and approve the Better Stack AI SRE app. Back in Better Stack, the integration's page says **Waiting for the Monitoring Reader role to be granted**.
6. Open [Azure Cloud Shell](https://shell.azure.com ";_blank") signed in to that tenant, as someone with the Owner, User Access Administrator or Role Based Access Control Administrator role on the subscription AI SRE should read. That's often someone other than the Entra admin.
7. Switch Cloud Shell to that subscription:

    ```bash
    [label Select the subscription]
    az account set --subscription <subscription ID>
    ```

8. Run the `az role assignment create` command the integration's page shows. It gives the app the Monitoring Reader role on that subscription.
9. Wait for **Active** at the top of the integration's page. Azure can take up to 10 minutes to apply the role. After the page turns **Active**, logs can take a few more minutes to become searchable.

To read another subscription, run the command under **Subscriptions** on the integration's page as someone who can assign roles on it. Each integration connects one tenant. To connect another, click **Add another** next to **Azure** and follow [Connect your tenant](#connect-your-tenant).

## What AI SRE can read

In the subscriptions where the app has the Monitoring Reader role, AI SRE can read:

-   Logs in Log Analytics workspaces and Application Insights.
-   Platform metrics of a resource.
-   The activity log, up to 90 days back.
-   Resources and their changes over the last 14 days, Resource Health, Azure service health and fired alerts.
-   The configuration of AKS clusters, App Service apps, Container Apps, virtual machines and deployments.

## Remove the integration

1. In **AI SRE** → [Integrations](https://chat.betterstack.com/team/0/integrations ";_blank"), click the tenant's ID under **Azure**.
2. Click **Remove**.
3. Confirm. AI SRE stops reading the tenant for your team.
4. If no other Better Stack team uses the tenant, run the commands in the **Azure integration was successfully removed.** message in Azure Cloud Shell, signed in to the tenant.

Removing the integration in Better Stack revokes nothing in Azure, so run those commands to remove the app's Monitoring Reader role assignments and then the app itself.
