You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PS Graph requests tooManyRetries, works fine in Graph Explorer #1793
When requesting large datasets with the expand parameter an error is returned saying: tooManyRetries, however you can use the exact same request uri in Graph explorer and it works and almost instantly returns the data. An example uri is:
This uri will return the full 1k of paginated results via graph explorer rapidly, but just errors via invoke-mggraphrequest, or equivalent commands like Get-MgDeviceAppMgtMobileApp -Property 'displayName, id' -Expand 'assignments'.
If you only have sub 100 apps then it sometimes works, and other times returns that error. It seems like these modules have a built in timeout of some sort when waiting for a reply from Graph, whereby graph is still working on the request but the module gives up waiting.
tooManyRetries error code is returned when your request has been throttled by the service, and our in-built retry handler has retried the throttled request 3 times without getting a successful response. Executing the command with -Debug will show you what's happening behind the scenes.
tooManyRetries error code is returned when your request has been throttled by the service, and our in-built retry handler has retried the throttled request 3 times without getting a successful response. Executing the command with -Debug will show you what's happening behind the scenes.
This request works fine in Graph Explorer though, so there should be no reason for it to have to retry. If it works in Graph Explorer it should also work via this powershell module. If it was truly a throttle and not an issue with this module why would Graph Explorer not get throttled?
Throttling is done by the service (via 429 status code), not the client. Graph Explorer is a web app, customers don't use it to make iterative requests in one go like they do in PowerShell. Naturally, requests from PowerShell will get throttled more given the number of requests we can send per second.
This error occurs on a single request though, so if run this on its own:
Invoke-MgGraphRequest -Method Get -Uri 'https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps?$Select=displayName,id&$expand=assignments'
then it gets this error. So that's just that one request on its own, no iteration.
If I use the -debug switch all it does is show me the auth settings and scope, then freezes for a while, then it gives me the same error mesage: ServiceException - Code: toomanyretries, Message: More than 3 retries encountered while sending the request.
I should also note that I am able to use batch requests, requesting 20 apps and there assignments at a time, and that works fine, so that is around 60 batch requests of 20, in rapid succession, vs this single request that errors.
The "freeze" is happening because the command is internally retrying the throttled request whilst honoring the retry-after header we get from the service.
Please share the complete output of the Get-MgDeviceAppMgtMobileApp -Property 'displayName, id' -Expand 'assignments' -Debug.
Please open a service ticket/question at https://developer.microsoft.com/en-us/graph/support to have the API owner investigate why all the requests coming from your app (packaging tooling ...) are being throttled. Use Fiddler to capture the trace and share the request-id and date of the failed request in your ticket.
In the meantime, you could:
try adjusting the default retry times to something > 3 - Set-MgRequestContext -MaxRetry 5.
use the default app that ships with the module - Connect-MgGraph -Scopes "DeviceManagementApps.ReadWrite.All". This assumes the service is throttling your app (packaging tooling ..).
I already logged a premier ticket via my works account, and a member of the Graph team said because its working fine in Graph Explorer the issue must be with the PowerShell module not the API :(
I should also add that this error also occurs with the Connect-MSGraph module as well.
Regarding the default app, I cant use that as its not had the permission added on the Enterprise app for it. However I'm assuming that given the issue still occurs with Connect-MSGraph, answers the question that its not just my app?
If I set the maxretry to 5, that seems to resolve the issue, but it takes longer on average than the batch method does. Graph Explorer returns the data almost instantaneously.
They didnt do any investigation on the ticket, they asked me to check if it worked in Graph Explorer, then said log an issue on Github for the module.
Activity
peombwa commentedon Feb 8, 2023
tooManyRetrieserror code is returned when your request has been throttled by the service, and our in-built retry handler has retried the throttled request 3 times without getting a successful response. Executing the command with-Debugwill show you what's happening behind the scenes.To change the default max retry limit of 3, use
Set-MgRequestContext -MaxRetry <1-10>. See #1584 and https://github.com/microsoftgraph/msgraph-sdk-design/blob/master/middleware/RetryHandler.md for more details.Please review the throttling guidance at https://learn.microsoft.com/en-us/graph/throttling and service-specific limits at https://learn.microsoft.com/en-us/graph/throttling-limits#intune-device-enrollment-service-limits for best practices when calling the service.
KG-droid commentedon Feb 9, 2023
This request works fine in Graph Explorer though, so there should be no reason for it to have to retry. If it works in Graph Explorer it should also work via this powershell module. If it was truly a throttle and not an issue with this module why would Graph Explorer not get throttled?
peombwa commentedon Feb 9, 2023
Throttling is done by the service (via 429 status code), not the client. Graph Explorer is a web app, customers don't use it to make iterative requests in one go like they do in PowerShell. Naturally, requests from PowerShell will get throttled more given the number of requests we can send per second.
Please use
-Debugswitch on the command to see where the 429 status code/retry-after header comes from. See https://learn.microsoft.com/en-us/powershell/microsoftgraph/troubleshooting?view=graph-powershell-1.0#using--debug.KG-droid commentedon Feb 9, 2023
This error occurs on a single request though, so if run this on its own:
Invoke-MgGraphRequest -Method Get -Uri 'https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps?$Select=displayName,id&$expand=assignments'then it gets this error. So that's just that one request on its own, no iteration.
If I use the -debug switch all it does is show me the auth settings and scope, then freezes for a while, then it gives me the same error mesage: ServiceException - Code: toomanyretries, Message: More than 3 retries encountered while sending the request.
I should also note that I am able to use batch requests, requesting 20 apps and there assignments at a time, and that works fine, so that is around 60 batch requests of 20, in rapid succession, vs this single request that errors.
peombwa commentedon Feb 9, 2023
The "freeze" is happening because the command is internally retrying the throttled request whilst honoring the
retry-afterheader we get from the service.Please share the complete output of the
Get-MgDeviceAppMgtMobileApp -Property 'displayName, id' -Expand 'assignments' -Debug.5 remaining items
peombwa commentedon Feb 9, 2023
No worries. Thanks for the output!
This is the service throttling the request.
Please open a service ticket/question at https://developer.microsoft.com/en-us/graph/support to have the API owner investigate why all the requests coming from your app (packaging tooling ...) are being throttled. Use Fiddler to capture the trace and share the
request-idanddateof the failed request in your ticket.In the meantime, you could:
Set-MgRequestContext -MaxRetry 5.Connect-MgGraph -Scopes "DeviceManagementApps.ReadWrite.All". This assumes the service is throttling your app (packaging tooling ..).KG-droid commentedon Feb 9, 2023
I already logged a premier ticket via my works account, and a member of the Graph team said because its working fine in Graph Explorer the issue must be with the PowerShell module not the API :(
I should also add that this error also occurs with the Connect-MSGraph module as well.
peombwa commentedon Feb 9, 2023
Sorry for the back and forth. Please share the Fiddler trace of the failing request in your ticket. The Fiddler trace will show the responses the command got from the service. See similar throttling related issues that have been tied to the service at https://learn.microsoft.com/en-us/answers/questions/381873/getting-exception-while-fetching-busy-time-from-ca.
Also, what's the outcome of the suggested workaround above?
KG-droid commentedon Feb 9, 2023
Regarding the default app, I cant use that as its not had the permission added on the Enterprise app for it. However I'm assuming that given the issue still occurs with Connect-MSGraph, answers the question that its not just my app?
If I set the maxretry to 5, that seems to resolve the issue, but it takes longer on average than the batch method does. Graph Explorer returns the data almost instantaneously.
They didnt do any investigation on the ticket, they asked me to check if it worked in Graph Explorer, then said log an issue on Github for the module.
KG-droid commentedon Feb 14, 2023
They have reopened the ticket so I'll see what they come up with, and post here if/when it's fixed.
KG-droid commentedon Mar 16, 2023
This has been accept as a bug, but apparently its not important enough to bother fixing it!