Skip to main content
Grant your Foundry Hosted agent permission to export telemetry to Microsoft Agent 365 by assigning the Agent365.Observability.OtelWrite app role to the hosted agent’s Entra Agent Identity. Use this procedure when your hosted agent is configured to send telemetry to Agent 365 and needs Microsoft Entra permission to write observability data.

Prerequisites

  • Azure CLI 2.x or later, signed in. Run az --version to confirm.
  • Global Administrator or Application Administrator role in Microsoft Entra ID to manage app role assignments.
  • A Foundry Hosted Agent deployed and configured to send telemetry to Agent 365. See Configure Agent 365 data collection for Microsoft Foundry.
  • Access to your hosted agent’s application resource in the Azure portal so you can retrieve its Entra Agent Identity object ID.
  • A tenant where the Agent365Observability service principal exists.
The hosted agent must be deployed so that its Entra Agent Identity exists. If you can’t find the agent identity object ID in step 1, see Troubleshooting.

Identify the required IDs

Collect the three values you need before you assign the app role.
  1. Get the object ID of the hosted agent’s Entra Agent Identity. In the Azure portal, open your agent application resource. On the Overview pane, select JSON View, choose the latest API version, and copy the agent identity object ID (agentIdentityId). For more information, see Agent identity. Save this value as <AGENT_PRINCIPAL_ID>. If you can’t find the value, see Troubleshooting.
For scripted workflows, you can list agent identities with the preview Microsoft Graph endpoint GET /beta/servicePrincipals/microsoft.graph.agentIdentity and copy the id for your agent. This endpoint is in beta and isn’t supported for production use.
  1. Get the object ID of the Agent365Observability service principal:
These commands use bash syntax. In PowerShell, escape the dollar sign with a backtick: `$filter. Alternatively, enclose the entire URI in single quotes, which suppresses variable expansion in PowerShell.
Save this value as <AGENT365_OBSERVABILITY_SP_ID>.
The appRoleId value is fixed and doesn’t vary by tenant — it’s the well-known identifier for the Agent365.Observability.OtelWrite role. Copy it directly from the table above; you don’t need to retrieve it with a command.

Assign the observability app role

Assign the Agent365.Observability.OtelWrite app role to the hosted agent’s Entra Agent Identity.
Replace both occurrences of <AGENT_PRINCIPAL_ID> in the following command — one appears in the URI path and one in the request body. Replace <AGENT365_OBSERVABILITY_SP_ID> with the Agent365Observability service principal object ID. Keep the appRoleId value as-is.
  • Run the command:
    A successful request returns HTTP 201 with a JSON object containing the assignment details, including principalId, resourceId, and appRoleId.
The --body value uses single-quoted JSON, which is valid in bash. In PowerShell, save the JSON to a file and pass it with --body @body.json, or use a here-string with escaped inner double quotes.

Verify the assignment

Verify that the role assignment exists before you test telemetry export.
  1. Run the following command:
  2. Confirm that the response includes an assignment for the Agent365.Observability.OtelWrite app role.
  3. After the assignment is present, test your hosted agent telemetry flow by reviewing traces in Microsoft Agent 365. See Configure Agent 365 data collection for Microsoft Foundry.
App role assignments can take a few minutes to propagate. If telemetry export fails immediately after assignment, wait 2–5 minutes and try again.

Troubleshooting