0

I'm trying to download a file (feed.csv) from Azure Storage Account Container. I'm authenticating using Managed Identity and the identity has "Owner" Role Assignment for the Storage Account.

I'm assuming the authentication is successful as I'm able to print the Account and Container name. But I'm getting an error when I try to download the file.

Any help is much appreciated. Thank you

Edit: I have assigned "Storage Blob Data Contributor" Role to the managed identity but am still getting the same error. I'm looking at logCredentialUnavailableException and IdentityClient.lambda$checkIMDSAvailable$58 but have no idea how to resolve them..

This is the code:

ManagedIdentityCredential managedIdentityCredential = new ManagedIdentityCredentialBuilder()
    .clientId(<MANAGED_IDENTITY_CLIENT_ID>)
    .build();       

BlobServiceClient storageClient = new BlobServiceClientBuilder()
    .endpoint(endpoint)
    .credential(managedIdentityCredential)
    .buildClient();
        
BlobContainerClient blobContainerClient = storageClient.getBlobContainerClient(containerName);
        
System.out.println("Get Storage Account Name: "+blobContainerClient.getAccountName());
System.out.println("Get Container Name: "+blobContainerClient.getBlobContainerName());
        
BlobClient blobClient = blobContainerClient.getBlobClient("feed.csv");
blobClient.downloadToFile("./data/" + blobClient.getBlobName());

This is the error log:

Get Storage Account Name: ********
Get Container Name: ************
746 [parallel-1] ERROR reactor.core.scheduler.Schedulers - Scheduler worker in group main failed with an uncaught exception
java.lang.NoSuchMethodError: 'void com.azure.core.util.logging.ClientLogger.log(com.azure.core.util.logging.LogLevel, java.util.function.Supplier, java.lang.Throwable)'
    at com.azure.identity.implementation.util.LoggingUtil.logCredentialUnavailableException(LoggingUtil.java:90)
    at com.azure.identity.implementation.IdentityClient.lambda$checkIMDSAvailable$58(IdentityClient.java:1461)
    at reactor.core.publisher.MonoCallable.call(MonoCallable.java:92)
    at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:127)
    at reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.MonoFromFluxOperator.subscribe(MonoFromFluxOperator.java:81)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.Mono.subscribe(Mono.java:4400)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:263)
    at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    at reactor.core.publisher.MonoDelaySubscription.accept(MonoDelaySubscription.java:53)
    at reactor.core.publisher.MonoDelaySubscription.accept(MonoDelaySubscription.java:34)
    at reactor.core.publisher.FluxDelaySubscription$DelaySubscriptionOtherSubscriber.onNext(FluxDelaySubscription.java:131)
    at reactor.core.publisher.MonoDelay$MonoDelayRunnable.propagateDelay(MonoDelay.java:271)
    at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:286)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
Adam
  • 3
  • 3
  • TL;DR; - You need [Storage Blob Data Contributor](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#storage-blob-data-contributor) role for managing data inside a storage account. – Gaurav Mantri Jun 02 '22 at 09:41
  • Thanks, I have given Storage Blob Data Contributor role to my managed identity but I'm still getting the same error message – Adam Jun 02 '22 at 09:45
  • You may need to re-acquire the token. Generally speaking it takes some time for the roles to take effect. Please try after some time. – Gaurav Mantri Jun 02 '22 at 10:01
  • How can I re-acquire the token? Sorry it's my first time and I'm quite lost.. Thanks for your patience and guidance – Adam Jun 02 '22 at 17:42
  • The NoSuchMethodError suggests you have an incompatible combination of dependencies, where `com.azure.identity.implementation.util.LoggingUtil` tries to call a method in `com.azure.core.util.logging.ClientLogger` which does not exist. Please review the dependency versions of your project and make sure they are compatible (if possible, use a BOM dependency to manage this for you, but I don't know if there is one for Azure). – Mark Rotteveel Jun 04 '22 at 08:32

0 Answers0