Skip to content

Commit

Permalink
[Az.RecoveryServices.Backup] Minor fixes (Azure#23861)
Browse files Browse the repository at this point in the history
* Added warning for Standard to Enhanced policy migration for AzureVMs. Updated Unregister-AzRecoveryServicesBackupContainer command to ouptput Job object if PassThru not given

* fixed AFS register container \n Fixed issue with Get-AzRecoveryServicesVaultSettingsFile cmdlet

* suppressed breaking change warning
re-recorded failed tests
updated Change log

* resolved review comments
  • Loading branch information
hiaga authored Jan 15, 2024
1 parent 6cd651e commit be87e03
Show file tree
Hide file tree
Showing 15 changed files with 6,822 additions and 3,231 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -844,4 +844,7 @@ Please contact Microsoft for further assistance.</value>
<data name="UnbakedSnapshotRecoveryPoint" xml:space="preserve">
<value>Snapshot recovery point time is less than 4 Hrs ago, please try later or with another recovery point</value>
</data>
<data name="StdToEnhPolicyMigrationWarning" xml:space="preserve">
<value>Upgrading to enhanced policy can incur additional charges. Once upgraded to the enhanced policy, it is not possible to revert back to the standard policy</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,16 @@ public void RegisterContainer(string containerName,
protectionContainerResource,
vaultName,
vaultResourceGroupName);

// registerResponse.Body.GetType().ToString() --> Microsoft.Azure.Management.RecoveryServices.Backup.Models.ProtectionContainerResource
if (registerResponse.Body == null || registerResponse.Body.Properties == null || registerResponse.Body.Properties.RegistrationStatus.ToLower() != "registered")
{
string errorMessage = string.Format(Resources.RegisterFailureErrorCode,
registerResponse.Response.StatusCode);
Logger.Instance.WriteDebug(errorMessage);
}

var operationStatus = TrackingHelpers.GetOperationResult(
/* var operationStatus = TrackingHelpers.GetOperationResult(
registerResponse,
operationId =>
ServiceClientAdapter.GetRegisterContainerOperationResult(
Expand All @@ -94,7 +102,7 @@ public void RegisterContainer(string containerName,
string errorMessage = string.Format(Resources.RegisterFailureErrorCode,
registerResponse.Response.StatusCode);
Logger.Instance.WriteDebug(errorMessage);
}
} */
}

public List<ProtectedItemResource> ListProtectedItemsByContainer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,27 @@ public RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtectio
ProtectionPolicyResource oldPolicy = null;
ProtectionPolicyResource newPolicy = null;
if (parameterSetName.Contains("Modify") && item.PolicyId != null && item.PolicyId != "")
{
{
Dictionary<UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.PolicyId);
string oldPolicyName = HelperUtils.GetPolicyNameFromPolicyId(keyValueDict, item.PolicyId);

keyValueDict = HelperUtils.ParseUri(policy.Id);
string newPolicyName = HelperUtils.GetPolicyNameFromPolicyId(keyValueDict, policy.Id);

// fetch old and new Policy
oldPolicy = ServiceClientAdapter.GetProtectionPolicy(
oldPolicyName,
vaultName: vaultName,
resourceGroupName: resourceGroupName);

newPolicy = ServiceClientAdapter.GetProtectionPolicy(
newPolicyName,
vaultName: vaultName,
resourceGroupName: resourceGroupName);
resourceGroupName: resourceGroupName);
}

bool isDiskExclusionParamPresent = ValidateDiskExclusionParameters(
inclusionDisksList, exclusionDisksList, resetDiskExclusionSetting, excludeAllDataDisks);
inclusionDisksList, exclusionDisksList, resetDiskExclusionSetting, excludeAllDataDisks);

// do validations
string containerUri = "";
Expand Down Expand Up @@ -250,6 +250,22 @@ public RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtectio
if (parameterSetName.Contains("Modify") && oldPolicy != null && newPolicy != null)
{
isMUAProtected = AzureWorkloadProviderHelper.checkMUAForModifyPolicy(oldPolicy, newPolicy, isMUAOperation);

#region validate Std to Enh policy migration
string oldPolicyType = ((ServiceClientModel.AzureIaaSVMProtectionPolicy)oldPolicy.Properties).PolicyType;

PSPolicyType oldPolicySubType = (oldPolicyType != null && oldPolicyType.ToLower().Contains("v2")) ? PSPolicyType.Enhanced : PSPolicyType.Standard;

string newPolicyType = ((ServiceClientModel.AzureIaaSVMProtectionPolicy)newPolicy.Properties).PolicyType;

PSPolicyType newPolicySubType = (newPolicyType != null && newPolicyType.ToLower().Contains("v2")) ? PSPolicyType.Enhanced : PSPolicyType.Standard;

if (oldPolicySubType == PSPolicyType.Standard && newPolicySubType == PSPolicyType.Enhanced)
{
// resx Resources.StdToEnhPolicyMigrationWarning
Logger.Instance.WriteWarning(String.Format(Resources.StdToEnhPolicyMigrationWarning));
}
#endregion
}

return ServiceClientAdapter.CreateOrUpdateProtectedItem(
Expand Down
Loading

0 comments on commit be87e03

Please sign in to comment.