Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Hi @Simon
Based on the information you provided, I understand that you are setting up a polling-based ingestion workflow for a shared mailbox using Microsoft Graph delta queries via an Azure Function with a System-Assigned Managed Identity. Even though your JWT token contains the Mail.Read application permission and works as expected (returning a 403 on /users), calling the endpoint [https://graph.microsoft.com/v1.0/users/inbox@company/mailFolders/inbox/messages](https://graph.micr… consistently returns a bare 401 Unauthorized with no response body or WWW-Authenticate header.
The bare 401 with an empty body is a classic symptom of an Application Access Policy denying access. When an Application Access Policy configured with AccessRight RestrictAccess is active and the calling application is either not allowed to access that specific mailbox, or if the policy has not fully propagated (or was created with the wrong ID), Microsoft Graph deliberately returns a silent 401 instead of a standard structured error payload.
To resolve this issue, please try referring to the following troubleshooting steps:
- Test the Application Access Policy immediately
Run the following PowerShell command via Exchange Online to verify the policy's evaluation:
Connect-ExchangeOnlineTest-ApplicationAccessPolicy -Identity "******@company.com" -AppId "<Managed-Identity-Application-ID>"
- Target outcome: You want to see
AccessCheckResult : Granted. - If it returns
Denied, the Application Access Policy is actively blocking your calls.
- Confirm you used the correct ID
When creating an Application Access Policy for a System-Assigned Managed Identity, you must use the Application (Client) ID, not the Object ID of the Enterprise Application / Service Principal.
You can verify the correct Client ID via:
- Azure Portal: Function App $\rightarrow$ Identity $\rightarrow$ System assigned $\rightarrow$ Client ID
- PowerShell / Graph: Inspecting the Service Principal’s
appIdproperty.
- Temporary isolation test
To confirm whether the policy is indeed causing the block:
- Temporarily remove the Application Access Policy.
- Re-test the Microsoft Graph call.
- If the endpoint starts returning
200 OK, the policy configuration was the sole culprit. - Carefully recreate the policy with the validated App ID and mail-enabled security group.
- Account for propagation delays
After creating or updating an Application Access Policy, wait at least 30 to 60 minutes (Microsoft documentation notes that propagation can sometimes take over an hour in certain tenants). Re-run Test-ApplicationAccessPolicy periodically until it reflects Granted.
- Additional sanity checks
- Group Type: Confirm that the group containing your mailbox is strictly a Mail-enabled Security Group (not a Microsoft 365 Group, Security Group, or Distribution List).
- Group Membership: Verify that
******@company.comis explicitly added as a member of this Mail-enabled Security Group. - Admin Consent: Double-check that Admin Consent for
Mail.Readwas properly granted specifically for your Managed Identity's Application ID.
Once the baseline /messages endpoint successfully returns a 200 OK, you can seamlessly switch to your delta query endpoint:
GET https://graph.microsoft.com/v1.0/users/inbox@company/mailFolders/inbox/messages/delta
Let me know how the Test-ApplicationAccessPolicy check goes.
If the answer is helpful, please click "Yes" and kindly upvote it. If you have extra questions about this answer, please click ""Comment"".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.