msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Throttling errors in Graph.DeviceManagement.Enrollment module

Open mikenikitin opened this issue 1 year ago • 0 comments

Describe the bug

I am trying to register multiple devices to Windows Autopilot using Invoke-MgGraphRequest with URI https://graph.microsoft.com/v1.0/deviceManagement/importedWindowsAutoPilotDeviceIdentities and method POST. Have been using this for many months without any issues. However, it looks like there is some new throttling has been introduced recently in Microsoft Graph, as after about 60-70 devices, the execution of a request stops with the following error:

System.InvalidOperationException: Too many retries performed ---> System.Exception: More than 3 retries encountered while sending the request.

--- End of inner exception stack trace --- at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RetryHandler.<SendRetryAsync>d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RetryHandler.<SendAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.CompressionHandler.<SendAsync>d__1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Authentication.Handlers.AuthenticationHandler.<SendAsync>d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Authentication.Cmdlets.InvokeMgGraphRequest.<GetResponseAsync>d__94.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Authentication.Cmdlets.InvokeMgGraphRequest.<ProcessRecordAsync>d__109.MoveNext()

This error happens 5 times, then the execution resumes and works without issues for another 60-70 devices, then stops again. And so on, and so on.

Expected behavior

Error-free execution with proper handling of Graph throttling

How to reproduce

Execute ~80 POST Invoke-MgGraphRequest calls in succession at URI https://graph.microsoft.com/v1.0/deviceManagement/importedWindowsAutoPilotDeviceIdentities. After 60-70 devices, an error occurs.

SDK Version

2.20.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

-OS: Windows 10, architecture: x64

### Other information

_No response_

mikenikitin avatar Jul 23 '24 00:07 mikenikitin