Lesson 4 of 5 Azure Blob Storage Data Management

Preserving Previous Data with Blob Versioning

Versioning keeps the previous state of a blob on every change. This lesson explains how versions are created and restored and how versioning relates to other features.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain how current and previous versions are created.
  • Describe how a previous version is restored.
  • Identify features that require versioning and how to control version costs.

How versioning works

When versioning for blobs is enabled on the account's Data protection page, every write operation that modifies a blob (upload, put block list, copy, set metadata) creates a new current version, and the state before the write is kept as a previous version. Each version has a version ID, a UTC timestamp, and previous versions are read-only. Deleting a blob without a version ID makes the current version a previous version, so the blob no longer appears in normal listings but its data remains.

To restore, open the blob's Versions tab, select a previous version and Make current version, which copies it over the base blob. A specific version can also be read or downloaded directly by its version ID. Deleting a specific previous version removes it permanently, unless blob soft delete is also enabled, in which case it is soft-deleted.

The following diagram shows the blob version to promote after files are overwritten, and the protection to add.

Restoring 2,000 configuration blobs overwritten with empty files. With versioning on, each blob has a previous version from before the overwrite, which is promoted to current, by script with the version IDs or by point-in-time restore if enabled. Blob soft delete is added so that a deleted version is recoverable too.
The number of versions shown is illustrative.
Put in order

What versioning records

Exam skills 2.3.7

Versioning is enabled. Arrange what happens to <code>plan.docx</code> in order.

Log in to try this activity Interactive activities are free with an account.

Cost, prerequisites and related features

Each version is billed for the unique data it contains, so frequently overwritten blobs can accumulate significant cost. Lifecycle management rules with version actions delete or tier previous versions after a number of days. Versioning is required for object replication and for point-in-time restore of block blobs (which also needs soft delete and change feed). It is not supported for accounts with a hierarchical namespace.

Versioning differs from snapshots: a snapshot is a read-only copy created manually or by an application at a moment it chooses, while versions are created automatically on every change. Microsoft recommends enabling versioning together with blob soft delete and container soft delete for complete protection, and using a resource lock for the account.

Sort into groups

Versions or snapshots?

Exam skills 2.3.7

Decide whether each statement describes blob versions or blob snapshots.

Log in to try this activity Interactive activities are free with an account.
Worked example

An overwritten file

A script overwrote 2,000 configuration blobs with empty files an hour ago. The account has blob versioning enabled and no soft delete. How should the administrator restore the files, and what should be added to protect against deletion of versions?

Each blob has a previous version from before the overwrite, so promote that version to current for each blob, by script with the version IDs or by point-in-time restore if it is enabled. Enable blob soft delete as well, so that a deleted previous version is soft-deleted rather than permanently removed. Container soft delete would not help, because no container was deleted.

Check yourself

How is a previous version of a blob restored?

Show answer

By making it the current version (promoting it), which copies it over the base blob.

Exam Tips

Remember for the exam

  • Versioning keeps the previous state on every write or delete; restore by making a version current.
  • Versioning is required for object replication and point-in-time restore.
  • Use lifecycle rules to delete old versions and control cost.
  • Combine versioning with blob and container soft delete.