Skip to content

Migrate Azure Backup tools to new tool design#2888

Open
alzimmermsft wants to merge 2 commits into
microsoft:mainfrom
alzimmermsft:MigrateAzureBackupToNewToolDesign
Open

Migrate Azure Backup tools to new tool design#2888
alzimmermsft wants to merge 2 commits into
microsoft:mainfrom
alzimmermsft:MigrateAzureBackupToNewToolDesign

Conversation

@alzimmermsft

Copy link
Copy Markdown
Contributor

What does this PR do?

Migrates Azure Backup tools to new design where Register and Bind options are based on Option attributes.

GitHub issue number?

[Link to the GitHub issue this PR addresses]

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated dependencies. Follow the changelog entry guide
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • Updated test prompts in servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 and ValidateOptions(...) for validation.
  • Migrates many Azure Backup options POCOs from JsonPropertyName-based binding to [Option] attribute metadata (including introducing VaultGetOptions).
  • 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; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants