[KeyVault] Fix New-AzKeyVault RequestDisallowedByPolicy error by explicitly setting enableSoftDelete in the request body#29497
Open
rahulalapati43 wants to merge 2 commits intoAzure:mainfrom
Conversation
…ableSoftDelete Explicitly set EnableSoftDelete=true in the request body for New-AzKeyVault to satisfy Azure Policy checks that require the property to be present. While soft delete is already enabled by default on the service side, Azure Policy checks may require the property to be explicitly present in the request body. Without it, New-AzKeyVault fails with a RequestDisallowedByPolicy error when such policies are enforced. This is a non-breaking fix - no new parameters are exposed and customer behavior is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the KeyVault module so New-AzKeyVault explicitly sends enableSoftDelete=true during vault creation, matching Azure Policy expectations and the related Azure CLI fix. It is a small, targeted change in the SDK-based KeyVault cmdlet plus accompanying release-note and test updates.
Changes:
- Set
EnableSoftDelete = trueinNew-AzKeyVaultrequest construction. - Add a new unit test intended to validate soft-delete request behavior.
- Add an upcoming release note for the policy-related fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/KeyVault/KeyVault/Commands/KeyVault/NewAzureKeyVault.cs |
Forces EnableSoftDelete into the create request body for new vaults. |
src/KeyVault/KeyVault.Test/UnitTests/NewAzureKeyVaultSoftDeleteTests.cs |
Adds test coverage around soft-delete handling in vault creation. |
src/KeyVault/KeyVault/ChangeLog.md |
Documents the fix for the next KeyVault release notes. |
Collaborator
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
Add a proper regression test that exercises NewAzureKeyVault.ExecuteCmdlet() end-to-end and verifies that EnableSoftDelete=true is always present in the outgoing SDK request body. This ensures Azure Policy checks requiring the property to be present are satisfied. The previous test only verified the pass-through client layer with EnableSoftDelete already set to true in the input, so it would keep passing even if the cmdlet's hardcoded assignment regressed. New tests: - ExecuteCmdlet_Sets_EnableSoftDelete_True_In_Request: full cmdlet path test - VaultManagementClient_Does_Not_Default_EnableSoftDelete: proves client is a pure pass-through (null in = null out), establishing that only the cmdlet provides the value Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Explicitly set EnableSoftDelete=true in the request body for New-AzKeyVault to satisfy Azure Policy checks that require the property to be present.
While soft delete is already enabled by default on the service side, Azure Policy checks may require the property to be explicitly present in the request body. Without it, New-AzKeyVault fails with a RequestDisallowedByPolicy error when such policies are enforced.
This is a non-breaking fix — no new parameters are exposed and customer behavior is unchanged.
Related CLI PR
Azure/azure-cli#33265
Testing Guide
Basic vault creation (should succeed without RequestDisallowedByPolicy)
New-AzKeyVault -Name -ResourceGroupName -Location
Verify soft delete is enabled on the created vault
(Get-AzKeyVault -VaultName ).EnableSoftDelete
Expected: True
Changes
This checklist is used to make sure that common guidelines for a pull request are followed.