Skip to content

feat: implement blob versioning support - #2689

Draft
jainakanksha-msft with Copilot wants to merge 2 commits into
mainfrom
copilot/enable-blob-versioning
Draft

feat: implement blob versioning support#2689
jainakanksha-msft with Copilot wants to merge 2 commits into
mainfrom
copilot/enable-blob-versioning

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Azurite had no support for Azure Blob Storage versioning — overwriting a blob should preserve the previous content as a named version accessible by versionId. This adds versioning lifecycle support to the Loki-backed blob metadata store.

Model & XML Serialization

  • Added BlobVersioning interface ({ enabled?: boolean }) and replaced the flat isVersioningEnabled field on StorageServiceProperties with a proper versioning?: BlobVersioning composite field
  • Added BlobVersioning composite mapper so <Versioning><Enabled>true</Enabled></Versioning> round-trips correctly via msrest XML serialization

Metadata Store (LokiBlobMetadataStore)

  • createBlob / commitBlockList: when versioning is enabled, marks the existing blob as isCurrentVersion: false (instead of deleting) and inserts the new blob with a fresh versionId and isCurrentVersion: true
  • getBlobWithLeaseUpdated: accepts optional versionId for direct version lookup; without it, filters out isCurrentVersion === false blobs so non-versioned callers are unaffected
  • listBlobs: added includeVersions flag; when false (default), previous versions are hidden
  • deleteBlob: when versionId is specified, removes only that version

HTTP Handlers

  • BlobHandler / BlockBlobHandler: propagate versionId option into store calls and surface versionId / isCurrentVersion in responses
  • ContainerHandler: parses include=versions from list requests and passes includeVersions to listBlobs; emits versionId / isCurrentVersion per blob item

Usage example

// Enable versioning (requires raw HTTP — SDK does not expose this yet)
await setServiceProperties(`<Versioning><Enabled>true</Enabled></Versioning>`);

const blobClient = containerClient.getBlockBlobClient("myblob");
const v1 = await blobClient.upload("version1", 8);  // v1.versionId set
const v2 = await blobClient.upload("version2", 8);  // v2.versionId set, v1 preserved

// Download a previous version
const old = await blobClient.withVersion(v1.versionId!).download();

// List all versions
for await (const blob of containerClient.listBlobsFlat({ includeVersions: true })) {
  console.log(blob.versionId, blob.isCurrentVersion);
}

// Delete a specific version
await blobClient.withVersion(v1.versionId!).delete();

Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 07:10
Copilot AI linked an issue Aug 3, 2026 that may be closed by this pull request
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 07:43
Copilot AI changed the title [WIP] Enable blob versioning for Azurite testing feat: implement blob versioning support Aug 3, 2026
Copilot AI requested a review from jainakanksha-msft August 3, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Blob versioning

2 participants