Skip to content

[Az.RecoveryServices.Backup] Added suspend backup as MUA protected operation #27835

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

Merged
merged 2 commits into from
May 26, 2025

Conversation

hiaga
Copy link
Member

@hiaga hiaga commented May 26, 2025

Description

Added suspend backup as MUA protected operation i.e. RetainRecoveryPointsAsPerPolicy as MUA protected operation in Disable-AzRecoveryServicesBackupProtection cmdlet.

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

@Copilot Copilot AI review requested due to automatic review settings May 26, 2025 03:19
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds suspend backup as an MUA-protected operation and updates related cmdlets, providers, and tests.

  • Documented the new RetainRecoveryPointsAsPerPolicy option in ChangeLog.
  • Updated the Disable-AzRecoveryServicesBackupProtection cmdlet and provider SuspendBackup methods to accept an auxiliary access token and MUA flag.
  • Extended PowerShell and C# scenario tests to cover the suspend backup flow.
  • Revised the purge date calculation logic in AzureWorkloadSQLDatabaseProtectedItem.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/RecoveryServices/RecoveryServices/ChangeLog.md Added MUA-protected RetainRecoveryPointsAsPerPolicy entry
src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Item/DisableAzureRmRecoveryServicesBackupProtection.cs Removed previous validation to enable suspend backup scenario
src/RecoveryServices/RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.ps1 Updated VM names and added suspend backup assertions
src/RecoveryServices/RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.cs Un-skipped the MUA test case
src/RecoveryServices/RecoveryServices.Backup.Providers/Providers/IaasVmPsBackupProvider.cs Added auxiliaryAccessToken and isMUAProtected parameters
src/RecoveryServices/RecoveryServices.Backup.Providers/Providers/AzureWorkloadPsBackupProvider.cs Same for Azure workload provider
src/RecoveryServices/RecoveryServices.Backup.Providers/Providers/AzureFilesPsBackupProvider.cs Same for Azure files provider
src/RecoveryServices/RecoveryServices.Backup.Models/AzureVmWorkloadModels/AzureWorkloadSQLDatabaseProtectedItem.cs Changed purge date computation to use DateTime.UtcNow
Comments suppressed due to low confidence (1)

src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Item/DisableAzureRmRecoveryServicesBackupProtection.cs:103

  • The variable 'plainToken' is assigned but never used after removing the previous validation block. Consider removing this unused variable to clean up the code.
string plainToken = HelperUtils.GetPlainToken(Token, SecureToken);

Comment on lines +291 to +292
string auxiliaryAccessToken = ProviderData.ContainsKey(ResourceGuardParams.Token) ? (string)ProviderData[ResourceGuardParams.Token] : null;
bool isMUAProtected = true;
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This initialization of 'auxiliaryAccessToken' and the 'isMUAProtected' flag is duplicated across multiple providers. Consider refactoring into a shared helper to reduce code duplication.

Suggested change
string auxiliaryAccessToken = ProviderData.ContainsKey(ResourceGuardParams.Token) ? (string)ProviderData[ResourceGuardParams.Token] : null;
bool isMUAProtected = true;
(string auxiliaryAccessToken, bool isMUAProtected) = GetAuxiliaryAccessTokenAndMUAProtection();

Copilot uses AI. Check for mistakes.

resourceGroupName: resourceGroupName,
auxiliaryAccessToken,
isMUAProtected,
true);
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Passing a positional boolean literal 'true' makes the argument’s intent unclear. Consider using a named argument or constant to clarify its purpose.

Suggested change
true);
enableValidation: true);

Copilot uses AI. Check for mistakes.

@@ -129,6 +129,9 @@ public RestAzureNS.AzureOperationResponse<ProtectedItemResource> SuspendBackup()
string resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName];

ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item];

string auxiliaryAccessToken = ProviderData.ContainsKey(ResourceGuardParams.Token) ? (string)ProviderData[ResourceGuardParams.Token] : null;
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This initialization is duplicated from other providers. Consider refactoring into a shared helper method to reduce code duplication.

Suggested change
string auxiliaryAccessToken = ProviderData.ContainsKey(ResourceGuardParams.Token) ? (string)ProviderData[ResourceGuardParams.Token] : null;
string auxiliaryAccessToken = GetAuxiliaryAccessToken();

Copilot uses AI. Check for mistakes.

@msJinLei
Copy link
Contributor

/azp run

Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@@ -101,11 +101,7 @@ public override void ExecuteCmdlet()
string resourceGroupName = resourceIdentifier.ResourceGroupName;

string plainToken = HelperUtils.GetPlainToken(Token, SecureToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use SecureStringExtensions.ConvertToString

@msJinLei msJinLei merged commit 418bf26 into Azure:main May 26, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants