-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Too many retries performed when using cmdlets #2534
Comments
Hi Nickp85, If I may ask a simple question: |
The script is years old and it was easier to change from Invoke-RestMethod to Invoke-MgGraphRequest since I already had all the other code laid out to make the requests |
Fair enough. I agree that there was a time before the SDK came into existence. It wasn't terribly fun managing access tokens, REST requests and such. However, I would try to steer you toward using the cmdlet above, as it'll take care of the (1000) chunking for you, step off when it comes to the HTTP 429 responses for as long as it takes etc. Hopefully that single string should be able to replace all of the code you've posted above, which should make support/maintenance a little easier too. |
Is the output identical to what I'm getting today? A JSON output? |
It'll be in a PSObject form (System.Array). From the text you posted above, it looked as though you were interested in returning PSObjects too.
However, if you must return this in JSON, you could do something like:
However, I am only able to see the information you've supplied, and I lack the full context of what you're doing. I can only recommend that you give the read-only cmdlets a whirl to experiment with. |
You're right, I have PSObject and convert to JSON later It's also been said I should try the "export APIs"? |
unfortunately the different cmdlet did not work either. $devices = Get-MgBetaDeviceManagementManagedDevice -filter "managementAgent eq 'mdm' or managementAgent eq 'easmdm'" -all -debug Get-MgBetaDeviceManagementManagedDevice : One or more errors occurred.
|
Running again I again get the retries error Get-MgBetaDeviceManagementManagedDevice : Too many retries performed
|
Wow, that's a little surprising. I'm not sure I've got the right questions to ask to continue this. It does sound like a Graph API based problem, rather than the SDK - but I can't be certain. I'm not convinced whether running your cmdlet with a debug command would be of use either, because it sounds like it collects several iterations (pages of 1000), before failing. I'll leave this for someone else to pick up and point you in the right direction, but I'll keep tabs on this just in case. A piece of advice I have here is to jump on over to the Graph API support location and raise the same over there. If the SDK devs determine that it's an API service issue, you'll have a head start on that ticket. The API support links can be found here: |
I opened a case yesterday for the same exact issue and I am leveraging 'Get-MgBetaDeviceManagementManagedDevice'. I have operational scripts that rely on it that have been working for a year and this week they are all failing consistently. This occurs with Graph Powershell v1.0 and beta. Also, I have no issues pulling back user and device objects with 'get-MgUser' and 'get-mgdevice'... this seems to be only affecting the managed device space (Intune devices). You're not alone in this and I have heard nothing from Microsoft yet. I provided them my debug output as well. |
Having the same issue but with the non-Beta cmdlet Get-MgDeviceManagementManagedDevice. |
Similar issue - Started happening around the 21st / 22nd of Jan, we've had this runbooks for well over six months with no issues until this.
|
That is the exact behavior I get and my case is ongoing with no further details unfortunately. |
I also have the exact same issue i have operation scripts that run the Get-MgDeviceManagementManagedDevice -All command. they worked fine upto 1/17/24 on 1/18/24 this command started only pulling 2000 results. when it used to pull 19000+ results. Get-MgDeviceManagementManagedDevice : Too many retries performed
using the old intune powershell module i get this error when i run Get-IntuneManagedDevice | Get-MSGraphAllPages command: Get-MSGraphNextPage : 504 Gateway Timeout My Code has not changed. this has worked fine for many months. I put in a ticket with Microsoft and it hasnt received much response. |
Getting the same issue. Tried the following with Graph Explorer: https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=operatingSystem eq 'iOS' Microsoft has given us an workaround of using the export API to get the data, but would want to know when this issue has been resolved. Sample of the code I'm using for the time being.
|
I am having the same problem with Get-MgDeviceManagementDeviceCompliancePolicyDeviceStatus. I've tried various maxretry values and various pagesizes between 100 and 999 but it did not make a difference. This code has been running since May of 2023 and started having this problem on 1/26. If I try the same query in graph explorer, it errors as well with a generic error. { |
Just tossing another hat in the ring here. I am having the same issue with a script that deletes a list of mobile devices from a CSV in Intune. This script was updated for the new MSGraph module syntax last year, and I noticed it had stopped working on 1/25. In said script, I pull a list of devices from Intune by running I have tried running the above command with a |
I'm also hitting this, but found there is a service advisory Some admins are unable to utilize the Graph API to fetch Microsoft Intune user devices. |
can you link directly to the service advisory? i cannot find it anywhere. |
https://admin.microsoft.com/AdminPortal/home#/servicehealth/:/alerts/IT711139/undefined |
Hi @nickp85, after doing some investigations, It would be best to log this issue with the service owner. |
As of today, my case has been open for two weeks, been escalated to the Intune product group and no details have been provided on the status on their end. Thank goodness our users can still enroll and check in, but our operational automation has been busted since 1/14. |
@Underdoge https://admin.microsoft.com/Adminportal/Home?#/servicehealth/:/alerts/IT711139 the latest status: Current status: We're continuing to observe and check our applied scale optimizations and monitoring telemetry enhancements, however, due to the complexity of the issue, this is taking longer than expected to produce a timeline for mitigation. Start time: Monday, January 15, 2024 at 10:00 AM EST Root cause: The Microsoft Graph API is experiencing timeout issues, which is causing affected admins to see failed queries that indicate too many retries have been performed. Next update by: Friday, February 2, 2024 at 1:00 PM EST |
It seems this might be affecting some WUfB DS Driver related queries too, that then also manifest themselves as never ending syncs in Intune. It is related to this resource in my case: https://learn.microsoft.com/en-us/graph/api/resources/windowsupdates-applicablecontent?view=graph-rest-beta Which is called via: Perhaps on the backend the APIs are using the get devices queries, but regardless this too manifests itself with the "Invoke-MgGraphRequest : Too many retries performed" error It does seem to have to do with some level of record count, as this happens in multiple tenants, but only with policies with around 25+ devices in them. The policies with only a few devices seem to work as expected. |
As of two hours ago, service has been restored if you want to test. |
Thanks for the info, just retried and still seems to be an issue for me. Retries are set to 5. |
i just tested Get-MgDeviceManagementManagedDevice -all. It initially stalled. then i opened a new powershell console window, authenticated and ran the command again and its pulling 20k+ records without issues now. its very slow though. |
It appears Microsoft made some adjustments to the API and it is now pulling back all records without error. |
Observation... they changed the pagination limit from 1,000 results to 500 per page. |
Well that explains why this happened. why would they put this limit in? it makes this command run crazy slow now. So before if I had 20k Intune devices I could complete it iterating through 20 pages of 1000 results. Now it has to run iterating through 40 pages. running the "get next page" command every time and waiting for a response. it also ignores the "-PageSize 999" and only gives you 500 results. |
Did anyone see this problem start happening again? It started again on my side two days ago without any changes. It's been fine since it "disappeared" early Feb. |
I'm so sorry, I am not seeing it right now. Just ran my scripts successfully. I saw it ONE time last Wednesday... just one time and ran fine a second time. If it's consistent for you, definitely open a case. |
Same as @Nohvah22. I saw it a few times last week, "504 Gateway Timeout", but it went away and hasn't returned. |
Received this today with a rather innocuous command. I assume the service is just down temporarily?
|
Hi, I'm getting this exact issue when calling New-MgBetaSecurityAuditLogQuery -FilterStartDateTime $startDate -FilterEndDateTime $endDate -DisplayName "test" -ErrorAction Stop -Verbose -Debug
DEBUG: [CmdletBeginProcessing]: - New-MgBetaSecurityAuditLogQuery begin processing with parameterSet 'CreateExpanded'.
DEBUG: [Authentication]: - AuthType: 'AppOnly', TokenCredentialType: 'ClientCertificate', ContextScope: 'Process', AppName: '<REDACTED>'.
DEBUG: [Authentication]: - Scopes: [AuditLogsQuery.Read.All, AuditLog.Read.All].
Confirm
Are you sure you want to perform this action?
Performing the operation "New-MgBetaSecurityAuditLogQuery_CreateExpanded" on target "Call remote 'POST /security/auditLog/queries' operation".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
DEBUG: [CmdletException]: Received exception with message 'InvalidOperationException - Too many retries performed : at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RetryHandler.SendRetryAsync(HttpResponseMessage response, RetryHandlerOption retryOption, CancellationToken cancellationToken, ActivitySource activitySource)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RetryHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.CompressionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Graph.PowerShell.Authentication.Handlers.AuthenticationHandler.SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at Microsoft.Graph.Beta.PowerShell.Security.SecurityAuditLogCreateQuery_Call(HttpRequestMessage request, Func`3 on2Xx, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Graph.Beta.PowerShell.Security.SecurityAuditLogCreateQuery_Call(HttpRequestMessage request, Func`3 on2Xx, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Graph.Beta.PowerShell.Security.SecurityAuditLogCreateQuery(IDictionary headers, IMicrosoftGraphSecurityAuditLogQuery body, Func`3 on2Xx, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Graph.Beta.PowerShell.Cmdlets.NewMgBetaSecurityAuditLogQuery_CreateExpanded.ProcessRecordAsync()'
New-MgBetaSecurityAuditLogQuery_CreateExpanded: Too many retries performed Might be worth re-opening this issue. (ping @petrhollayms @nickp85) |
Getting the same issue with: but also with: I've tried reinstalling Microsoft.Graph modules, attempted in both Poweshell 5+ and 7+ as well. Microsoft.Graph version 2.25 and 2.24 same issue |
Did any of you guys try this ? Or find a way to make it work?
Let me know if this header works for you . L.E: For me it worked for around 300 domains, when I tried with 1260 domains, got the same error |
Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:
Describe the bug
Using Invoke-MgGraphRequest to make custom Graph requests to query devices in Intune. Has been working for years and within the last week, the requests are returning "Too many retries performed". I have tried to change the retry count or retry delay but nothing has helped. Eventually I started getting "task has been canceled" instead of "too many retries performed". The issue occurs the same with v1.0 or beta API. I use the beta API since that matches what Microsoft uses for the production Intune console (why I don't know).
The API chunks the response into 1000 at a time so the error is random. Sometimes it's immediate, other times it takes 3-4 runs of the while loop for it to fail
To Reproduce
Steps to reproduce the behavior:
Invoke-MgGraphRequest : Too many retries performed
Expected behavior
The device data is put into the $devices variable
Debug Output
DEBUG: GET
/beta/deviceManagement/managedDevices?$filter=managementAgent+eq+%27mdm%27+or+managementAgent+eq+%27easmdm%27&$skiptoken=LastDeviceName%3d%27Ben%25e2%2580%2599s%2520iPhone%27%2cLast
DeviceId%3d%27e230406f-f8ef-4dac-8eb1-f352c2b7ec63%27 HTTP/1.1
HTTP: graph.microsoft.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.19045; en-US) PowerShell/2024.0.0 Invoke-MgGraphRequest
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): y
Invoke-MgGraphRequest : Too many retries performed
At line:4 char:25
Module Version
Script 2.11.1 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext...}
Environment Data
Name Value
PSVersion 5.1.19041.3803
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3803
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Screenshots
Additional context
The text was updated successfully, but these errors were encountered: