Closed Dauntless1121 closed 2 years ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @pvrk, @adityabalaji-msft.
Author: | Dauntless1121 |
---|---|
Assignees: | - |
Labels: | `Recovery Services Backup`, `Service Attention`, `question`, `customer-reported`, `needs-triage` |
Milestone: | - |
@Dauntless1121 - thanks for reaching out. Given that different Azure Backup workloads support different types of policy capabilities, there would be some difference in the policy object schemas for different workload types. For SQL workload, given that it supports full, differential and log backup, I believe you would need to run something like $SchPol.FullBackupPolicySchedule.ScheduleRunTimes,clear()
You can print the contents of SchPol to understand the schema for the given workload type. For SQL, it might look something like the below
IsCompression : False IsDifferentialBackupEnabled : False IsLogBackupEnabled : True FullBackupSchedulePolicy : scheduleRunType:Daily, ScheduleRunDays:{Sunday}, ScheduleRunTimes:{10/1/2021 5:30:00 PM} DifferentialBackupSchedulePolicy : scheduleRunType:Weekly, ScheduleRunDays:{Monday}, ScheduleRunTimes:{10/1/2021 5:30:00 PM} LogBackupSchedulePolicy : Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.LogSchedulePolicy
Agree that we should provide more examples in the documentation to account for the differences between workloads. We will add this to our backlog
Thank you
Yeah I wasted quite a few hours initially assuming I was doing something wrong as the demo code worked perfectly. I'll give your example a go as well in the meantime but updating the documentation would probably save others from my mistake 👍
Description
When using the Get-AzRecoveryServicesBackupRetentionPolicyObject to create a AzureVM workload policy it supports the functions listed at https://docs.microsoft.com/en-us/powershell/module/az.recoveryservices/set-azrecoveryservicesbackupprotectionpolicy?view=azps-6.4.0 such as $BackupPolicy.ScheduleRunTimes.Clear() $BackupPolicy.ScheduleRunTimes.Add($BackupScheduleRunTimes) $BackupPolicy.ScheduleRunDays = $BackupScheduleRetentionInDays
Running the specific functions against MSSQL Workload type produces multiple errors PS /home/ad> $BackupPolicy.ScheduleRunTimes.Clear() InvalidOperation: You cannot call a method on a null-valued expression. PS /home/ad> $BackupPolicy.ScheduleRunTimes.Add($BackupScheduleRunTimes) InvalidOperation: You cannot call a method on a null-valued expression. PS /home/ad> $BackupPolicy.ScheduleRunDays = $BackupScheduleRetentionInDays InvalidOperation: The property 'ScheduleRunDays' cannot be found on this object. Verify that the property exists and can be set.
etc
There seems to be function/feature disparity between the workload types
Steps to reproduce
$SchPol = Get-AzRecoveryServicesBackupSchedulePolicyObject -WorkloadType "MSSQL" $SchPol.ScheduleRunTimes.Clear() $Time = Get-Date $Time1 = Get-Date -Year $Time.Year -Month $Time.Month -Day $Time.Day -Hour $Time.Hour -Minute 0 -Second 0 -Millisecond 0 $Time1 = $Time1.ToUniversalTime() $SchPol.ScheduleRunTimes.Add($Time1) $SchPol.ScheduleRunFrequency.Clear $SchPol.ScheduleRunDays.Add("Monday") $SchPol.ScheduleRunFrequency="Weekly" $RetPol = Get-AzRecoveryServicesBackupRetentionPolicyObject -WorkloadType "MSSQL" $RetPol.IsDailyScheduleEnabled=$false $RetPol.DailySchedule.DurationCountInDays = 0 $RetPol.IsWeeklyScheduleEnabled=$true $RetPol.WeeklySchedule.DaysOfTheWeek.Add("Monday") $RetPol.WeeklySchedule.DurationCountInWeeks = 365 $vault = Get-AzRecoveryServicesVault -ResourceGroupName "azurefiles" -Name "azurefilesvault" $Pol= Get-AzRecoveryServicesBackupProtectionPolicy -Name "TestPolicy" -VaultId $vault.ID $Pol.SnapshotRetentionInDays=5 Set-AzRecoveryServicesBackupProtectionPolicy -Policy $Pol -SchedulePolicy $SchPol -RetentionPolicy $RetPol
Environment data
Azure Cloudshell
Module versions