Azure Backup policy throws CloudInternal error.

Mahalakshmi Gandhi 0 Reputation points
2025-01-30T12:42:00.9733333+00:00

I have created an hourly-based backup policy. But when I applied that policy to VM, it threw an error.

{

"endTime": "2025-01-30T12:26:54.573302+00:00",

"error": {

"code": "CloudInternalError",

"message": "Microsoft Azure Backup encountered an internal error."

},

"id": "d69c5c5a-d64c-4b5a-9670-278483a64718",

"name": "d69c5c5a-d64c-4b5a-9670-278483a64718",

"properties": null,

"startTime": "2025-01-30T12:26:54.573302+00:00",

"status": "Failed"

}

@hour_policy = "hourlypolicy"
def hourly_backup_policy
  @api_url = "#{@azure_url}/subscriptions/#{@subscription_id}/resourceGroups/#{@resource_group_name}/providers/Microsoft.RecoveryServices/vaults/#{@vaultName}/backupPolicies/#{@hour_policy}?api-version=2021-07-01"
  @request_body = {
    properties: {
      backupManagementType: "AzureIaasVM",
      timeZone: "UTC",
      policyType: "V2",
      schedulePolicy: {
        schedulePolicyType: "SimpleSchedulePolicyV2",
        scheduleRunFrequency: "Hourly",
        hourlySchedule: {
          interval: 4,
          scheduleWindowStartTime: "2023-02-06T23:00:00Z",
          scheduleWindowDuration: 24
        }
      },
      retentionPolicy: {
        retentionPolicyType: "LongTermRetentionPolicy",
        dailySchedule: {
          retentionTimes: [
            "2023-02-06T23:00:00Z"
          ],
          retentionDuration: {
            count: 7,
            durationType: "Days"
          }
        }
      }
    }
  }.to_json
response = put_request
puts ("Request_body: #{@request_body}")
puts ("Response: #{response}")
end
#hourly_backup_policy


def enable_protection_for_vm
  @api_url = "#{@azure_url}/subscriptions/#{@subscription_id}/resourceGroups/#{@resource_group_name}/providers/Microsoft.RecoveryServices/vaults/#{@vaultName}/backupFabrics/Azure/protectionContainers/iaasvmcontainer;iaasvmcontainerv2;#{@resource_group_name};#{@vm_name}/protectedItems/vm;iaasvmcontainerv2;#{@resource_group_name};#{@vm_name}?api-version=2021-07-01"

  @request_body = {
    properties: {
      protectedItemType: "Microsoft.Compute/virtualMachines",
      sourceResourceId: "/subscriptions/#{@subscription_id}/resourceGroups/#{@resource_group_name}/providers/Microsoft.Compute/virtualMachines/#{@vm_name}",
      policyId: "/subscriptions/#{@subscription_id}/resourceGroups/#{@resource_group_name}/providers/Microsoft.RecoveryServices/vaults/#{@vaultName}/backupPolicies/#{@policyName}"
    }
  }.to_json

  puts "Request URL: #{@api_url}"
  puts "Request Body: #{@request_body}"

  put_request
end
enable_protection_for_vm

I included my code as well.

Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,351 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pranay Reddy Madireddy 1,590 Reputation points Microsoft Vendor
    2025-01-30T13:46:34.71+00:00

    Hi @Mahalakshmi Gandhi

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    According to this documentation: azurerm_backup_policy_vm

    instant_restore_retention_days must be set to 5 if the backup frequency is set to Weekly.
    User's image

    If you have any further queries, do let us know.


    If the answer is helpful, please and "Upvote it".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.