Storage - STG104 Add Blob Access Tier to Get Blob Response#49219
Storage - STG104 Add Blob Access Tier to Get Blob Response#49219browndav-msft wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
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
BlobDownloadHeadersand 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());
There was a problem hiding this comment.
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.StepVerifieris 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.SMARTin 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 orsetAccessTier) 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());
}
| * account or for Block blobs on blob storage or general purpose V2 account. | ||
| */ | ||
| public Boolean isAccessTierInferred() { | ||
| return Boolean.TRUE.equals(internalHeaders.isXMsAccessTierInferred()); |
There was a problem hiding this comment.
Added this because dotnet changes null to false.
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
Impact