[KeyVault] az keyvault secret copy: Add command to copy secrets between vaults#32751
Open
jcassanji-southworks wants to merge 38 commits intoAzure:devfrom
Open
Conversation
…test_keyvault_commands.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…test_keyvault_commands.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…github.com/jcassanji-southworks/azure-cli into jcassanji-southworks/feature-keyvault-copy
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…true and add test for default behavior
…github.com/jcassanji-southworks/azure-cli into jcassanji-southworks/feature-keyvault-copy
…gs and update dummy secret validation call
…ion and refactor copy_secret to utilize it
…/feature-keyvault-copy
❌AzureCLI-FullTest
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new az keyvault secret copy command that enables users to copy secrets between Azure Key Vaults. The command supports copying individual secrets or bulk copying all secrets, with built-in protection against accidental overwrites and automatic filtering of Azure-managed secrets.
Changes:
- Added
copy_secretcommand function with helper_copy_single_secretto handle the copy logic - Registered the new
copycommand in the keyvault secret command group - Added comprehensive parameter definitions for source vault, destination vault, secret selection, and overwrite behavior
- Implemented unit tests covering various scenarios (single copy, bulk copy, overwrite protection)
- Implemented integration tests validating end-to-end functionality
- Added help documentation with usage examples
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/keyvault/custom.py | Core implementation of copy_secret and _copy_single_secret functions with error handling and logging |
| src/azure-cli/azure/cli/command_modules/keyvault/commands.py | Command registration for the new copy command |
| src/azure-cli/azure/cli/command_modules/keyvault/_params.py | Parameter definitions for source-vault, destination-vault, name, all, and overwrite options |
| src/azure-cli/azure/cli/command_modules/keyvault/_help.py | Help text and usage examples for the copy command |
| src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_unit.py | Unit tests for copy functionality covering various scenarios |
| src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py | Integration tests validating end-to-end command behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
az keyvault secret copy: Add command to copy secrets between vaults
…r missing secrets
…ional client configurations
… location parameter for destination Key Vault creation
Refactor credential retrieval logic in Key Vault client.
Refactor KeyVault copy tests to improve structure and clarity, including renaming test classes and methods for better readability. Enhance test coverage for secret copy functionality, including overwrite behavior and error cases.
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.
Related command
az keyvault secret copyDescription
This PR introduces a new command
az keyvault secret copyto simplify the process of copying secrets from one Key Vault to another. It supports copying individual secrets or all secrets in bulk, with options to control overwrite behavior and preserve metadata.Motivation and Benefits
Currently, users needing to migrate or replicate secrets between Key Vaults (e.g., promoting from Dev to Prod, or replicating for DR) must write complex scripts. This new command standardizes this workflow into a single CLI operation.
Implementation Details
keyvault secretgroup.azure-keyvault-secretstrack2 SDK.Testing Guide
Copy a single secret:
Copy all secrets:
Force copy (overwrite existing):
History Notes
[KeyVault]
az keyvault secret copy: Add new command to copy secrets between Key VaultsThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.