> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neoagent.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting Azure Monitor Logs to Neo

> Create an app registration for Neo, give it the Log Analytics Data Reader role, save it in Neo and turn Azure Monitor Logs on for your agents

You connect Azure Monitor Logs once at the MSP level, then turn it on per agent. Neo reads only the workspaces and resources where you give its app the Log Analytics Data Reader role.

## 1. Create an app registration

**1. Register the app**

In the [Microsoft Entra admin center](https://entra.microsoft.com), open **Identity** > **Applications** > **App registrations** and click **New registration**. Name it "Neo Log Analytics", keep **Accounts in this organizational directory only**, and click **Register**.

**2. Copy the ids**

On the app's **Overview**, copy the **Directory (tenant) ID** and the **Application (client) ID**.

**3. Create a client secret**

Open **Certificates & secrets** > **Client secrets** > **New client secret**. Copy the secret's **Value** (not its Secret ID): Microsoft shows it only once. Note when it expires; Neo stops reading your logs on that date until you save a new one.

The app needs no API permissions in Entra ID. Its access comes from the Azure role in the next step. Create a new app for this integration, never the one you made for the Microsoft Azure integration: that app holds roles that change Azure resources, and one secret would then carry both.

## 2. Give the app the Log Analytics Data Reader role

In the [Azure portal](https://portal.azure.com), open each Log Analytics workspace Neo should read, then **Access control (IAM)** > **Add** > **Add role assignment**. Pick **Log Analytics Data Reader**, and select the app as the member. Assign it on each workspace, not on a resource group or subscription. This role only runs queries, reads the data and lists the workspace, which is all Neo needs, so a stolen secret reads logs and nothing else in Azure.

**Your clients' workspaces:** when a client's workspace is in its own tenant, the client delegates it to your app with [Azure Lighthouse](https://learn.microsoft.com/en-us/azure/lighthouse/overview). Lighthouse does not accept roles with data permissions, such as Log Analytics Data Reader, so the delegation uses **Log Analytics Reader** on the resource group that holds only the workspace. That role also reads the settings of every other resource in the group, so keep the workspace in a group of its own.

**Resource queries** (the logs of one VM or other Azure resource, on agents with no ticket) also need read access to that resource, such as **Monitoring Reader** on it. Skip this when your agents query workspaces only.

> [!NOTE]
>
> A new role assignment can take a few minutes to apply. Until it does, a query answers that the app has insufficient access.

## 3. Add the credential in Neo

**1. Open Integrations**

In the Neo Dashboard, open **Integrations** and find the Azure Monitor Logs card, under Servers & Virtualization.

**2. Save the credential**

Paste the Directory (tenant) ID, the Application (client) ID and the client secret, and click **Save**. Neo asks Microsoft for a sign-in token with them before it saves, so a wrong id or secret is rejected straight away with the reason. The save cannot check the role on a workspace: the first query does.

## 4. Map workspaces to your customers

After the save, the card's **Organization Mapping** tab lists every workspace the app may read, found through Azure Resource Graph, with a suggested customer for each. Neo suggests a match from the workspace's Microsoft Entra tenant and its name, and never trusts a suggestion on its own: confirm each one on the tab. A technician can also confirm a workspace on the approval card of the first query that names it.

On a ticket, an agent queries only the workspaces mapped to the ticket's company. On a ticket it does not send a resource query, KQL that calls `workspace()`, `app()`, `resource()`, `arg()`, `adx()`, `cluster()` or `database()`, or KQL with a `//` comment or a bracket-quoted name, because those reach, or can hide a reach into, other workspaces. A scheduled agent with no ticket, or a chat, is not limited to one company.

> [!WARNING]
>
> A function saved in a workspace runs as it is stored. Keep functions that query other workspaces (with `workspace()` or `union`) in your own workspace, never in a customer's: on that customer's tickets, Neo checks the workspaces a query names, and a stored function can reach past them with the app's role.

## 5. Turn it on per agent

Open the agent, go to its **Tools & Settings** tab, click **Servers & Virtualization**, and expand the **Azure Monitor Logs** block. It has one area, **Log Queries**, which is **Disabled** or **Read Only**. A query only reads, so it never waits for a technician's approval.

A ticket agent takes the company's workspaces from the mapping. A scheduled agent needs the **Workspace ID** of each workspace it should query in its instructions: open the workspace in the Azure portal and copy the Workspace ID from its **Overview**.

## Example: check a server on an offline alert

Give an agent that runs on your "server offline" tickets **Log Queries** on Read Only, and instructions like these:

> For the server named in the ticket, query the company's Log Analytics workspace: read its last Heartbeat and its Windows errors from the Event table in the last 24 hours. Add an internal note with the last heartbeat time and the five most recent errors.

## Limits

* Microsoft stops a query after 50 seconds when Neo runs it. A narrower time range or a summary fixes most slow queries.
* Neo reads up to 32 MB of one answer. Ask for the columns and rows you need.
* Microsoft allows an app about 200 queries in 30 seconds. Neo sends at most 50 calls in 30 seconds per MSP, and a batch holds at most 3 queries.

## Troubleshooting

| Error | Fix |
| - | - |
| Microsoft refused the client secret | Create a new client secret and paste its **Value**, not its Secret ID. |
| No application with that Application (client) ID | Check the ids are from the same app registration, in the tenant you entered. |
| The app has insufficient access (403) | Give the app the Log Analytics Data Reader role on that workspace (step 2), wait a few minutes and try again. |
| No workspace with that id (404) | Use the Workspace ID from the workspace's **Overview**, a GUID, not its name. |
| The ticket's company maps to no workspace | Confirm the workspace for that customer on the **Organization Mapping** tab, or approve the agent's request to use it. |
| A query returns no rows you expect | For a resource query, Microsoft leaves out workspaces and tables the app may not read. Check the role on each workspace the resource sends to. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.