2

I'm working on integrating Azure Blob Storage into a Java application using the Azure SDK. When initializing the BlobContainerClient, I encounter the following error only on the server (not on my local machine):

Caused by: **java.lang.IllegalStateException**: A request was made to load the default HttpClient provider but one could not be found on the classpath. If you are using a dependency manager, consider including a dependency on azure-core-http-netty or azure-core-http-okhttp. Depending on your existing dependencies, you have the choice of Netty or OkHttp implementations. Additionally, refer to https://aka.ms/azsdk/java/docs/custom-httpclient to learn about writing your own implementation.

    at com.azure.core.implementation.http.HttpClientProviders.createInstance(HttpClientProviders.java:37)
    at com.azure.core.http.HttpClient.createDefault(HttpClient.java:27)
    at com.azure.core.http.HttpPipelineBuilder.build(HttpPipelineBuilder.java:60)
    at com.azure.storage.blob.implementation.util.BuilderHelper.buildPipeline(BuilderHelper.java:110)
    at com.azure.storage.blob.BlobServiceClientBuilder.buildAsyncClient(BlobServiceClientBuilder.java:107)
    at com.azure.storage.blob.BlobServiceClientBuilder.buildClient(BlobServiceClientBuilder.java:84)
    at com.azure.service.impl.AzureBlobAuthService.authenticate(AzureBlobAuthService.java:46)

Here is the relevant part of my code:

 BlobContainerClient containerClient = new BlobContainerClientBuilder()
        .endpoint(config.getSasUrl())
        .containerName(config.getContainerName())
        .buildClient();

Additional Info: I'm using Maven with the following dependency:

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-storage-blob</artifactId>
    <version>12.9.0</version>
</dependency>
2
  • could you please clarify what you mean by server, is the app running on an Azure Web App, VM, container or something else? Commented May 6 at 10:22
  • Our app is running in a container, managed by Amazon EKS. Commented May 6 at 10:29

1 Answer 1

-1

The Azure SDK for Java uses a pluggable HTTP client architecture. It doesn't bundle a specific HTTP client implementation by default. Instead, it relies on you to provide one (either Netty or OkHttp) as a dependency in your project. When the SDK tries to create a default HTTP client and can't find either Netty or OkHttp on the classpath, it throws the IllegalStateException.

Solutions Using Netty dependency:

You need to explicitly add azure-core-http-netty as a dependency to your project. Choose one based on your project's existing dependencies and preferences.

Maven dependency:



<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-core-http-netty</artifactId>
    <version>1.13.8</version> <!-- Use the latest version -->
</dependency>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.