-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[KeyVault] az keyvault secret copy: Add command to copy secrets between vaults #32751
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
base: dev
Are you sure you want to change the base?
[KeyVault] az keyvault secret copy: Add command to copy secrets between vaults #32751
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
|
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| keyvault secret copy | cmd keyvault secret copy added |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
Thank you for your contribution @jcassanji-southworks! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.