Set Retention for SQL Backup to URL

ola-hallengrensql server

I am using Ola Hallengrens DatabaseBackup script. I am storing my backups in Azure Blob storage using the @url parameter. Everything is working fine, however I am looking for a way to set a retention policy on those backups – currently I assume they live there forever until I manually delete them. I tried using the @CleanupTime parameter but got the following error

The value for the parameter @CleanupTime is not supported

Is there any way I am able to set this?

Edit: SQL being run for the backup

sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d DBATools -Q \ 
"EXECUTE [dbo].[DatabaseBackup] \ 
@Databases = 'USER_DATABASES', \ 
@BackupType = 'LOG', \ 
@Verify = 'Y',  \
@Compress = 'Y', \ 
@CheckSum = 'Y', \ 
@LogToTable = 'Y', \ 
@ChangeBackupType='Y', \
@url='https://example.blob.core.windows.net/backups', \ 
Credential='AzureBlobBackups'" -b

Best Answer

In order to clean up files in Azure blob storage requires PowerShell or going through some app like Azure Explorer. So it is likely that Ola's backup script does not support it since there is no native T-SQL command or procedure to access blob storage in that manner.

When you are deleting files you will need to account for any that may still have an active lease. BOL has code to handle dropping the active leases.