Skip to content

Commit 756dea8

Browse files
authored
Merge pull request #11394 from MabOneSdk/users/sarath/user-rg
[RecoveryServices.Backup] Added User ResourceGroup Feature in IAASVM policy
2 parents feaa860 + 279bb69 commit 756dea8

File tree

7 files changed

+266
-239
lines changed

7 files changed

+266
-239
lines changed

src/RecoveryServices/RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ public static PolicyBase GetPolicyModelForAzureIaaSVM(ServiceClientModel.Protect
170170
iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((ServiceClientModel.SimpleSchedulePolicy)
171171
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy,
172172
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).TimeZone);
173+
iaasPolicyModel.AzureBackupRGName =
174+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).InstantRPDetails.AzureBackupRGNamePrefix;
175+
iaasPolicyModel.AzureBackupRGNameSuffix =
176+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).InstantRPDetails.AzureBackupRGNameSuffix;
173177
return policyModel;
174178
}
175179

src/RecoveryServices/RecoveryServices.Backup.Models/AzureVmModels/AzureVmPolicy.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Compute.Version_2018_04.Models;
16+
1517
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
1618
{
1719
/// <summary>
@@ -28,6 +30,16 @@ public class AzureVmPolicy : AzurePolicy
2830
/// Object defining the number of associated items for the policy
2931
/// </summary>
3032
public int? ProtectedItemsCount { get; set; }
33+
34+
/// <summary>
35+
/// object defining the RG Name to store Restore Points
36+
/// </summary>
37+
public string AzureBackupRGName { get; set; }
38+
39+
/// <summary>
40+
/// object defining the RG Name suffix to store Restore Points
41+
/// </summary>
42+
public string AzureBackupRGNameSuffix { get; set; }
3143
}
3244

3345
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,10 @@ public RestAzureNS.AzureOperationResponse<ProtectionPolicyResource> ModifyPolicy
753753
SchedulePolicy = PolicyHelpers.GetServiceClientSimpleSchedulePolicy(
754754
(CmdletModel.SimpleSchedulePolicy)((AzureVmPolicy)policy).SchedulePolicy),
755755
TimeZone = DateTimeKind.Utc.ToString().ToUpper(),
756-
InstantRpRetentionRangeInDays = ((AzureVmPolicy)policy).SnapshotRetentionInDays
756+
InstantRpRetentionRangeInDays = ((AzureVmPolicy)policy).SnapshotRetentionInDays,
757+
InstantRPDetails = new InstantRPAdditionalDetails(
758+
((AzureVmPolicy)policy).AzureBackupRGName,
759+
((AzureVmPolicy)policy).AzureBackupRGNameSuffix)
757760
}
758761
};
759762

src/RecoveryServices/RecoveryServices.Backup.Test/ScenarioTests/IaasVm/PolicyTests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ $policyName = "PsTestPolicy";
1818
$defaultPolicyName = "DefaultPolicy";
1919
$DefaultSnapshotDays = 2;
2020
$UpdatedSnapShotDays = 5;
21+
$rgPrefix = "RecoveryServices";
22+
$rgsuffix = "Policy";
2123

2224
# Test old polices in the VaultId
2325
$oldResourceGroupName = "sambit_rg"
@@ -78,6 +80,8 @@ function Test-AzureVMPolicy
7880

7981
#update snapshot days
8082
$policy.SnapshotRetentionInDays = $UpdatedSnapShotDays;
83+
$policy.AzureBackupRGName = $rgPrefix;
84+
$policy.AzureBackupRGNameSuffix = $rgsuffix;
8185

8286
# Update policy
8387
Set-AzRecoveryServicesBackupProtectionPolicy `

src/RecoveryServices/RecoveryServices.Backup.Test/SessionRecords/Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.PolicyTests/TestAzureVMPolicy.json

Lines changed: 238 additions & 238 deletions
Large diffs are not rendered by default.

src/RecoveryServices/RecoveryServices/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* Azure Backup added support for retrying policy update for failed items.
2424
* Azure Backup Added support for disk exclusion settings during backup and restore.
2525
* Azure Backup Added Support for Restoring Multiple files/folders in AzureFileShare
26+
* Azure Backup Added support for User-specified Resourcegroup support while updating IaasVM Policy
2627

2728
## Version 2.7.0
2829
* Added Support for Restore-as-files for SQL Databases.

src/RecoveryServices/RecoveryServices/help/Set-AzRecoveryServicesBackupProtectionPolicy.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ PS C:\> $SchPol.ScheduleRunTimes.Add($DT.ToUniversalTime())
4343
PS C:\> $RetPol = Get-AzRecoveryServicesBackupRetentionPolicyObject -WorkloadType "AzureVM"
4444
PS C:\> $RetPol.DailySchedule.DurationCountInDays = 365
4545
PS C:\> $Pol = Get-AzRecoveryServicesBackupProtectionPolicy -Name "NewPolicy"
46+
PS C:\> $Pol.AzureBackupRGName = "RG_prefix"
47+
PS C:\> $Pol.AzureBackupRGNameSuffix = "RG_suffix"
4648
PS C:\> Set-AzRecoveryServicesBackupProtectionPolicy -Policy $Pol -SchedulePolicy $SchPol -RetentionPolicy $RetPol
4749
```
4850

@@ -53,6 +55,7 @@ The fourth command adds the date and time in $DT to the schedule run time for th
5355
The fifth command gets a base retention policy object, and then stores it in the $RetPol variable.
5456
The sixth command sets the retention duration to 365 days.
5557
The seventh command gets the Backup protection policy named NewPolicy, and then stores it in the $Pol variable.
58+
The eighth and ninth sets the resource group parameters associated with policy which stores the restore points.
5659
The final command modifies the Backup protection policy in $Pol using schedule policy in $SchPol and the retention policy in $RetPol.
5760

5861
## PARAMETERS

0 commit comments

Comments
 (0)