Skip to content

Storage - STG104 Add Blob Access Tier to Get Blob Response#49219

Open
browndav-msft wants to merge 7 commits into
Azure:feature/storage/stg104basefrom
browndav-msft:stg104/addAccessTierHeadersGetBlob
Open

Storage - STG104 Add Blob Access Tier to Get Blob Response#49219
browndav-msft wants to merge 7 commits into
Azure:feature/storage/stg104basefrom
browndav-msft:stg104/addAccessTierHeadersGetBlob

Conversation

@browndav-msft
Copy link
Copy Markdown
Member

Summary

This change adds support for returning blob access tier headers in the GetBlob API response, aligning its behavior with existing responses from GetBlobProperties and ListBlobs.
By surfacing access tier information directly in GetBlob, this eliminates the need for additional API calls to retrieve tier metadata, significantly reducing operational overhead and cost—particularly for high-volume scenarios such as ODSP cold blob reads.

Key Changes

  • Introduces the following response headers in GetBlob:
  1. x-ms-access-tier
  2. x-ms-access-tier-inferred
  3. x-ms-access-tier-change-time
  4. x-ms-smart-access-tier
  • Ensures consistency across Blob APIs for access tier visibility.

Impact

  • Removes the need for follow-up calls to fetch tier information
  • Improves efficiency for read-heavy workloads
  • Reduces large-scale costs associated with redundant metadata lookups

@github-actions github-actions Bot added the Storage Storage Service (Queues, Blobs, Files) label May 19, 2026
@browndav-msft browndav-msft changed the title generate swagger changes Add Access Tier Headers to GetBlob May 20, 2026
@browndav-msft browndav-msft requested a review from Copilot May 20, 2026 02:00
@ibrandes ibrandes changed the title Add Access Tier Headers to GetBlob Storage - STG104 Add Blob Access Tier to Get Blob Response May 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Azure Storage Blob Java SDK to surface access-tier related response headers on GetBlob/Download responses (similar to existing GetBlobProperties and ListBlobs behavior), enabling callers to obtain tier metadata without an extra properties call.

Changes:

  • Updates the swagger input to a newer service version and regenerates the download headers model to include access tier headers.
  • Adds new strongly-typed access tier accessors to BlobDownloadHeaders and wires them to the generated internal headers (BlobsDownloadHeaders).
  • Adds/updates tests to validate smart access tier and related metadata is returned.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/storage/azure-storage-blob/swagger/README.md Updates the swagger input-file used for code generation.
sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/models/BlobDownloadHeaders.java Adds public getters/setters for access-tier related headers on download responses.
sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/models/BlobsDownloadHeaders.java Adds generated fields/parsing for the new x-ms-*access-tier* headers in download responses.
sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java Adds assertions validating access tier headers are present on download responses.
sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobAsyncApiTests.java Adds an async test covering SMART tier properties and tier metadata.
sdk/storage/azure-storage-blob/assets.json Updates the asset tag reference.
Comments suppressed due to low confidence (1)

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java:550

  • Same issue as above: the test-created blob doesn’t set AccessTier.SMART but the assertions require SMART + smartAccessTier. Please either create/set a SMART-tier blob before downloadContentWithResponse, or update assertions to the default tier. Also, prefer asserting accessTierChangeTime is non-null (and avoid equality/inequality against OffsetDateTime.now(), which is not a stable expectation).
        assertEquals(AccessTier.SMART, headers.getAccessTier());
        assertNotNull(headers.getSmartAccessTier());
        assertNotEquals(OffsetDateTime.now(), headers.getAccessTierChangeTime());
        assertTrue(headers.isAccessTierInferred());

Comment thread sdk/storage/azure-storage-blob/swagger/README.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java:95

  • reactor.test.StepVerifier is imported but not used anywhere in this (synchronous) test class, which will cause compilation to fail. Remove the import or add the intended usage.
import reactor.core.publisher.Hooks;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import reactor.test.StepVerifier;

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java:557

  • These tests assert AccessTier.SMART in the download response headers, but the test setup uploads the blob without setting its tier to SMART. This will likely fail in live runs where the default tier is HOT. Set the blob tier to SMART before downloading (e.g., via upload options or setAccessTier) so the assertions match the test data.
    @RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "2026-10-06")
    @Test
    public void downloadSmartAccessTierHeaders() {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        BlobDownloadResponse response = bc.downloadWithResponse(stream, null, null, null, false, null, null);
        ByteBuffer body = ByteBuffer.wrap(stream.toByteArray());

        assertEquals(DATA.getDefaultData(), body);
        assertSmartAccessTierHeaders(response.getDeserializedHeaders());

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobApiTests.java:574

  • assertNotEquals(OffsetDateTime.now(), headers.getAccessTierChangeTime()) is effectively a non-assertion (it will almost always pass) and can be flaky/meaningless in playback. Prefer asserting the header is non-null and, if needed, that it is not in the future (or otherwise matches expected semantics).
    private static void assertSmartAccessTierHeaders(BlobDownloadHeaders headers) {
        assertEquals(AccessTier.SMART, headers.getAccessTier());
        assertNotNull(headers.getSmartAccessTier());
        assertTrue(headers.isAccessTierInferred());
        assertNotEquals(OffsetDateTime.now(), headers.getAccessTierChangeTime());
    }

Comment thread sdk/storage/azure-storage-blob/swagger/README.md
* account or for Block blobs on blob storage or general purpose V2 account.
*/
public Boolean isAccessTierInferred() {
return Boolean.TRUE.equals(internalHeaders.isXMsAccessTierInferred());
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this because dotnet changes null to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storage Storage Service (Queues, Blobs, Files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants