Skip to content
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

Get-MgEntitlementManagementAssignmentPolicy returns "An item with the same key has already been added" #3018

Open
Xiaojing123456 opened this issue Nov 6, 2024 · 0 comments
Labels

Comments

@Xiaojing123456
Copy link

Describe the bug

When I run Get-MgEntitlementManagementAssignmentPolicy in China Azure Cloud, it returns "An item with the same key has already been added". However, I can get normal return when trying other commands, like Get-MgEntitlementManagementAccessPackage. Moreover, it's working through REST API rather than Microsoft Graph Powershell.
++++Debug Result+++++++++++++++++++++++++++++++++++++++++
PS C:\Users\xiaojing> Get-MgEntitlementManagementAssignmentPolicy -AccessPackageAssignmentPolicyId 59b0e0d3-1ead-4596-b6
40-e289a2135f83 -Debug
DEBUG: [CmdletBeginProcessing]: - Get-MgEntitlementManagementAssignmentPolicy begin processing with parameterSet 'Get'.

Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): A
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'DeviceCode', ContextScope: 'CurrentUser',
AppName: 'xiaojinggraph'.
DEBUG: [Authentication]: - Scopes: [Application.Read.All, Directory.ReadWrite.All, EntitlementManagement.ReadWrite.All,
Group.ReadWrite.All, openid, profile, User.Read, User.ReadWrite.All, email].
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://microsoftgraph.chinacloudapi.cn/v1.0/identityGovernance/entitlementManagement/assignmentPolicies/59b0e0d3-1ead-
4596-b640-e289a2135f83

Headers:
FeatureFlag : 00000043
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 6.3; Microsoft Windows 6.3.9600;
en-US),PowerShell/5.1.14409.2001
Accept-Encoding : gzip
SdkVersion : graph-powershell/2.24.0
client-request-id : e344ad72-b96f-4590-8c1f-2075001a419d

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : a0f764ab-5c37-4ce7-9181-6da3b59d634b
client-request-id : e344ad72-b96f-4590-8c1f-2075001a419d
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"China
East","Slice":"E","Ring":"6","ScaleUnit":"001","RoleInstance":"SH1NEPF0000074D"}}
OData-Version : 4.0
Cache-Control : private
Date : Tue, 05 Nov 2024 09:29:17 GMT

Body:
{
"@odata.context":
"https://microsoftgraph.chinacloudapi.cn/v1.0/$metadata#identityGovernance/entitlementManagement/assignmentPolicies/$en
tity",
"id": "59b0e0d3-1ead-4596-b640-e289a2135f83",
"displayName": "Initial Policy",
"description": "Initial Policy",
"allowedTargetScope": "specificDirectoryUsers",
"createdDateTime": "2024-11-05T02:10:35.31Z",
"modifiedDateTime": "2024-11-05T02:10:35.39Z",
"automaticRequestSettings": null,
"reviewSettings": null,
"specificAllowedTargets": [
{
"@odata.type": "#microsoft.graph.singleUser",
"userId": "bcf93d6d-c03a-43a5-a81a-099546db6048",
"description": "Requestorxiaojing"
}
],
"expiration": {
"endDateTime": null,
"duration": "P30D",
"type": "afterDuration"
},
"requestorSettings": {
"allowCustomAssignmentSchedule": true,
"onBehalfRequestors": []
},
"requestApprovalSettings": {
"isApprovalRequiredForUpdate": false
},
"[email protected]":
"https://microsoftgraph.chinacloudapi.cn/v1.0/$metadata#identityGovernance/entitlementManagement/assignmentPolicies('59
b0e0d3-1ead-4596-b640-e289a2135f83')/questions",
"questions": [],
"customExtensionStageSettings": []
}

DEBUG: [CmdletException]: Received exception with message 'ArgumentException - An item with the same key has already
been added. : at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at Microsoft.Graph.PowerShell.Runtime.Json.JsonParser.ReadObject() at Microsoft.Graph.PowerShell.Runtime.Json.JsonParser.ReadNode() at Microsoft.Graph.PowerShell.Runtime.Json.JsonNode.Parse(SourceReader sourceReader) at Microsoft.Graph.PowerShell.IdentityGovernance.<>c.<IdentityGovernanceEntitlementManagementGetAssignmentPolicy_Call>b__1 424_0(Task1 body)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- 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.Cmdlets.GetMgEntitlementManagementAssignmentPolicy_Get.d__68.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.IdentityGovernance.<IdentityGovernanceEntitlementManagementGetAssignmentPolicy_Call>d__1424.
MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at
Microsoft.Graph.PowerShell.IdentityGovernance.<IdentityGovernanceEntitlementManagementGetAssignmentPolicy_Call>d__1424.
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.IdentityGovernance.d__1422.MoveN
ext()
--- 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.Cmdlets.GetMgEntitlementManagementAssignmentPolicy_Get.d__66.MoveNext()'

Confirm
An item with the same key has already been added.
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): Y
Get-MgEntitlementManagementAssignmentPolicy : An item with the same key has already been added.
At line:1 char:1

  • Get-MgEntitlementManagementAssignmentPolicy -AccessPackageAssignmentP ...
  •   + CategoryInfo          : NotSpecified: (:) [Get-MgEntitleme...nmentPolicy_Get], ArgumentException
    
  • FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgEntitlementManagementAssignmentPolicy_Get
    DEBUG: [CmdletException]: Received exception with message 'ArgumentException - An item with the same key has already
    been added. : at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)

    +++++++++++++++++++++++++++++++++++++++++++++

image

Expected behavior

Please help check what's going wrong with command Get-MgEntitlementManagementAssignmentPolicy & New-MgEntitlementManagementAssignmentPolicy. Is it a bug? The same command works fine in Global Azure.

How to reproduce

  1. Connect-MgGraph -Environment China -ClientId "c45ca454-3e62-xxx" -TenantId "b388b808-0ec9-4a09-xxxxx" -UseDeviceAuthentication -Scopes "EntitlementManagement.ReadWrite.All"

  2. Get-MgEntitlementManagementAssignmentPolicy -AccessPackageAssignmentPolicyId 59b0e0d3-1ead-4596-xxxx

SDK Version

2.24.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

PS C:\Users\xiaojing> Get-MgEntitlementManagementAssignmentPolicy -AccessPackageAssignmentPolicyId 59b0e0d3-1ead-4596-b6
40-e289a2135f83 -Debug
DEBUG: [CmdletBeginProcessing]: - Get-MgEntitlementManagementAssignmentPolicy begin processing with parameterSet 'Get'.

Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): A
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'DeviceCode', ContextScope: 'CurrentUser',
AppName: 'xiaojinggraph'.
DEBUG: [Authentication]: - Scopes: [Application.Read.All, Directory.ReadWrite.All, EntitlementManagement.ReadWrite.All,
Group.ReadWrite.All, openid, profile, User.Read, User.ReadWrite.All, email].
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://microsoftgraph.chinacloudapi.cn/v1.0/identityGovernance/entitlementManagement/assignmentPolicies/59b0e0d3-1ead-
4596-b640-e289a2135f83

Headers:
FeatureFlag : 00000043
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 6.3; Microsoft Windows 6.3.9600;
en-US),PowerShell/5.1.14409.2001
Accept-Encoding : gzip
SdkVersion : graph-powershell/2.24.0
client-request-id : e344ad72-b96f-4590-8c1f-2075001a419d

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : a0f764ab-5c37-4ce7-9181-6da3b59d634b
client-request-id : e344ad72-b96f-4590-8c1f-2075001a419d
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"China
East","Slice":"E","Ring":"6","ScaleUnit":"001","RoleInstance":"SH1NEPF0000074D"}}
OData-Version : 4.0
Cache-Control : private
Date : Tue, 05 Nov 2024 09:29:17 GMT

Body:
{
"@odata.context":
"https://microsoftgraph.chinacloudapi.cn/v1.0/$metadata#identityGovernance/entitlementManagement/assignmentPolicies/$en
tity",
"id": "59b0e0d3-1ead-4596-b640-e289a2135f83",
"displayName": "Initial Policy",
"description": "Initial Policy",
"allowedTargetScope": "specificDirectoryUsers",
"createdDateTime": "2024-11-05T02:10:35.31Z",
"modifiedDateTime": "2024-11-05T02:10:35.39Z",
"automaticRequestSettings": null,
"reviewSettings": null,
"specificAllowedTargets": [
{
"@odata.type": "#microsoft.graph.singleUser",
"userId": "bcf93d6d-c03a-43a5-a81a-099546db6048",
"description": "Requestorxiaojing"
}
],
"expiration": {
"endDateTime": null,
"duration": "P30D",
"type": "afterDuration"
},
"requestorSettings": {
"allowCustomAssignmentSchedule": true,
"onBehalfRequestors": []
},
"requestApprovalSettings": {
"isApprovalRequiredForUpdate": false
},
"[email protected]":
"https://microsoftgraph.chinacloudapi.cn/v1.0/$metadata#identityGovernance/entitlementManagement/assignmentPolicies('59
b0e0d3-1ead-4596-b640-e289a2135f83')/questions",
"questions": [],
"customExtensionStageSettings": []
}

DEBUG: [CmdletException]: Received exception with message 'ArgumentException - An item with the same key has already
been added. : at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at Microsoft.Graph.PowerShell.Runtime.Json.JsonParser.ReadObject() at Microsoft.Graph.PowerShell.Runtime.Json.JsonParser.ReadNode() at Microsoft.Graph.PowerShell.Runtime.Json.JsonNode.Parse(SourceReader sourceReader) at Microsoft.Graph.PowerShell.IdentityGovernance.<>c.<IdentityGovernanceEntitlementManagementGetAssignmentPolicy_Call>b__1 424_0(Task1 body)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- 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.Cmdlets.GetMgEntitlementManagementAssignmentPolicy_Get.d__68.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.IdentityGovernance.<IdentityGovernanceEntitlementManagementGetAssignmentPolicy_Call>d__1424.
MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at
Microsoft.Graph.PowerShell.IdentityGovernance.<IdentityGovernanceEntitlementManagementGetAssignmentPolicy_Call>d__1424.
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.IdentityGovernance.d__1422.MoveN
ext()
--- 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.Cmdlets.GetMgEntitlementManagementAssignmentPolicy_Get.d__66.MoveNext()'

Confirm
An item with the same key has already been added.
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): Y
Get-MgEntitlementManagementAssignmentPolicy : An item with the same key has already been added.
At line:1 char:1

  • Get-MgEntitlementManagementAssignmentPolicy -AccessPackageAssignmentP ...
  •   + CategoryInfo          : NotSpecified: (:) [Get-MgEntitleme...nmentPolicy_Get], ArgumentException
    
  • FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgEntitlementManagementAssignmentPolicy_Get
    DEBUG: [CmdletException]: Received exception with message 'ArgumentException - An item with the same key has already
    been added. : at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)

Configuration

No response

Other information

No response

@Xiaojing123456 Xiaojing123456 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Nov 6, 2024
@timayabi2020 timayabi2020 added Status: Needs Investigation and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants