Azure / Azure/azure-powershell

Unable to update policy exemption update using "Set-AzPolicyExemption" PowerShell cmdlet

Open
#23,623 1 comment 0 reactions 0 assignees View on GitHub
bug customer-reported Policy Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

When trying to update a policy exemption using the "Set-AzPolicyExemption" PowerShell cmdlet, the following error is thrown: "InvalidPolicyDefinitionReference : The policy exemption '2bb37db403eb46e5a5644de9' create request is invalid. The associated policy assignment is an assignment of a policy definition. The policy definition reference is only valid for policy assignments of policy set definitions.".

When using the -Debug parameter, checked that the HTTP request for [Policy Exemptions - Create Or Update - REST API (Azure Policy)](https://learn.microsoft.com/en-us/rest/api/policy/policy-exemptions/create-or-update?view=rest-policy-2022-07-01-preview&tabs=HTTP). E.g.:

Body:
{
"properties": {
"policyAssignmentId": "/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyAssignments/fa3355e8b0274269be1a5aef",
**"policyDefinitionReferenceIds": [
"[]"
]**,
"exemptionCategory": "Waiver",
"displayName": "InternalSubscription-joaosa-Webapplogs",
"description": "a",
"metadata": {}
},
"name": "2bb37db403eb46e5a5644de9"
}

The property "policyDefinitionReferenceIds"'s value is an array with an empty array. HTTP response code: 400.

E.g. when using the Azure Portal:

Body:

{
"properties": {
"policyAssignmentId": "/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyAssignments/fa3355e8b0274269be1a5aef",
**"policyDefinitionReferenceIds": []**,
"exemptionCategory": "Waiver",
"expiresOn": null,
"displayName": "Internal Subscription - joaosa - Web app logs",
"description": "",
"metadata": {},
"resourceSelectors": []
}

}

The property "policyDefinitionReferenceIds"'s value is an empty array. HTTP response code: 200.

### Issue script & Debug output

```PowerShell
DEBUG: 10:49:17 - SetAzurePolicyExemptionCmdlet begin processing with ParameterSet 'IdParameterSet'.
DEBUG: 10:49:17 - using account id 'pii'...
DEBUG: 10:49:17 - [ConfigManager] Got [False] from [DisplayBreakingChangeWarning], Module = [], Cmdlet = [].
DEBUG: [Common.Authentication]: Authenticating using Account: 'pii', environment: 'AzureCloud', tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47'
DEBUG: 10:49:17 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'72f988bf-86f1-41af-91ab-2d7cd011db47', Scopes:'https://management.core.windows.net//.default',
AuthorityHost:'https://login.microsoftonline.com/', UserId:'pii'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 716a5453-bb93-4f25-bb40-e5221c559188] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 716a5453-bb93-4f25-bb40-e5221c559188] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 716a5453-bb93-4f25-bb40-e5221c559188] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 716a5453-bb93-4f25-bb40-e5221c559188] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 716a5453-bb93-4f25-bb40-e5221c559188] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 716a5453-bb93-4f25-bb40-e5221c559188] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 716a5453-bb93-4f25-bb40-e5221c559188] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z] Found 3 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z] Returning 3 accounts
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] MSAL MSAL.Desktop with assembly version '4.46.2.0'. Correl
ationId(0be0bf1b-ae5f-494e-aa67-cb774e2cd041)
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] LoginHint provided: False
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] Account provided: True
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] ForceRefresh: False
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] === Token Acquisition (SilentRequest) started:
Scopes: https://management.core.windows.net//.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] Access token is not expired. Returning the found cache ent
ry. [Current time (11/30/2023 10:49:17) - Expiration Time (11/30/2023 11:05:06 +00:00) - Extended Expiration Time (11/30/2023 11:05:06 +00:00)]
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] Returning access token found in cache. RefreshOn exists ?
False
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 0be0bf1b-ae5f-494e-aa67-cb774e2cd041] AT expiration time: 30/11/2023 11:05:06 +00:00, scopes: h
ttps://management.core.windows.net//user_impersonation https://management.core.windows.net//.default. source: Cache
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2023-11-30T11:05:06.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47', UserId: 'pii'
DEBUG: [Common.Authentication]: Authenticating using Account: 'pii', environment: 'AzureCloud', tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47'
DEBUG: 10:49:17 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'72f988bf-86f1-41af-91ab-2d7cd011db47', Scopes:'https://management.core.windows.net//.default',
AuthorityHost:'https://login.microsoftonline.com/', UserId:'pii'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 49f8ec0d-276f-460d-bdf2-0fb3b9d9169f] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 49f8ec0d-276f-460d-bdf2-0fb3b9d9169f] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 49f8ec0d-276f-460d-bdf2-0fb3b9d9169f] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 49f8ec0d-276f-460d-bdf2-0fb3b9d9169f] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 49f8ec0d-276f-460d-bdf2-0fb3b9d9169f] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 49f8ec0d-276f-460d-bdf2-0fb3b9d9169f] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 49f8ec0d-276f-460d-bdf2-0fb3b9d9169f] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z] Found 3 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z] Returning 3 accounts
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] MSAL MSAL.Desktop with assembly version '4.46.2.0'. Correl
ationId(380f6e18-70a3-4687-abcf-7f113d31c08d)
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] LoginHint provided: False
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] Account provided: True
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] ForceRefresh: False
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 380f6e18-70a3-4687-abcf-7f113d31c08d
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] === Token Acquisition (SilentRequest) started:
Scopes: https://management.core.windows.net//.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] Access token is not expired. Returning the found cache ent
ry. [Current time (11/30/2023 10:49:17) - Expiration Time (11/30/2023 11:05:06 +00:00) - Extended Expiration Time (11/30/2023 11:05:06 +00:00)]
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] Returning access token found in cache. RefreshOn exists ?
False
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.46.2.0 MSAL.Desktop 4.8 or later Windows 10 Enterprise [2023-11-30 10:49:17Z - 380f6e18-70a3-4687-abcf-7f113d31c08d] AT expiration time: 30/11/2023 11:05:06 +00:00, scopes: h
ttps://management.core.windows.net//user_impersonation https://management.core.windows.net//.default. source: Cache
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2023-11-30T11:05:06.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47', UserId: 'pii'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyExemptions/2bb37db403eb46e5a5644de9?api-version=2020-07-01-preview

Headers:
User-Agent : AzurePowershell/v0.0.0,PSVersion/v5.1.22621.2506,Az.Resources/6.5.0
ParameterSetName : IdParameterSet
CommandName : Set-AzPolicyExemption

Body:

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

Status Code:
OK

Headers:
Pragma : no-cache
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 11997
x-ms-request-id : 9511e987-c246-4d06-9402-82e66c343a20
x-ms-correlation-request-id : 9511e987-c246-4d06-9402-82e66c343a20
x-ms-routing-request-id : FRANCECENTRAL:20231130T104917Z:9511e987-c246-4d06-9402-82e66c343a20
X-Content-Type-Options : nosniff
Cache-Control : no-cache
Date : Thu, 30 Nov 2023 10:49:17 GMT
Server : Kestrel

Body:
{
"properties": {
"policyAssignmentId": "/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyAssignments/fa3355e8b0274269be1a5aef",
"policyDefinitionReferenceIds": [],
"exemptionCategory": "Waiver",
"displayName": "Internal Subscription - joaosa - Web app logs",
"description": "",
"metadata": {}
},
"id": "/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyExemptions/2bb37db403eb46e5a5644de9",
"type": "Microsoft.Authorization/policyExemptions",
"name": "2bb37db403eb46e5a5644de9",
"systemData": {
"createdBy": "pii",
"createdByType": "User",
"createdAt": "2023-11-29T12:22:02.4916082Z",
"lastModifiedBy": "pii",
"lastModifiedByType": "User",
"lastModifiedAt": "2023-11-29T14:16:42.9424511Z"
}
}

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PUT

Absolute Uri:
https://management.azure.com/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyExemptions/2bb37db403eb46e5a5644de9?api-version=2020-07-01-preview

Headers:
User-Agent : AzurePowershell/v0.0.0,PSVersion/v5.1.22621.2506,Az.Resources/6.5.0
ParameterSetName : IdParameterSet
CommandName : Set-AzPolicyExemption

Body:
{
"properties": {
"policyAssignmentId": "/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyAssignments/fa3355e8b0274269be1a5aef",
"policyDefinitionReferenceIds": [
"[]"
],
"exemptionCategory": "Waiver",
"displayName": "InternalSubscription-joaosa-Webapplogs",
"description": "a",
"metadata": {}
},
"name": "2bb37db403eb46e5a5644de9"
}

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

Status Code:
BadRequest

Headers:
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-request-id : 99d1582f-baf6-4428-ac64-e14a2dcb2009
x-ms-correlation-request-id : 99d1582f-baf6-4428-ac64-e14a2dcb2009
x-ms-routing-request-id : FRANCECENTRAL:20231130T104917Z:99d1582f-baf6-4428-ac64-e14a2dcb2009
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Cache-Control : no-store, no-cache
Date : Thu, 30 Nov 2023 10:49:17 GMT
Server : Kestrel

Body:
{
"error": {
"code": "InvalidPolicyDefinitionReference",
"message": "The policy exemption '2bb37db403eb46e5a5644de9' create request is invalid. The associated policy assignment is an assignment of a policy definition. The policy definition referenc
e is only valid for policy assignments of policy set definitions."
}
}

DEBUG: 10:49:17 - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = [].
Set-AzPolicyExemption : InvalidPolicyDefinitionReference : The policy exemption '2bb37db403eb46e5a5644de9' create request is invalid. The associated policy assignment is an assignment of a
policy definition. The policy definition reference is only valid for policy assignments of policy set definitions.
CorrelationId: 99d1582f-baf6-4428-ac64-e14a2dcb2009
At line:1 char:1
+ Set-AzPolicyExemption -ResourceId "/subscriptions/d926280d-abb2-4fb3- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzPolicyExemption], ErrorResponseMessageException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzurePolicyExemptionCmdlet

DEBUG: 10:49:18 - [ConfigManager] Got [False] from [DisplayBreakingChangeWarning], Module = [], Cmdlet = [].
DEBUG: AzureQoSEvent: Module: Az.Resources:6.5.0; CommandName: Set-AzPolicyExemption; PSVersion: 5.1.22621.2506; IsSuccess: False; Duration: 00:00:00.5764128; Exception: InvalidPolicyDefinitionR
eference : The policy exemption '2bb37db403eb46e5a5644de9' create request is invalid. The associated policy assignment is an assignment of a policy definition. The policy definition reference is
only valid for policy assignments of policy set definitions.
CorrelationId: 99d1582f-baf6-4428-ac64-e14a2dcb2009;
DEBUG: 10:49:18 - SetAzurePolicyExemptionCmdlet end processing.
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

### Module versions

```PowerShell
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.10.4 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Script 6.5.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}
```

### Error output

```PowerShell
DEBUG: 10:50:24 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 10:50:24 - using account id 'pii'...
DEBUG: 10:50:24 - [ConfigManager] Got [False] from [DisplayBreakingChangeWarning], Module = [], Cmdlet = [].

HistoryId: 4

Message : InvalidPolicyDefinitionReference : The policy exemption '2bb37db403eb46e5a5644de9' create request is invalid. The associated policy assignment is an assignment of a policy
definition. The policy definition reference is only valid for policy assignments of policy set definitions.
CorrelationId: 99d1582f-baf6-4428-ac64-e14a2dcb2009
StackTrace : at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.HandleException(ExceptionDispatchInfo capturedException)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.ErrorResponses.ErrorResponseMessageException
InvocationInfo : {Set-AzPolicyExemption}
Line : Set-AzPolicyExemption -ResourceId "/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyExemptions/2bb37db403eb46e5a5644de9" -Description
"a"
Position : At line:1 char:1
+ Set-AzPolicyExemption -ResourceId "/subscriptions/d926280d-abb2-4fb3- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 4

HistoryId: 2

Message : InvalidPolicyDefinitionReference : The policy exemption '2bb37db403eb46e5a5644de9' create request is invalid. The associated policy assignment is an assignment of a policy
definition. The policy definition reference is only valid for policy assignments of policy set definitions.
CorrelationId: efa3e393-df68-4a59-9f7d-a424aeab6d1e
StackTrace : at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.HandleException(ExceptionDispatchInfo capturedException)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.ErrorResponses.ErrorResponseMessageException
InvocationInfo : {Set-AzPolicyExemption}
Line : Set-AzPolicyExemption -ResourceId "/subscriptions/d926280d-abb2-4fb3-a5d8-262c8da77c2e/providers/Microsoft.Authorization/policyExemptions/2bb37db403eb46e5a5644de9" -Description
"a"
Position : At line:1 char:1
+ Set-AzPolicyExemption -ResourceId "/subscriptions/d926280d-abb2-4fb3- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 2

The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.

DEBUG: AzureQoSEvent: Module: Az.Accounts:2.10.4; CommandName: Resolve-AzError; PSVersion: 5.1.22621.2506; IsSuccess: True; Duration: 00:00:00.1435075
DEBUG: 10:50:24 - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = [].
DEBUG: 10:50:24 - ResolveError end processing.
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the Set-AzPolicyExemption cmdlet and compare its debug request with the Policy Exemptions - Create Or Update REST API example and the Azure Portal request. Done means updating an exemption for a policy-definition assignment succeeds and sends policyDefinitionReferenceIds as an empty array rather than an array containing an empty array.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cli, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.