Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
import com.azure.core.util.IterableStream;
import com.azure.core.util.logging.ClientLogger;
import com.azure.storage.blob.BlobServiceVersion;
import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.util.BinaryData;
import com.azure.core.util.UrlBuilder;
import com.azure.storage.blob.implementation.AzureBlobStorageImpl;
import com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder;
import com.azure.storage.blob.implementation.util.RequestOptionsHelper;
import com.azure.storage.blob.models.AccessTier;
import com.azure.storage.blob.models.BlobStorageException;
import com.azure.storage.blob.models.DeleteSnapshotsOptionType;
Expand Down Expand Up @@ -51,14 +55,16 @@ public final class BlobBatchAsyncClient {
private final AzureBlobStorageImpl client;
private final boolean containerScoped;
private final BlobServiceVersion serviceVersion;
// The container-scoped batch URL already names the container. The generated operation has an empty path
// template, so without scoping the request to that path it goes out as "/container/?restype=..." where the
// shipped client sent "/container?restype=...".
private final String containerPath;

BlobBatchAsyncClient(String clientUrl, HttpPipeline pipeline, BlobServiceVersion version, boolean containerScoped) {
this.serviceVersion = version;
this.client = new AzureBlobStorageImplBuilder().url(clientUrl)
.pipeline(pipeline)
.version(version.getVersion())
.buildClient();
this.client = new AzureBlobStorageImpl(pipeline, clientUrl, version);
this.containerScoped = containerScoped;
this.containerPath = containerScoped ? UrlBuilder.parse(clientUrl).getPath() : null;
}

AzureBlobStorageImpl getClient() {
Expand Down Expand Up @@ -154,20 +160,25 @@ public Mono<Response<Void>> submitBatchWithResponse(BlobBatch batch, boolean thr

Mono<Response<Void>> submitBatchWithResponse(BlobBatch batch, boolean throwOnAnyFailure, Context context) {
Context finalContext = context == null ? Context.NONE : context;
return batch.prepareBlobBatchSubmission()
.flatMap(batchOperationInfo -> containerScoped
? client.getContainers()
.submitBatchWithResponseAsync(null, batchOperationInfo.getContentLength(),
batchOperationInfo.getContentType(), Flux.fromIterable(batchOperationInfo.getBody()), null,
null, finalContext)
.flatMap(response -> BlobBatchHelper.mapBatchResponse(batchOperationInfo, response,
throwOnAnyFailure, LOGGER))
: client.getServices()
.submitBatchWithResponseAsync(batchOperationInfo.getContentLength(),
batchOperationInfo.getContentType(), Flux.fromIterable(batchOperationInfo.getBody()), null,
null, finalContext)
.flatMap(response -> BlobBatchHelper.mapBatchResponse(batchOperationInfo, response,
throwOnAnyFailure, LOGGER)));
return batch.prepareBlobBatchSubmission().flatMap(batchOperationInfo -> {
long contentLength = batchOperationInfo.getContentLength();

// The generated operation fixes Content-Type to "multipart/mixed"; the service also needs the batch
// boundary, so the full value is set on the request options, which are applied after the request is
// built.
RequestOptions requestOptions = RequestOptionsHelper.requestOptions(finalContext);
requestOptions.setHeader(HttpHeaderName.CONTENT_TYPE, batchOperationInfo.getContentType());
if (containerScoped) {
RequestOptionsHelper.scopeRequestToResourcePath(requestOptions, containerPath);
}

return BinaryData.fromFlux(Flux.fromIterable(batchOperationInfo.getBody()), contentLength, false)
.flatMap(body -> containerScoped
? client.getContainers().submitBatchWithResponseAsync(contentLength, body, requestOptions)
: client.getServices().submitBatchWithResponseAsync(contentLength, body, requestOptions))
.flatMap(response -> BlobBatchHelper.mapBatchResponse(batchOperationInfo, response, throwOnAnyFailure,
LOGGER));
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.FluxUtil;
Expand Down Expand Up @@ -57,7 +58,7 @@ class BlobBatchHelper {

// This method connects the batch response values to the individual batch operations based on their Content-Id
static Mono<SimpleResponse<Void>> mapBatchResponse(BlobBatchOperationInfo batchOperationInfo,
Response<Flux<ByteBuffer>> rawResponse, boolean throwOnAnyFailure, ClientLogger logger) {
Response<BinaryData> rawResponse, boolean throwOnAnyFailure, ClientLogger logger) {
/*
* Content-Type will contain the boundary for each batch response. The expected format is:
* "Content-Type: multipart/mixed; boundary=batchresponse_66925647-d0cb-4109-b6d3-28efe3e1e5ed"
Expand All @@ -73,7 +74,7 @@ static Mono<SimpleResponse<Void>> mapBatchResponse(BlobBatchOperationInfo batchO

String boundary = boundaryPieces[1];

return FluxUtil.collectBytesInByteBufferStream(rawResponse.getValue())
return Mono.just(rawResponse.getValue().toBytes())
/*
* This has been changed from using 'Mono.fromRunnable' to 'Mono.create' to resolve an issue where iterating
* the responses resulted in 0 responses being returned. The reason that this occurred is that
Expand Down Expand Up @@ -237,7 +238,7 @@ public Mono<String> getBodyAsString(Charset charset) {
};
}

private static HttpResponse createHttpResponse(Response<Flux<ByteBuffer>> response) {
private static HttpResponse createHttpResponse(Response<BinaryData> response) {
return new HttpResponse(response.getRequest()) {
@Override
public int getStatusCode() {
Expand All @@ -256,7 +257,7 @@ public HttpHeaders getHeaders() {

@Override
public Flux<ByteBuffer> getBody() {
return response.getValue();
return response.getValue().toFluxByteBuffer();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void beforeTest() {
interceptorManager.addMatchers(Arrays.asList(new BodilessMatcher(),
new CustomMatcher().setHeadersKeyOnlyMatch(Collections.singletonList("Content-Type"))
.setQueryOrderingIgnored(true)
.setIgnoredQueryParameters(Arrays.asList("sv"))));
.setIgnoredQueryParameters(Arrays.asList("sv"))
.setExcludedHeaders(Collections.singletonList("Accept"))));

primaryBlobServiceClient = getServiceClient(ENVIRONMENT.getPrimaryAccount());
primaryBlobServiceAsyncClient = getServiceAsyncClient(ENVIRONMENT.getPrimaryAccount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import com.azure.core.client.traits.HttpTrait;
import com.azure.core.http.HttpClient;
import java.util.Collections;
import com.azure.core.test.models.CustomMatcher;
import com.azure.core.test.TestMode;
import com.azure.core.test.TestProxyTestBase;
import com.azure.core.test.utils.TestUtils;
Expand Down Expand Up @@ -51,6 +53,10 @@ public class BlobChunkedDownloaderTests extends TestProxyTestBase {
@Override
protected void beforeTest() {
super.beforeTest();
if (!interceptorManager.isLiveMode()) {
interceptorManager.addMatchers(
Collections.singletonList(new CustomMatcher().setExcludedHeaders(Collections.singletonList("Accept"))));
}

prefix = getCrc32(testContextManager.getTestPlaybackRecordingName());
BlobServiceAsyncClient primaryBlobServiceAsyncClient = getServiceAsyncClient(ENV.getPrimaryAccount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected void beforeTest() {
// in SAS tokens.
interceptorManager.addMatchers(Collections.singletonList(new CustomMatcher().setComparingBodies(false)
.setExcludedHeaders(Arrays.asList("x-ms-copy-source", "If-Match", "x-ms-range", "If-Modified-Since",
"If-Unmodified-Since"))
"If-Unmodified-Since", "Accept"))
.setQueryOrderingIgnored(true)
.setIgnoredQueryParameters(Arrays.asList("sv"))));
}
Expand Down
6 changes: 6 additions & 0 deletions sdk/storage/azure-storage-blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
### Features Added

### Breaking Changes
- When no root element name is passed, `toXml`/`fromXml` on `BlobAccessPolicy`, `BlobAnalyticsLogging`,
`BlobContainerItemProperties`, `BlobMetrics` and `BlobRetentionPolicy` now default to the service's element names
(`AccessPolicy`, `Logging`, `ContainerProperties`, `Metrics` and `RetentionPolicy`) instead of the class names.
Requests and responses sent through the clients are unaffected.

### Bugs Fixed
- Fixed `createIfNotExists` on `BlobContainerClient` and `BlobContainerAsyncClient`, and
Expand All @@ -17,6 +21,8 @@
blob of a different type already exists.

### Other Changes
- Migrated code generation from AutoRest (Swagger) to TypeSpec. The public API is unchanged apart from the items listed
in this release.

## 12.38.0-beta.1 (2026-11-05)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<suppress files="com.azure.storage.blob.implementation.util.BlobUserAgentModificationPolicy.java" checks="io.clientcore.linting.extensions.checkstyle.checks.HttpPipelinePolicyCheck" />
<suppress files="com.azure.storage.blob.implementation.util.SessionAuthenticationPolicy.java" checks="io.clientcore.linting.extensions.checkstyle.checks.HttpPipelinePolicyCheck" />
<suppress files="com.azure.storage.blob.implementation.util.SessionAwareLoggingPolicy.java" checks="io.clientcore.linting.extensions.checkstyle.checks.HttpPipelinePolicyCheck" />
<suppress files="com.azure.storage.blob.implementation.AzureBlobStorageImplBuilder.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ServiceClientBuilderCheck" />
<suppress files="com.azure.storage.blob.BlobClient.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ServiceClientCheck" />
<suppress files="com.azure.storage.blob.specialized.BlobLeaseAsyncClient.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ServiceClientCheck" />
<suppress files="com.azure.storage.blob.specialized.BlobLeaseClient.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ServiceClientCheck" />
Expand All @@ -20,4 +19,8 @@
<suppress files="com.azure.storage.blob.implementation.ServicesImpl.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
<suppress files="com.azure.storage.blob.specialized.BlobInputStream.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
<suppress files="com.azure.storage.blob.specialized.BlobOutputStream.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
<suppress files="com.azure.storage.blob.implementation.models.BlobHierarchyListSegment.java" checks="io.clientcore.linting.extensions.checkstyle.checks.EnforceFinalFieldsCheck" />
<suppress files="com.azure.storage.blob.implementation.models.BlobLayoutEndpoints.java" checks="io.clientcore.linting.extensions.checkstyle.checks.EnforceFinalFieldsCheck" />
<suppress files="com.azure.storage.blob.implementation.models.BlobLayoutRanges.java" checks="io.clientcore.linting.extensions.checkstyle.checks.EnforceFinalFieldsCheck" />
<suppress files="com.azure.storage.blob.implementation.XmlSerializer.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
Comment on lines +22 to +25
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.azure</groupId>
Expand All @@ -10,8 +11,11 @@
<relativePath>../../../parents/azure-code-customization-parent</relativePath>
</parent>

<groupId>com.azure</groupId>
<name>Microsoft Azure Blob Storage client customization for Java</name>
<description>This package contains client customization for Microsoft Azure Blob Storage</description>

<groupId>com.azure.tools</groupId>
<artifactId>azure-storage-blob-customization</artifactId>
<version>1.0.0-beta.1</version>
<modelVersion>4.0.0</modelVersion>
</project>
<packaging>jar</packaging>
</project>
Loading
Loading