feat: Add keyvault copy command#32742
feat: Add keyvault copy command#32742jcassanji-southworks wants to merge 24 commits intoAzure:devfrom
Conversation
❌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.
Pull request overview
This PR introduces a new az keyvault secret copy command to simplify copying secrets between Azure Key Vaults. The implementation adds functionality to copy individual secrets or all secrets in bulk, with support for metadata preservation and overwrite control.
Changes:
- Added
copy_secretfunction incustom.pywith core logic for copying secrets between vaults - Registered the
copycommand under thekeyvault secretgroup incommands.py - Defined command parameters (source-vault, destination-vault, name, all, overwrite) in
_params.py - Added comprehensive help documentation with usage examples in
_help.py - Created integration test suite
KeyVaultCopyScenarioTestintest_keyvault_commands.py
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/keyvault/custom.py | Implements the core copy_secret function with secret retrieval, metadata preservation, and bulk/single copy logic |
| src/azure-cli/azure/cli/command_modules/keyvault/commands.py | Registers the new copy command under the keyvault secret command group |
| src/azure-cli/azure/cli/command_modules/keyvault/_params.py | Defines CLI arguments for source-vault, destination-vault, name, all, and overwrite parameters |
| src/azure-cli/azure/cli/command_modules/keyvault/_help.py | Provides command documentation including short/long summaries and usage examples |
| src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py | Adds integration tests covering single copy, bulk copy, overwrite protection, and metadata preservation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Show resolved
Hide resolved
…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
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
Show resolved
Hide resolved
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
Summary
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.Description
The new command allows users to:
--allflag.--overwriteflag.Syntax:
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 to:
This new command standardizes and simplifies this common workflow into a single CLI operation.
Key Benefits:
Implementation Details
copycommand underkeyvault secretgroup incommands.py._params.pyadhering to CLI standards usingget_three_state_flag.custom.pyusingazure-keyvault-secretstrack2 SDK.test_keyvault_commands.pycovering:_help.py.Testing
KeyVaultCopyScenarioTestintest_keyvault_commands.py.python -m azure.cli.