Skip to content

Commit be87e03

Browse files
authored
[Az.RecoveryServices.Backup] Minor fixes (#23861)
* 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
1 parent 6cd651e commit be87e03

File tree

15 files changed

+6822
-3231
lines changed

15 files changed

+6822
-3231
lines changed

src/RecoveryServices/RecoveryServices.Backup.Models/Properties/Resources.Designer.cs

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RecoveryServices/RecoveryServices.Backup.Models/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,4 +844,7 @@ Please contact Microsoft for further assistance.</value>
844844
<data name="UnbakedSnapshotRecoveryPoint" xml:space="preserve">
845845
<value>Snapshot recovery point time is less than 4 Hrs ago, please try later or with another recovery point</value>
846846
</data>
847+
<data name="StdToEnhPolicyMigrationWarning" xml:space="preserve">
848+
<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>
849+
</data>
847850
</root>

src/RecoveryServices/RecoveryServices.Backup.Providers/AzureWorkloadProviderHelper.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,16 @@ public void RegisterContainer(string containerName,
7777
protectionContainerResource,
7878
vaultName,
7979
vaultResourceGroupName);
80+
81+
// registerResponse.Body.GetType().ToString() --> Microsoft.Azure.Management.RecoveryServices.Backup.Models.ProtectionContainerResource
82+
if (registerResponse.Body == null || registerResponse.Body.Properties == null || registerResponse.Body.Properties.RegistrationStatus.ToLower() != "registered")
83+
{
84+
string errorMessage = string.Format(Resources.RegisterFailureErrorCode,
85+
registerResponse.Response.StatusCode);
86+
Logger.Instance.WriteDebug(errorMessage);
87+
}
8088

81-
var operationStatus = TrackingHelpers.GetOperationResult(
89+
/* var operationStatus = TrackingHelpers.GetOperationResult(
8290
registerResponse,
8391
operationId =>
8492
ServiceClientAdapter.GetRegisterContainerOperationResult(
@@ -94,7 +102,7 @@ public void RegisterContainer(string containerName,
94102
string errorMessage = string.Format(Resources.RegisterFailureErrorCode,
95103
registerResponse.Response.StatusCode);
96104
Logger.Instance.WriteDebug(errorMessage);
97-
}
105+
} */
98106
}
99107

100108
public List<ProtectedItemResource> ListProtectedItemsByContainer(

src/RecoveryServices/RecoveryServices.Backup.Providers/Providers/IaasVmPsBackupProvider.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ public RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtectio
9393
ProtectionPolicyResource oldPolicy = null;
9494
ProtectionPolicyResource newPolicy = null;
9595
if (parameterSetName.Contains("Modify") && item.PolicyId != null && item.PolicyId != "")
96-
{
96+
{
9797
Dictionary<UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.PolicyId);
9898
string oldPolicyName = HelperUtils.GetPolicyNameFromPolicyId(keyValueDict, item.PolicyId);
9999

100100
keyValueDict = HelperUtils.ParseUri(policy.Id);
101101
string newPolicyName = HelperUtils.GetPolicyNameFromPolicyId(keyValueDict, policy.Id);
102-
102+
103103
// fetch old and new Policy
104104
oldPolicy = ServiceClientAdapter.GetProtectionPolicy(
105105
oldPolicyName,
106106
vaultName: vaultName,
107107
resourceGroupName: resourceGroupName);
108-
108+
109109
newPolicy = ServiceClientAdapter.GetProtectionPolicy(
110110
newPolicyName,
111111
vaultName: vaultName,
112-
resourceGroupName: resourceGroupName);
112+
resourceGroupName: resourceGroupName);
113113
}
114114

115115
bool isDiskExclusionParamPresent = ValidateDiskExclusionParameters(
116-
inclusionDisksList, exclusionDisksList, resetDiskExclusionSetting, excludeAllDataDisks);
116+
inclusionDisksList, exclusionDisksList, resetDiskExclusionSetting, excludeAllDataDisks);
117117

118118
// do validations
119119
string containerUri = "";
@@ -250,6 +250,22 @@ public RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtectio
250250
if (parameterSetName.Contains("Modify") && oldPolicy != null && newPolicy != null)
251251
{
252252
isMUAProtected = AzureWorkloadProviderHelper.checkMUAForModifyPolicy(oldPolicy, newPolicy, isMUAOperation);
253+
254+
#region validate Std to Enh policy migration
255+
string oldPolicyType = ((ServiceClientModel.AzureIaaSVMProtectionPolicy)oldPolicy.Properties).PolicyType;
256+
257+
PSPolicyType oldPolicySubType = (oldPolicyType != null && oldPolicyType.ToLower().Contains("v2")) ? PSPolicyType.Enhanced : PSPolicyType.Standard;
258+
259+
string newPolicyType = ((ServiceClientModel.AzureIaaSVMProtectionPolicy)newPolicy.Properties).PolicyType;
260+
261+
PSPolicyType newPolicySubType = (newPolicyType != null && newPolicyType.ToLower().Contains("v2")) ? PSPolicyType.Enhanced : PSPolicyType.Standard;
262+
263+
if (oldPolicySubType == PSPolicyType.Standard && newPolicySubType == PSPolicyType.Enhanced)
264+
{
265+
// resx Resources.StdToEnhPolicyMigrationWarning
266+
Logger.Instance.WriteWarning(String.Format(Resources.StdToEnhPolicyMigrationWarning));
267+
}
268+
#endregion
253269
}
254270

255271
return ServiceClientAdapter.CreateOrUpdateProtectedItem(

0 commit comments

Comments
 (0)