Search code examples
azureazure-bicepazure-site-recovery

Bicep - Unable to Create VM Snapshot Backup Policy for Azure Recovery Services Vault


I am trying to deploy a Recovery Services Vault as part of an infrastructure release using Bicep. I am having trouble deploying one backup policy in particular, a VM Snapshot backup policy (AzureIaaSVM).

I have followed the Bicep reference page for creating the template but it fails validation when trying to deploy. I am using VSCode to develop and when I build an ARM template from the Bicep file, it fails validation with the following message:

enter image description here

If I have understood the documentation correctly, there should be more than just 'AzureStorage' being allowed here.

My question is, is this a tooling/API problem or have I misunderstood the documentation? If so, what would I have to alter to get this working?

The template:

resource vmSnapshotBackupPolicy 'Microsoft.RecoveryServices/vaults/backupPolicies@2022-03-01' = {
  name: 'vm-snapshot-policy'
  location: resourceLocation
  parent: recoveryServicesVault
  properties: {
    protectedItemsCount: 0
    backupManagementType: 'AzureIaasVM'
    instantRPDetails: {
      azureBackupRGNamePrefix: 'vmsnapshot'
    }
    instantRpRetentionRangeInDays: 2
    policyType: 'V1'
    retentionPolicy: {
      retentionPolicyType: 'LongTermRetentionPolicy'
      dailySchedule: {
        retentionDuration: {
          count: 7
          durationType: 'Days'
        }
        retentionTimes: [
          '2022-10-21T02:00:00Z'
        ]
      }
      monthlySchedule: {
        retentionDuration: {
          count: 6
          durationType: 'Months'
        }
        retentionScheduleDaily: {
          daysOfTheMonth: [
            {
              date: 1
              isLast: false
            }
          ]
        }
        retentionScheduleFormatType: 'Daily'
        retentionTimes: [
          '2022-10-21T02:00:00Z'
        ]
      }
      weeklySchedule: {
        daysOfTheWeek: [
          'Sunday'
        ]
        retentionDuration: {
          count: 4
          durationType: 'Weeks'
        }
        retentionTimes: [
          '2022-10-21T02:00:00Z'
        ]
      }
      yearlySchedule: {
        monthsOfYear: [
          'July'
        ]
        retentionDuration: {
          count: 2
          durationType: 'Years'
        }
        retentionScheduleDaily: {
          daysOfTheMonth: [
            {
              date: 1
              isLast: false
            }
          ]
        }
        retentionScheduleFormatType: 'Daily'
        retentionTimes: [
          '2022-10-21T02:00:00Z'
        ]
      }
    }
    schedulePolicy: {
      schedulePolicyType: 'SimpleSchedulePolicy'
      scheduleRunFrequency: 'Daily'
      scheduleRunTimes: [
        '2022-10-21T02:00:00Z'
      ]
      scheduleWeeklyFrequency: 0
    }
    timeZone: 'UTC'
  }

}


Solution

  • It's a tooling problem, see: https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.recoveryservices/recovery-services-backup-vms/main.bicep for another example.

    You can also add a comment here: https://github.com/Azure/bicep/issues/784 for the tooling issue.