Agentless, cloud-native backup for Microsoft Azure
Post Reply
ratkinsonuk
Expert
Posts: 140
Liked: 22 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Azure REST API Examples

Post by ratkinsonuk »

Does anyone have any sample Powershell code for creating Azure schedule based backups using the REST API. The payload below creates the backup, but won't add the VM. I'm probably using the wrong id somewhere, but I'm getting fed up of going round in circles.

Thanks, Rob

Code: Select all

{
    "serviceAccountId":  "XXXXXXXXXXX-XXXXXXXXXXXXXX",
    "snapshotSettings":  {
                             "applicationAwareSnapshot":  false,
                             "copyOriginalTags":  false
                         },
    "description":  "Alchemy DMS daily Production backup",
    "retention":  {
                      "value":  3,
                      "type":  "Days"
                  },
    "schedule":  {
                     "dailyOptions":  {
                                          "time":  "18:45"
                                      },
                     "type":  "Daily"
                 },
    "regions":  [
                    {
                        "regionId":  "uksouth"
                    }
                ],
    "name":  "PROD_DAILY_ALCHEMY-4_BACKUP",
    "selectedItems":  {
                          "VirtualMachines":  [
                                                  {
                                                      "id":  "/subscriptions/XXXXXXXXXXXXX-XXXXXXXXXXXXX-XXXXXXXXXX/resourceGroups/prod-infra-rg-netftp-uks/providers/Microsoft.Compute/virtualMachines/UKLNETFTPPZ001"
                                                  }
                                              ]
                      },
    "tenantId":  "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "backupType":  "SelectedItems",
    "settings":  {
                     "enableApplicationConsistentBackup":  true,
                     "compressionLevel":  "Optimal",
                     "enableEncryption":  true,
                     "enableFileSystemConsistentBackup":  true,
                     "notificationSettings":  {
                                                  "enableSNMPNotifications":  false,
                                                  "enableEmailNotifications":  true
                                              }
                 },
    "isEnabled":  true
}
nielsengelen
Product Manager
Posts: 6070
Liked: 1267 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Azure REST API Examples

Post by nielsengelen »

Hi,

If I'm correct, you should use the ID that is assigned in VBAz for the VirtualMachines section. You should first query this API call to get the correct ID and then it should work.
GitHub: https://github.com/nielsengelen
ratkinsonuk
Expert
Posts: 140
Liked: 22 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Azure REST API Examples

Post by ratkinsonuk »

Hi Nielsen. That returns the VBAZ ID and the AzureID. I've already tried both of them and neither work. Is it because I haven't specified the other selectedItems fields, e.g. Subscriptions = null?

Thanks, Rob.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests