Skip to content

Fix Azure resource policy apply: 400 on permanent assignments + surface ARM error - #273

Merged
kayasax merged 1 commit into
kayasax:mainfrom
SebastianClaesson:fix/azure-resource-policy-expiration
Sep 24, 2026
Merged

kayasax merged 1 commit into
kayasax:mainfrom
SebastianClaesson:fix/azure-resource-policy-expiration

Conversation

@SebastianClaesson

Copy link
Copy Markdown

Fixes #272.

The Azure branch of the policy rule builders sent maximumDuration even when isExpirationRequired was false, which ARM rejects, so applying an Azure resource role policy with AllowPermanent* = true failed with 400. The Entra branch already guards against this.

Changes:

  • Set-ActiveAssignment / Set-EligibilityAssignment: the Azure branch now omits maximumDuration when isExpirationRequired is false, the same way the Entra branch does.
  • Set-ActiveAssignment: the Azure Expiration_Admin_Assignment rule used target.level "Eligibility"; changed to "Assignment".
  • Invoke-ARM: include the ARM error response body ($_.ErrorDetails.Message, falling back to the response stream) in the failure so 400s show the actual error.code / error.message.

The duration/level changes only touch the Azure (non -EntraRole) code path; the Entra path is unchanged. All three functions parse clean.

- Set-ActiveAssignment / Set-EligibilityAssignment: the Azure branch now omits
  maximumDuration when isExpirationRequired is false, matching the Entra branch.
  Azure ARM rejects an expiration rule that carries maximumDuration together with
  isExpirationRequired:false, so applying an Azure resource policy with
  AllowPermanent* = true returned 400.
- Set-ActiveAssignment: the Azure Expiration_Admin_Assignment rule used
  target.level "Eligibility"; changed to "Assignment".
- Invoke-ARM: include the ARM error response body ($_.ErrorDetails.Message) in the
  failure message instead of only the status line, so ARM 400s are diagnosable.

Fixes kayasax#272
@kayasax
kayasax merged commit 6ee1b6c into kayasax:main Sep 24, 2026
@kayasax kayasax mentioned this pull request Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure resource policy apply sends maximumDuration when isExpirationRequired is false (ARM 400)

3 participants