Create Recovery Service Vault with policy using ARM Template

HOJ 21 Reputation points
2021-03-09T09:52:00.417+00:00

Hi,
I'm trying to create an ARM template to create RSV with a default Backup policy. The vault is created, but the creation of the policy fails with the below error:

Status Message: Input for create or update policy is not in proper format
Please check format of parameters like schedule time, schedule days, retention time and retention days (Code:BMSUserErrorInvalidPolicyInput)
Status Message: Parameter value in request is invalid
Please provide correct value for parameter value (Code:UserErrorInvalidRequestParameter)

My template is like this:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "CustomerID": {
            "type": "int",
            "minValue":100000,
            "maxValue":999999,
            "metadata": {
                "description": "Customer ID, 6 digits"
            }
        },
        "CustomerSubID": {
            "type": "int",
            "minValue":1,
            "maxValue":99,
            "metadata": {
                "description": "Customer Sub ID, one or two dgits"
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Location for Resources"
            }
        },
        "date": {
            "type": "string",
            "defaultValue": "[utcNow('yyyy-MM-dd')]",
            "metadata": {
                "description": "Date in format yyyy-MM-dd"
            }
        },
        "timeZone": {
            "type": "string",
            "defaultValue": "UTC",
            "metadata": {
                "description": "Any Valid timezone, for example:UTC, Pacific Standard Time. Refer: https://msdn.microsoft.com/en-us/library/gg154758.aspx"
            } 
        },
        "time2": {
            "type": "string",
            "defaultValue": "2021-03-08T22:00:00Z"
        }
    },
    "functions": [],
    "variables": {
        "recoveryvaultName": "[toLower(concat('azpnoe','-rsv-',parameters('CustomerID'),'-',padLeft(parameters('CustomerSubID'),2,'0')))]",
        "time": "[concat(parameters('date'), 'T22:00:00Z')]"
    },
    "resources": [
        {
            "name": "[variables('recoveryvaultName')]",
            "type": "Microsoft.RecoveryServices/vaults",
            "apiVersion": "2016-06-01",
            "location": "[parameters('location')]",
            "tags": {
                "CustomerID": "[parameters('CustomerID')]"
            },
            "sku": {
                "name": "RS0",
                "tier": "Standard"
            },
            "properties": {
            }
        },
        {
            "name": "[concat(variables('recoveryvaultName'),'/VM-Policy')]",
            "type": "Microsoft.RecoveryServices/vaults/backupPolicies",
            "apiVersion": "2016-06-01",
            "dependsOn": [
                "[resourceId('Microsoft.RecoveryServices/vaults', variables('recoveryvaultName'))]"
            ],
            "location": "[parameters('location')]",
            "properties": {
                "backupManagementType": "AzureIaasVM",
                "instantRpRetentionRangeInDays": 2,
                "schedulePolicy": {
                    "schedulePolicyType": "SimpleSchedulePolicy",
                    "scheduleRunFrequency": "Daily",
                    "scheduleRunTimes": [
                        "[variables('time')]"
                    ],
                    "scheduleWeeklyFrequency": 0
                },
                "retentionPolicy": {
                    "retentionPolicyType": "LongTermRetentionPolicy",
                    "dailySchedule": {
                        "retentionTimes": [
                            "[variables('time')]"
                        ],
                        "retentionDuration": {
                            "count": 5,
                            "durationType": "Days"
                        }
                    },
                    "weeklySchedule": {
                        "daysOfTheWeek": [
                            "Friday"
                        ],
                        "retentionTimes": [
                            "[variables('time')]"
                        ],
                        "retentionDuration": {
                            "count": 6,
                            "durationType": "Weeks"
                        }
                    }
                },
                "timeZone": "[parameters('timeZone')]"
            }
        }
    ],
    "outputs": {}
}

I get the same error when trying to create using the Quickstart template "Create Daily Backup Policy for RS Vault to protect IaaSVMs"

Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,126 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,129 questions
0 comments No comments
{count} votes

Accepted answer
  1. sajjad ali 81 Reputation points
    2021-03-09T13:22:16.003+00:00

    @HOJ retention dailybackups should be 7 days, so change the count to 7 days and try again

    What is the minimum allowed retention range for a daily backup point?
    Azure Virtual Machine backup policy supports a minimum retention range from seven days up to 9999 days. Any modification to an existing VM backup policy with less than seven days will require an update to meet the minimum retention range of seven days.

    https://learn.microsoft.com/en-us/azure/backup/backup-azure-vm-backup-faq#what-is-the-minimum-allowed-retention-range-for-a-daily-backup-point


0 additional answers

Sort by: Most helpful