this is my first question on stackoverflow, so if i did something wrong, please tell me :)
I am trying to deploy an bicep template, that creates recovery services vault and creates a policy to backup a specific VM. I am getting the following error while deploying the template:
"UserErrorThisVMBackupIsSupportedUsingEnhancedPolicy","message":"This VM backup cannot be configured using standard policy, please use Enhanced Policy"}]}]}}
How can i do that in a bicep template? Tried multiple things, checked the documentation multiple times but can't find anything.
This is my YML:
steps:
- task: AzureCLI@2
inputs:
azureSubscription: ${{ parameters.serviceConnection }}
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az deployment group create --resource-group "${{ parameters.existingVirtualMachinesResourceGroup }}" --template-file "$(Build.SourcesDirectory)/iac/templates/backup-template.bicep" --parameters existingVirtualMachines='["${{ parameters.existingVirtualMachines }}"]' existingVirtualMachinesResourceGroup="${{ parameters.existingVirtualMachinesResourceGroup }}"
displayName: 'Deploy ARM Template'
and this is my backup policy resource:
resource backupPolicy 'Microsoft.RecoveryServices/vaults/backupPolicies@2021-03-01' = if (isNewPolicy) {
parent: recoveryServicesVault
name: policyName
location: location
properties: {
backupManagementType: 'AzureIaasVM'
instantRpRetentionRangeInDays: 5
schedulePolicy: {
scheduleRunFrequency: 'Daily'
scheduleRunTimes: scheduleRunTimes
schedulePolicyType: 'SimpleSchedulePolicy'
}
retentionPolicy: {
dailySchedule: {
retentionTimes: scheduleRunTimes
retentionDuration: {
count: 104
durationType: 'Days'
}
}
weeklySchedule: {
daysOfTheWeek: [
'Sunday'
'Tuesday'
'Thursday'
]
retentionTimes: scheduleRunTimes
retentionDuration: {
count: 104
durationType: 'Weeks'
}
}
monthlySchedule: {
retentionScheduleFormatType: 'Daily'
retentionScheduleDaily: {
daysOfTheMonth: [
{
date: 1
isLast: false
}
]
}
retentionTimes: scheduleRunTimes
retentionDuration: {
count: 60
durationType: 'Months'
}
}
yearlySchedule: {
retentionScheduleFormatType: 'Daily'
monthsOfYear: [
'January'
'March'
'August'
]
retentionScheduleDaily: {
daysOfTheMonth: [
{
date: 1
isLast: false
}
]
}
retentionTimes: scheduleRunTimes
retentionDuration: {
count: 10
durationType: 'Years'
}
}
retentionPolicyType: 'LongTermRetentionPolicy'
}
timeZone: 'UTC'
}
}
Many thanks in advance!
Tried adding properties, but the resource isn't accepting them
It’s funny that you posted this today, as I was just looking for the same thing! Fortunately, I was able to figure it out.
It's not too clear from the documentation, but you have to set the following properties:
policyTypetoV2schedulePolicyTypetoSimpleSchedulePolicyV2Also, the actual
SchedulePolicysyntax is a bit different—the Microsoft documentation should help you through it.You'll also need to use a newer API version. The following worked for me:
I took your example and made the necessary changes, but I took out the
retentionPolicyproperty just so the code block is a little easier to handle in this post. None of that should be changing.