[BUG] Using azure.storage.blob together with azure.identity in Azure Functions results in NoSuchMethodError
See original GitHub issueDescribe the bug I am trying to connect to a Storage Account using azure.identity from an Azure Function. I tried using Managed Identity for this but the process of debugging (constantly deploying) took to long so I created a service principal with a secret for easy local debugging.
When using com.azure.identity to provide credentials to com.azure.storage while running as an Azure Function, you will get a NoSuchMethodError
on io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)
Note 1: Originally I tried the listBlobs() method prior to trying to create containers. The effect was the same.
Note 2: I have tried both Application ID and Object ID to create ClientSecretCredential
object, I get an authentication error with when using Object ID. Storage Account log show me correctly authenticated as service principal.
Note 3: Without adding slf4j-jdk14 to the dependencies, I do not get any feedback or errors at all. It just… does nothing?
Note 4: most important note I think: when building, if it runs the complementary test scripts (as-is, I haven’t changed anything to them), it actually does create the storage account. When deleting the test scripts and rebuild the code, it gives the same error.
Exception or Stack Trace
[01/05/2020 16:55:18] Host lock lease acquired by instance ID '0000000000000000000000005847D5B8'.
[01/05/2020 16:55:26] Executing HTTP request: {
[01/05/2020 16:55:26] "requestId": "377bfb13-196d-4bee-a501-d6a5fe8b88c6",
[01/05/2020 16:55:26] "method": "GET",
[01/05/2020 16:55:26] "uri": "/api/HttpExample"
[01/05/2020 16:55:26] }
[01/05/2020 16:55:27] Executing 'Functions.HttpExample' (Reason='This function was programmatically called via the host APIs.', Id=09aed63f-7cd6-4667-9863-ad4031c0ae0e)
[01/05/2020 16:55:27] Java HTTP trigger processed a request.
[01/05/2020 16:55:30] May 01, 2020 6:55:30 PM reactor.util.Loggers$Slf4JLogger error
[01/05/2020 16:55:30] SEVERE: Operator called default onErrorDropped
[01/05/2020 16:55:30] java.lang.NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z
[01/05/2020 16:55:30] at reactor.netty.http.client.HttpClientSecure.<clinit>(HttpClientSecure.java:79)
[01/05/2020 16:55:30] at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:298)
[01/05/2020 16:55:30] at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
[01/05/2020 16:55:30] at reactor.core.publisher.FluxRetryPredicate$RetryPredicateSubscriber.resubscribe(FluxRetryPredicate.java:124)
[01/05/2020 16:55:30] at reactor.core.publisher.MonoRetryPredicate.subscribeOrReturn(MonoRetryPredicate.java:51)
[01/05/2020 16:55:30] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:48)
[01/05/2020 16:55:30] at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:323)
[01/05/2020 16:55:30] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55)
[01/05/2020 16:55:30] at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
[01/05/2020 16:55:30] at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:173)
[01/05/2020 16:55:30] at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:173)
[01/05/2020 16:55:30] at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:495)
[01/05/2020 16:55:30] at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:495)
[01/05/2020 16:55:30] at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287)
[01/05/2020 16:55:30] at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1705)
[01/05/2020 16:55:30] at reactor.core.publisher.MonoCompletionStage.lambda$subscribe$0(MonoCompletionStage.java:86)
[01/05/2020 16:55:30] at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
[01/05/2020 16:55:30] at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
[01/05/2020 16:55:30] at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
[01/05/2020 16:55:30] at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1609)
[01/05/2020 16:55:30] at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596)
[01/05/2020 16:55:30] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
[01/05/2020 16:55:30] at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
[01/05/2020 16:55:30] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
[01/05/2020 16:55:30] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
To Reproduce Create a new Function in VS Code based on Java. Add the following dependencies to the POM:
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.6.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.0.5</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
(note: the slf4j-jdk14 dependency is required for actually seeing any stacktrace at all)
Import the following in your function:
import com.azure.storage.blob.*;
import com.azure.identity.*;
Code Snippet Replace the entire Function body with this:
context.getLogger().info("Java HTTP trigger processed a request.");
String storageURI = "https://storageaccounthere.blob.core.windows.net";
ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("ApplicationID_of_ServicePrincipal")
.clientSecret("Secret_I_created_in_Service_Principal")
.tenantId("My_Tenant_ID")
.build();
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint(storageURI)
.credential(clientSecretCredential)
.buildClient();
String listOfFiles = "";
int x = 0;
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HHmmA");
LocalDateTime now = LocalDateTime.now();
String tstamp = dtf.format(now);
blobServiceClient.createBlobContainer(tstamp);
return request.createResponseBuilder(HttpStatus.OK).body("\n listofFiles: " + listOfFiles + "\n number: " + x).build();
Expected behavior To have new containers created with every visit to the function when running locally, not only when running the test scripts.
Screenshots None.
Setup (please complete the following information):
- OS: Win10 18363.778
- IDE : VS Code 1.44.2
- Version of the Library used : see POM dependencies
Additional context
I ran the following command to see if there was any issue:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
This is the outcome:
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< com.javafuncmi:javafuncmi-test >-------------------
[INFO] Building Azure Java Functions 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ javafuncmi-test ---
[WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution
[INFO] com.javafuncmi:javafuncmi-test:jar:1.0-SNAPSHOT
[INFO] +- org.slf4j:slf4j-jdk14:jar:1.7.25:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- com.microsoft.azure.functions:azure-functions-java-library:jar:1.3.1:compile
[INFO] +- com.azure:azure-storage-blob:jar:12.6.0:compile
[INFO] | +- com.azure:azure-core:jar:1.4.0:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.10.1:compile
[INFO] | | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.1:compile
[INFO] | | | +- com.fasterxml.jackson.core:jackson-core:jar:2.10.1:compile
[INFO] | | | \- com.fasterxml.jackson.core:jackson-databind:jar:2.10.1:compile
[INFO] | | | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.10.1:compile - omitted for duplicate)
[INFO] | | | \- (com.fasterxml.jackson.core:jackson-core:jar:2.10.1:compile - omitted for duplicate)
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.10.1:compile
[INFO] | | | +- (com.fasterxml.jackson.core:jackson-core:jar:2.10.1:compile - omitted for duplicate)
[INFO] | | | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.10.1:compile - omitted for duplicate)
[INFO] | | | +- (com.fasterxml.jackson.core:jackson-databind:jar:2.10.1:compile - omitted for duplicate)
[INFO] | | | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.10.1:compile
[INFO] | | | | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.10.1:compile - omitted for duplicate)
[INFO] | | | | +- (com.fasterxml.jackson.core:jackson-core:jar:2.10.1:compile - omitted for duplicate)
[INFO] | | | | +- (com.fasterxml.jackson.core:jackson-databind:jar:2.10.1:compile - omitted for duplicate)
[INFO] | | | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[INFO] | | | | | \- (jakarta.activation:jakarta.activation-api:jar:1.2.1:compile - omitted for duplicate)
[INFO] | | | | \- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[INFO] | | | +- org.codehaus.woodstox:stax2-api:jar:4.2:compile
[INFO] | | | \- com.fasterxml.woodstox:woodstox-core:jar:6.0.2:compile
[INFO] | | | \- (org.codehaus.woodstox:stax2-api:jar:4.2:compile - omitted for duplicate)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.28:compile - omitted for conflict with 1.7.25)
[INFO] | | +- io.projectreactor:reactor-core:jar:3.3.3.RELEASE:compile
[INFO] | | | \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] | | \- io.netty:netty-tcnative-boringssl-static:jar:2.0.27.Final:compile
[INFO] | \- com.azure:azure-storage-common:jar:12.6.0:compile
[INFO] | +- (com.azure:azure-core:jar:1.4.0:compile - omitted for duplicate)
[INFO] | \- com.azure:azure-core-http-netty:jar:1.5.0:compile
[INFO] | +- (com.azure:azure-core:jar:1.4.0:compile - omitted for duplicate)
[INFO] | +- io.netty:netty-handler:jar:4.1.45.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.45.Final:compile
[INFO] | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- io.netty:netty-transport:jar:4.1.45.Final:compile
[INFO] | | | +- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.45.Final:compile
[INFO] | | | \- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | \- io.netty:netty-codec:jar:4.1.45.Final:compile
[INFO] | | +- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | \- (io.netty:netty-transport:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- io.netty:netty-handler-proxy:jar:4.1.45.Final:compile
[INFO] | | +- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-transport:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-codec:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- io.netty:netty-codec-socks:jar:4.1.45.Final:compile
[INFO] | | | +- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | | +- (io.netty:netty-transport:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | | \- (io.netty:netty-codec:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | \- (io.netty:netty-codec-http:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- io.netty:netty-buffer:jar:4.1.45.Final:compile
[INFO] | | \- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- io.netty:netty-codec-http:jar:4.1.45.Final:compile
[INFO] | | +- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-transport:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-codec:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | \- (io.netty:netty-handler:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- io.netty:netty-codec-http2:jar:4.1.45.Final:compile
[INFO] | | +- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-transport:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-codec:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-handler:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | \- (io.netty:netty-codec-http:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- io.netty:netty-transport-native-unix-common:jar:4.1.45.Final:compile
[INFO] | | +- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | \- (io.netty:netty-transport:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.45.Final:compile
[INFO] | | +- (io.netty:netty-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-buffer:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | +- (io.netty:netty-transport:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | | \- (io.netty:netty-transport-native-unix-common:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | \- io.projectreactor.netty:reactor-netty:jar:0.9.5.RELEASE:compile
[INFO] | +- (io.netty:netty-codec-http:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- (io.netty:netty-codec-http2:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- (io.netty:netty-handler:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- (io.netty:netty-handler-proxy:jar:4.1.45.Final:compile - omitted for duplicate)
[INFO] | +- (io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.45.Final:compile - omitted for duplicate)
[INFO] | \- (io.projectreactor:reactor-core:jar:3.3.3.RELEASE:compile - omitted for duplicate)
[INFO] +- com.azure:azure-identity:jar:1.0.5:compile
[INFO] | +- (com.azure:azure-core:jar:1.4.0:compile - omitted for duplicate)
[INFO] | +- com.microsoft.azure:msal4j:jar:0.5.0-preview:compile
[INFO] | | +- (com.nimbusds:oauth2-oidc-sdk:jar:6.5:compile - omitted for conflict with 6.14)
[INFO] | | +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.21:compile - omitted for conflict with 1.7.25)
[INFO] | | +- commons-codec:commons-codec:jar:1.11:compile
[INFO] | | +- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] | | +- org.projectlombok:lombok:jar:1.18.6:compile
[INFO] | | \- org.apache.httpcomponents:httpclient:jar:4.5:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.1:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | \- (commons-codec:commons-codec:jar:1.9:compile - omitted for conflict with 1.11)
[INFO] | +- com.nimbusds:oauth2-oidc-sdk:jar:6.14:compile
[INFO] | | +- com.sun.mail:javax.mail:jar:1.6.1:compile
[INFO] | | | \- javax.activation:activation:jar:1.1:compile
[INFO] | | +- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] | | +- net.minidev:json-smart:jar:2.3:compile
[INFO] | | | \- net.minidev:accessors-smart:jar:1.2:compile
[INFO] | | | \- org.ow2.asm:asm:jar:5.0.4:compile
[INFO] | | +- com.nimbusds:lang-tag:jar:1.4.4:compile
[INFO] | | \- com.nimbusds:nimbus-jose-jwt:jar:8.16:compile
[INFO] | | +- (com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile - omitted for duplicate)
[INFO] | | \- (net.minidev:json-smart:jar:2.3:compile - omitted for duplicate)
[INFO] | +- org.nanohttpd:nanohttpd:jar:2.3.1:compile
[INFO] | \- net.java.dev.jna:jna-platform:jar:5.4.0:compile
[INFO] | \- net.java.dev.jna:jna:jar:5.4.0:compile
[INFO] +- org.junit.jupiter:junit-jupiter:jar:5.4.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter-api:jar:5.4.2:test
[INFO] | | +- org.apiguardian:apiguardian-api:jar:1.0.0:test
[INFO] | | +- org.opentest4j:opentest4j:jar:1.1.1:test
[INFO] | | \- org.junit.platform:junit-platform-commons:jar:1.4.2:test
[INFO] | | \- (org.apiguardian:apiguardian-api:jar:1.0.0:test - omitted for duplicate)
[INFO] | +- org.junit.jupiter:junit-jupiter-params:jar:5.4.2:test
[INFO] | | +- (org.apiguardian:apiguardian-api:jar:1.0.0:test - omitted for duplicate)
[INFO] | | \- (org.junit.jupiter:junit-jupiter-api:jar:5.4.2:test - omitted for duplicate)
[INFO] | \- org.junit.jupiter:junit-jupiter-engine:jar:5.4.2:test
[INFO] | +- (org.apiguardian:apiguardian-api:jar:1.0.0:test - omitted for duplicate)
[INFO] | +- org.junit.platform:junit-platform-engine:jar:1.4.2:test
[INFO] | | +- (org.apiguardian:apiguardian-api:jar:1.0.0:test - omitted for duplicate)
[INFO] | | +- (org.opentest4j:opentest4j:jar:1.1.1:test - omitted for duplicate)
[INFO] | | \- (org.junit.platform:junit-platform-commons:jar:1.4.2:test - omitted for duplicate)
[INFO] | \- (org.junit.jupiter:junit-jupiter-api:jar:5.4.2:test - omitted for duplicate)
[INFO] \- org.mockito:mockito-core:jar:2.23.4:test
[INFO] +- net.bytebuddy:byte-buddy:jar:1.9.3:test
[INFO] +- net.bytebuddy:byte-buddy-agent:jar:1.9.3:test
[INFO] \- org.objenesis:objenesis:jar:2.6:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.766 s
[INFO] Finished at: 2020-05-01T19:14:45+02:00
[INFO] ------------------------------------------------------------------------
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Bug Description Added
- Repro Steps Added
- Setup information Added
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
@JarroVGIT
This is the Underlying Issue: The Azure Functions environment has grpc netty dependency in their class path which conflicts with the netty dependency coming in from our Azure SDKs. This conflict results in NoSuchMethodError.
This issue is being fixed on Azure Functions side and can be tracked at https://github.com/Azure/azure-functions-java-worker/issues/381
To get things unblocked, you can use our okhttp client with storage blob. You’l need to update your pom.xml with these dependencies:
The fix on Azure Functions end has been released for this. https://github.com/Azure/azure-functions-core-tools/releases
Core tools have been released v3 3.0.2852 or higher v2 2.7.2855 or higher
After upgrading the function core tools to the latest release.
For Java 8 Functions environment: Users will need to add
FUNCTIONS_WORKER_JAVA_LOAD_APP_LIBS
application setting as True or 1. This will opt-in and load the client jars first and then worker jars.JAVA 11 will use only the client jars no need to add any application settings.
Let us know if you have any questions or would like to reopen this issue.