An Azure service that provides an event-driven serverless compute platform.
Hello Kirt Sawaya ,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are having Durable Function errors with MI on Set-Mailbox.
The issue is not proven to be a Durable Functions write-cmdlet limitation.
With the scenario and strongest evidence you provided that Set-Mailbox succeeds inside the same Function when executed under another Managed Identity context.
Therefore, the direct fix is:
- Explicitly specify the intended user-assigned Managed Identity with
-ManagedIdentityAccountId. - https://learn.microsoft.com/en-us/powershell/exchange/connect-exo-powershell-managed-identity?view=exchange-ps - Verify that exact identity has
Exchange.ManageAsApp. - https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps - Verify that exact identity has Exchange RBAC rights for
Set-Mailbox -LitigationHoldEnabled. - https://learn.microsoft.com/en-us/powershell/exchange/find-exchange-cmdlet-permissions?view=exchange-ps - Validate mailbox Litigation Hold licensing. - https://learn.microsoft.com/en-us/microsoft-365/admin/misc/create-litigation-hold-mac?view=o365-worldwide
- Run connect/execute/disconnect inside the Durable activity function, not as a shared/stale session. - https://learn.microsoft.com/en-us/azure/durable-task/common/durable-task-code-constraints?tabs=csharp&pivots=durable-functions
If the issue still reproduces after those checks, then collect the failing activity invocation ID, Exchange request/correlation information, module version, Managed Identity object ID/client ID, and exact UTC timestamp, and open a Microsoft support case as a potential Exchange Online service-side failure. But based on the evidence, the root cause to eliminate is wrong or underprivileged Managed Identity being used by the Function, not Durable Functions itself. - https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/get-managementroleassignment?view=exchange-ps
Use the associated links for more reading and detail steps.
I hope this is helpful! Do not hesitate to let me know if you have any other questions, steps or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.