question

mpowrie avatar image
0 Votes"
mpowrie asked mpowrie answered

Storage account data protection - disabling operational Backups programmatically

As part of a nightly build test that builds and destroys an environment, I need to disable operational backups on a storage account programmatically after it's been created (via REST API or the az cli or Powershell), but only know how to do this via portal.azure.com

![106081-image.png][1]


The CURL command I'm using to enable operational backups via the REST API is:

 curl -X PUT -H "Authorization: Bearer $AZURE_TOKEN_ID" -H "Content-Type: application/json" --data "{\"name\": \"$STORAGE_ACCOUNT-operational-backups\",\"type\": \"Microsoft.DataProtection/backupVaults/backupInstances\",\"properties\": {\"friendlyName\": \"$STORAGE_ACCOUNT\",\"dataSourceInfo\": {\"resourceID\": \"/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.Storage/storageAccounts/$STORAGE_ACCOUNT\",\"resourceUri\": \"/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.Storage/storageAccounts/$STORAGE_ACCOUNT\",\"datasourceType\": \"Microsoft.Storage/storageAccounts/blobServices\",\"resourceName\": \"$STORAGE_ACCOUNT\",\"resourceType\": \"Microsoft.Storage/storageAccounts\",\"resourceLocation\": \"australiaeast\",\"objectType\": \"Datasource\"},\"policyInfo\": {\"policyId\": \"/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.DataProtection/backupVaults/$BACKUP_VAULT_NAME/backupPolicies/$BACKUP_POLICY_NAME\"},\"protectionStatus\": {\"status\": \"ProtectionConfigured\"},\"currentProtectionState\": \"ProtectionConfigured\",\"provisioningState\": \"Succeeded\",\"objectType\": \"BackupInstance\"}}" "https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.DataProtection/BackupVaults/$BACKUP_VAULT_NAME/backupInstances/$STORAGE_ACCOUNT-operational-backups?api-version=2021-01-01"




azure-storage-accounts
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TThe portal.azure.com option I'm trying to disable programmatically is shown in the below screenshot:

106082-image.png


0 Votes 0 ·
image.png (100.1 KiB)

1 Answer

mpowrie avatar image
0 Votes"
mpowrie answered

Found the problem: I had a typo!

The working CURL command to delete Operational Backups is:

curl --location --request DELETE 'https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.DataProtection/backupVaults/$BACKUP_VAULT_NAME/backupInstances/$STORAGE_ACCOUNT-operational-backups?api-version=2020-01-01-alpha' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $AZURE_TOKEN_ID'

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.