Object Versioning

For instances created on the Zone Redundant Storage (ZRS) storage class, the Object Store service has a built-in capability that allows object (blob) versioning on Azure-based landscapes. Blob versioning is a feature provided by Azure.

Object versioning helps in maintaining multiple versions of the same object. For more information, see Blob VersioningInformation published on non-SAP site.

Versioning maintains previous versions of a blob automatically. Blob versioning allows you to restore an earlier version of a blob to recover your data if it was erroneously modified or deleted. It can also be used to archive blobs such that previous versions can be accessed.

Object Store uses a soft delete mechanism to protect against accidental deletion or overwrite. When an object is deleted, it is removed from active use immediately, but a temporary recovery copy is kept for a limited time in case the deletion was accidental.

Configuration Parameters for Blob Versioning

Parameter

Type

Mandatory

Description

Versioning

Boolean

No

Enables versioning for blobs within a service instance

Impact on the Cost

Each version of a blob is stored and charged as a separate, complete blobs. The total storage cost for a blob with multiple versions is therefore the sum of the storage costs for all its versions.

Normal storage and data transfer rates apply to each version. For example, if you have three versions of a blob stored, you are charged for all three complete objects.

Enable Versioning for Azure Blob Storage

This parameter can't be set to false, and can't be changed on the standard plan. On previous plans, you can use the following command to enable versioning:
cf update-service <service_instance_name> -c '{"versioning" : true}'

Using Versioned Blobs through Azure Command-Line Interface (CLI)

You can see a list all the versions, restore an older version, and several other version-specific operations with the help of Az CLI commands.

The following command lists all blobs in the container including versions:

az storage blob list --account-name <storage_account> --container-name <container_name> --include v --sas-token sig="<sas_token>"

The following command downloads a specific version of the blob:

az storage blob download --account-name <storage_account> --container-name <container_name> --file ./local/download_to_this --name blob2download.txt --if-match <etag-value>  --sas-token sig="<sas_token>

Each blob has a unique e-tag value. When you list all blobs, the response contains properties of the blob including versionId, and e-tag value. versionId is the time-stamp at which the blob was modified or updated. Using the corresponding etag for the blob, you can download a specific version with the download command.

The following command restores a blob to a different version:

az storage blob copy start --account-name <storage_account> --destination-blob current.txt --destination-container <container_name> --source-uri "https://<storage_account>.blob.core.windows.net/<container_name>/current.txt?versionId=<version_id>&sig=<sas_token>" --sas-token "<sas_token>" 

This operation creates a new blob (the contents of the -source-uri are copied into this new blob). Consequently, there's an impact on the cost. To avoid it, delete the older version after restoring it to the current version.

The following command deletes a blob:

az storage blob delete --account-name <storage_account> --container-name <container_name> --name blob2delete.txt --if-match <etag-value>  --sas-token sig="<sas_token>

Using REST APIs for Versioned Blobs

The following request retrieves a list of all blobs in the container including all the versions:

GET https://<storage_account>.blob.core.windows.net/mycontainer?restype=<container_name>&comp=list&include=versions&<sas_token>

The SAS-Token appended at the end of the request must be URL-decoded.