Update-MgAdminSharepointSetting: Too many retries performed. More than 3 retries

Laszlo Olasz 0 Reputation points
2025-02-04T10:32:32.6166667+00:00

I am trying to update Sharepoint Tenant settings with 1260+ domains for sharingAllowedDomainList using either on of the following cmdlets:

Getting the same issue with: $Uri = "https://graph.microsoft.com/v1.0/admin/sharepoint/settings" Invoke-MgGraphRequest -Uri $Uri -Method Patch -Body $updateBody

but also with: Update-MgAdminSharepointSetting -SharingAllowedDomainList $allowedDomains Update-MgAdminSharepointSetting_UpdateExpanded: Too many retries performed. More than 3 retries encountered while sending the request. (HTTP request failed with status code: GatewayTimeout.

I've tried reinstalling Microsoft.Graph modules, attempted in both Poweshell 5+ and 7+ as well. Same things happens if script is run in Azure Automation runbook.

Microsoft.Graph version 2.25 and 2.24 same issue

Image

Expected behavior

Expected behavior should be long running time ( 1200+ domains ) but then list updated, no error

How to reproduce

  1. Connect-MgGraph -TenantId $TenantId -ClientSecretCredential $Global:ClientCredentials
  2. $Uri = "https://graph.microsoft.com/v1.0/admin/sharepoint/settings"
  3. $SPOSettings = Invoke-MgGraphRequest -Uri $Uri -Method Get
  4. $allowedDomains = $SPOSettings.sharingAllowedDomainList
  5. $allowedDomains+="contoso.com"
  6. $updateBody = @{ sharingAllowedDomainList = $allowedDomains }
  7. Invoke-MgGraphRequest -Uri $Uri -Method Patch -Body $updateBody

or

  1. Connect-MgGraph -TenantId $TenantId -ClientSecretCredential $Global:ClientCredentials
  2. $SPOSettings = Get-MgAdminSharepointSetting
  3. $allowedDomains = $SPOSettings.sharingAllowedDomainList
  4. $allowedDomains+="contoso.com"
  5. Update-MgAdminSharepointSetting -SharingAllowedDomainList $allowedDomains -Debug

or

Either one of the above in Azure Automation runbook Powershell version 7.2

SDK Version

2.25.0,2.24.0,Beta

Latest version known to work for scenario above?

No response

Known Workarounds

no workaround with Microsoft Graph issue persists with Microsoft.Graph.Beta.Sites

This is not reliable at all, even with Retry-After 240, it errors out, although it adds the domains.

Image

Same error with 600 Retry-After:

Image

I've tried reinstalling Microsoft.Graph modules, attempted in both Poweshell 5+ and 7+ as well.
Same things happens if script is run in Azure Automation runbook.

Microsoft.Graph version 2.25 and 2.24 same issue

Image

Expected behavior

Expected behavior should be long running time ( 1200+ domains ) but then list updated, no error

How to reproduce

  1. Connect-MgGraph -TenantId $TenantId -ClientSecretCredential $Global:ClientCredentials
  2. $Uri = "https://graph.microsoft.com/v1.0/admin/sharepoint/settings"
  3. $SPOSettings = Invoke-MgGraphRequest -Uri $Uri -Method Get
  4. $allowedDomains = $SPOSettings.sharingAllowedDomainList
  5. $allowedDomains+="contoso.com"
  6. $updateBody = @{
    sharingAllowedDomainList = $allowedDomains
    }
  7. Invoke-MgGraphRequest -Uri $Uri -Method Patch -Body $updateBody

or

  1. Connect-MgGraph -TenantId $TenantId -ClientSecretCredential $Global:ClientCredentials
  2. $SPOSettings = Get-MgAdminSharepointSetting
  3. $allowedDomains = $SPOSettings.sharingAllowedDomainList
  4. $allowedDomains+="contoso.com"
  5. Update-MgAdminSharepointSetting -SharingAllowedDomainList $allowedDomains -Debug

or

Either one of the above in Azure Automation runbook Powershell version 7.2

SDK Version

2.25.0,2.24.0,Beta

Latest version known to work for scenario above?

No response

Known Workarounds

no workaround with Microsoft Graph
issue persists with Microsoft.Graph.Beta.Sites

This is not reliable at all, even with Retry-After 240, it errors out, although it adds the domains.

Image

Same error with 600 Retry-After:

Image

Debug:
Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): y DEBUG: [CmdletException]: Received exception with message 'AggregateException - Too many retries performed. More than 3 retries encountered while sending the request. : at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RetryHandler.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.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.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.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.Beta.PowerShell.Sites.<AdminSharepointUpdateSetting_Call>d__17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Graph.Beta.PowerShell.Sites.<AdminSharepointUpdateSetting_Call>d__17.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.Beta.PowerShell.Sites.d__16.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.Beta.PowerShell.Cmdlets.UpdateMgBetaAdminSharepointSetting_UpdateExpanded.d__148.MoveNext()'

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): y

Confirm Too many retries performed. More than 3 retries encountered while sending the request. [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): y Update-MgBetaAdminSharepointSetting : Too many retries performed. More than 3 retries encountered while sending the request. At line:1 char:1

  • Update-MgBetaAdminSharepointSetting -SharingAllowedDomainList $allowe ...
  • + CategoryInfo : NotSpecified: (:) [Update-MgBetaAd..._UpdateExpanded], AggregateException + FullyQualifiedErrorId : Microsoft.Graph.Beta.PowerShell.Cmdlets.UpdateMgBetaAdminSharepointSetting_ UpdateExpanded

DEBUG: [CmdletEndProcessing]: - Update-MgBetaAdminSharepointSetting end processing.

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): y PS C:\Users\laszl>

</details>


### Configuration

- OS: Windows 10
- Powershell 5.1
- Powershell 7.4.6

or 

- Azure Automation
- PowerShell 7.2

### Other information

_No response_
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,954 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,172 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.