Migrate Azure Backup tools to new tool design#2888
Open
alzimmermsft wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Azure Backup tool implementation to the newer command/options design where option registration and binding are driven by [Option] attributes (and subscription resolution is provided via ISubscriptionResolver), updating both production commands and unit tests accordingly.
Changes:
- Refactors Azure Backup commands to use the
SubscriptionCommand<TOptions, TResult>/BaseAzureBackupCommand<TOptions, TResult>pattern andValidateOptions(...)for validation. - Migrates many Azure Backup options POCOs from
JsonPropertyName-based binding to[Option]attribute metadata (including introducingVaultGetOptions). - Updates Azure Backup unit tests to the newer command test base and adjusts DI setup accordingly.
Invoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with write access to the repo need to validate the contents of this PR before leaving a comment with the text /azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.
Reviewed changes
Copilot reviewed 64 out of 64 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Vault/VaultUpdateCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Vault/VaultGetCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Vault/VaultCreateCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Security/SecurityConfigureMuaCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Security/SecurityConfigureEncryptionCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/RecoveryPoint/RecoveryPointGetCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/ProtectedItem/ProtectedItemUndeleteCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/ProtectedItem/ProtectedItemProtectCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/ProtectedItem/ProtectedItemGetCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/ProtectableItem/ProtectableItemListCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Policy/PolicyUpdateCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Policy/PolicyGetCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Policy/PolicyCreateCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Job/JobGetCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Governance/GovernanceSoftDeleteCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Governance/GovernanceImmutabilityCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Governance/GovernanceFindUnprotectedCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/DisasterRecovery/DisasterRecoveryEnableCrrCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Backup/BackupStatusCommandTests.cs | Updates test base class/imports for subscription-aware command testing. |
| tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/AzureBackupSetupTests.cs | Updates test DI container to include ISubscriptionResolver. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Services/AzureBackupService.cs | Removes an unused Azure.ResourceManager using after refactor. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Vault/VaultUpdateOptions.cs | Migrates vault update option metadata to [Option] attributes and renames soft-delete property. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Vault/VaultGetOptions.cs | Adds new options model for vault get/list in the new design. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Vault/VaultCreateOptions.cs | Migrates vault create option metadata to [Option] attributes and makes location required. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Security/SecurityConfigureMuaOptions.cs | Migrates MUA option metadata to [Option] attributes. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Security/SecurityConfigureEncryptionOptions.cs | Migrates CMK encryption option metadata to [Option] attributes and marks key fields required. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/RecoveryPoint/RecoveryPointGetOptions.cs | Refactors recovery point options to the new base/options model. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/ProtectedItem/ProtectedItemUndeleteOptions.cs | Migrates undelete option metadata to [Option] attributes and makes datasource ID required. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/ProtectedItem/ProtectedItemProtectOptions.cs | Migrates protect option metadata to [Option] attributes (includes AKS-specific options). |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/ProtectableItem/ProtectableItemListOptions.cs | Migrates protectable item list option metadata to [Option] attributes. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Policy/PolicyUpdateOptions.cs | Migrates policy update option metadata to [Option] attributes and makes policy required. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Policy/PolicyGetOptions.cs | Migrates policy get option metadata to [Option] attributes. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Policy/PolicyCreateOptions.cs | Migrates policy create flag surface to [Option] attributes (expanded schedule/retention flags). |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Job/JobGetOptions.cs | Migrates job get option metadata to [Option] attributes. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Governance/GovernanceSoftDeleteOptions.cs | Migrates soft delete governance option metadata to [Option] attributes and makes soft-delete required. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Governance/GovernanceImmutabilityOptions.cs | Migrates immutability governance option metadata to [Option] attributes and makes immutability required. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Governance/GovernanceFindUnprotectedOptions.cs | Refactors scan options to implement ISubscriptionOption and use [Option] attributes. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/BaseProtectedItemOptions.cs | Migrates protected-item option metadata to [Option] attributes. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/BaseAzureBackupOptions.cs | Refactors common vault/resource-group/subscription options to ISubscriptionOption + [Option] attributes. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/Backup/BackupStatusOptions.cs | Refactors backup status options to ISubscriptionOption + [Option] attributes. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Options/AzureBackupOptionDefinitions.cs | Reworks option definitions to focus on descriptive strings for attribute-driven metadata. |
| tools/Azure.Mcp.Tools.AzureBackup/src/GlobalUsings.cs | Removes global System.CommandLine using (no longer needed with new approach). |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Vault/VaultUpdateCommand.cs | Refactors command to new base class signature, option binding, and validation. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Vault/VaultGetCommand.cs | Refactors command to new subscription command pattern and new options type. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Vault/VaultCreateCommand.cs | Refactors command to new base class signature and validation approach. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Security/SecurityConfigureMuaCommand.cs | Refactors command to new base class signature and validation approach. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Security/SecurityConfigureEncryptionCommand.cs | Refactors command to new base class signature and validation approach. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/RecoveryPoint/RecoveryPointGetCommand.cs | Refactors command to new base class signature and new options type. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/ProtectedItem/ProtectedItemUndeleteCommand.cs | Refactors command to new base class signature and attribute-driven options. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/ProtectedItem/ProtectedItemProtectCommand.cs | Refactors command to new base class signature and attribute-driven options. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/ProtectedItem/ProtectedItemGetCommand.cs | Refactors command to new base class signature and attribute-driven options. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/ProtectableItem/ProtectableItemListCommand.cs | Refactors command to new base class signature and moves workload validation to ValidateOptions. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Policy/PolicyUpdateCommand.cs | Refactors command to new base class signature and attribute-driven options. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Policy/PolicyGetCommand.cs | Refactors command to new base class signature and attribute-driven options. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Policy/PolicyCreateCommand.cs | Refactors command to new base class signature and attribute-driven options (builds request DTO). |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Job/JobGetCommand.cs | Refactors command to new base class signature and attribute-driven options. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Governance/GovernanceSoftDeleteCommand.cs | Refactors command to new base class signature and validation approach. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Governance/GovernanceImmutabilityCommand.cs | Refactors command to new base class signature and validation approach. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Governance/GovernanceFindUnprotectedCommand.cs | Refactors command to new subscription command pattern and new options type. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/DisasterRecovery/DisasterRecoveryEnableCrrCommand.cs | Refactors command to new base class signature and attribute-driven options. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/BaseProtectedItemCommand.cs | Removes legacy protected-item command base class (no longer needed with attribute model). |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/BaseAzureBackupCommand.cs | Introduces new generic base command using subscription resolver + ValidateOptions. |
| tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Backup/BackupStatusCommand.cs | Refactors command to new subscription command pattern and new options type. |
| servers/Azure.Mcp.Server/changelog-entries/1781549268619.yaml | Adds changelog entry describing breaking change for Azure Backup tools. |
Comment on lines
+32
to
43
| [Option("Interval in hours between hourly backups. Valid values: 4, 6, 8, 12. Used only when --schedule-frequency is 'Hourly' (RSV).")] | ||
| public int HourlyIntervalHours { get; set; } | ||
|
|
||
| [JsonPropertyName(AzureBackupOptionDefinitions.HourlyWindowStartTimeName)] | ||
| [Option("Start time of the hourly backup window in 24h HH:mm format (e.g., '08:00'). Used only when --schedule-frequency is 'Hourly' (RSV).")] | ||
| public string? HourlyWindowStartTime { get; set; } | ||
|
|
||
| [JsonPropertyName(AzureBackupOptionDefinitions.HourlyWindowDurationHoursName)] | ||
| [Option("Duration of the hourly backup window in hours (e.g., 12). Used only when --schedule-frequency is 'Hourly' (RSV).")] | ||
| public int HourlyWindowDurationHours { get; set; } | ||
|
|
||
| // Retention flags (new in policy create overhaul; not yet consumed by builders). | ||
| [JsonPropertyName(AzureBackupOptionDefinitions.WeeklyRetentionWeeksName)] | ||
| [Option("Number of weeks to keep weekly recovery points. Required alongside --weekly-retention-days-of-week.")] | ||
| public int WeeklyRetentionWeeks { get; set; } |
Comment on lines
+119
to
132
| [Option("Enable backup compression at the policy level. RSV VmWorkload only.")] | ||
| public bool IsCompression { get; set; } | ||
|
|
||
| [JsonPropertyName(AzureBackupOptionDefinitions.IsSqlCompressionName)] | ||
| [Option("Enable SQL Server on VM native backup compression. RSV SQL only.")] | ||
| public bool IsSqlCompression { get; set; } | ||
|
|
||
| // ===== Stage 2 expansion ===== | ||
|
|
||
|
|
||
| [JsonPropertyName(AzureBackupOptionDefinitions.SmartTierName)] | ||
| [Option("Enable smart-tiering (ML-based archive recommendation). RSV VM only - equivalent to TieringMode=TierRecommended. Kept separate from --archive-tier-mode because it emits a structurally different tiering shape (Duration=0, DurationType=Invalid).")] | ||
| public bool SmartTier { get; set; } | ||
|
|
||
| [JsonPropertyName(AzureBackupOptionDefinitions.EnableSnapshotBackupName)] | ||
| [Option("Enable snapshot/instance backups (HANA System Replication snapshot RPs). RSV SAPHANA only.")] | ||
| public bool EnableSnapshotBackup { get; set; } |
Comment on lines
+140
to
150
| [Option("Enable vault-tier copy of operational store backups. DPP AzureDisk only.")] | ||
| public bool EnableVaultTierCopy { get; set; } | ||
|
|
||
| [JsonPropertyName(AzureBackupOptionDefinitions.VaultTierCopyAfterDaysName)] | ||
| [Option("Days after which an operational backup is copied to the vault tier. DPP AzureDisk only.")] | ||
| public int VaultTierCopyAfterDays { get; set; } | ||
|
|
||
| [JsonPropertyName(AzureBackupOptionDefinitions.BackupModeName)] | ||
| [Option("Backup mode for storage workloads: 'Continuous' (default for AzureBlob, ADLS) or 'Vaulted' (discrete recovery points). DPP AzureBlob, AzureDataLakeStorage.")] | ||
| public string? BackupMode { get; set; } | ||
|
|
||
| [JsonPropertyName(AzureBackupOptionDefinitions.PitrRetentionDaysName)] | ||
| [Option("Point-in-time restore retention in days for continuous backups. DPP AzureBlob, AzureDataLakeStorage.")] | ||
| public int PitrRetentionDays { get; set; } |
Comment on lines
+25
to
26
| [Option("Resource group used to store AKS volume snapshots created by Backup. DPP AKS only.")] | ||
| public string? AksExcludedNamespaces { get; set; } |
Comment on lines
+31
to
32
| [Option("Include cluster-scoped resources in the AKS backup policy. DPP AKS only.")] | ||
| public bool AksIncludeClusterScopeResources { get; set; } |
Comment on lines
+23
to
+24
| [Option(AzureBackupOptionDefinitions.LocationName)] | ||
| public required string Location { get; set; } |
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.
What does this PR do?
Migrates Azure Backup tools to new design where Register and Bind options are based on
Optionattributes.GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationREADME.mdchanges running the script./eng/scripts/Process-PackageReadMe.ps1. See Package READMEToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.jsonbreaking-changelabelservers/Azure.Mcp.Server/docs/azmcp-commands.md./eng/scripts/Update-AzCommandsMetadata.ps1to update tool metadata inazmcp-commands.md(required for CI)servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline