microsoft / azure-spring-boot

Spring Boot Starters for Azure services
MIT License
374 stars 460 forks source link

Unable to use Azurite as an Blob Storage emulator using storage spring boot starter:2.2.0 #762

Closed zoosm3 closed 4 years ago

zoosm3 commented 5 years ago

Environment

Summary

Unable to use the Blob Storage emulators with this SDK

Reproduce steps

  1. Use the latest Azurite or Azure Storage Emulator

  2. Configure application.properties based on Azurete's Storage Accounts

    azure.storage.account-name=devstoreaccount1
    azure.storage.account-key=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
    azure.storage.container-name=upload
    azure.storage.allow-telemetry=false
  3. Upload a file with TransferManager

final BlockBlobURL blockBlobURL = containerURL.createBlockBlobURL(getFullPath());

final AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(Paths.get(bean.getFullPath()));

TransferManager.uploadFileToBlockBlob(fileChannel, blockBlobURL, 8 * 1024 * 1024, createUploadOptions(getMimeType()))
                    .toCompletable()
                    .doOnComplete(() -> { putLog(); })
                    .doOnError(error -> { putLog(); })
                    .blockingAwait();

Expected Results

A file shoud be successfully uploaded to the Blob storage emulator but failed

because the endpoing is not 'http://devstoreaccount1.blob.core.windows.net/' but http://127.0.0.1:10000/myaccount/according to Enulator's Endpoint & Connection URL

Actual Results

2019-11-07 16:44:22.203  INFO 8440 --- [ionThreadPool-2] Azure Storage Java SDK                   : 'http://devstoreaccount1.blob.core.windows.net/upload?restype=container'==> OUTGOING REQUEST (Try number='4')

2019-11-07 16:44:50.227  WARN 8440 --- [ntLoopGroup-5-8] io.netty.util.concurrent.DefaultPromise  : An exception was thrown by com.microsoft.rest.v2.http.NettyClient$AcquisitionListener.operationComplete()

java.lang.NullPointerException: null
        at com.microsoft.rest.v2.http.NettyClient$AcquisitionListener.emitError(NettyClient.java:425) ~[client-runtime-2.0.2.jar:na]
        at com.microsoft.rest.v2.http.NettyClient$AcquisitionListener.operationComplete(NettyClient.java:246) ~[client-runtime-2.0.2.jar:na]
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:577) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:551) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.util.concurrent.DefaultPromise.access$200(DefaultPromise.java:35) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.util.concurrent.DefaultPromise$1.run(DefaultPromise.java:501) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518) ~[netty-transport-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

java.lang.RuntimeException: java.util.concurrent.TimeoutException: The source did not signal an event for 60 seconds and has been terminated.
        at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46) ~[rxjava-2.2.13.jar:na]
        at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:93) ~[rxjava-2.2.13.jar:na]
        at io.reactivex.Single.blockingGet(Single.java:2835) ~[rxjava-2.2.13.jar:na]
superrdean commented 5 years ago

Hi @zoosm3, Thanks for your feedback, as you said, the SDK doesn't support local emulator yet, because the endpoint is hard-coded in the SDK. You can have a try in Azure as your workaround. We may consider adding this feature in our next release. Very very sorry for the inconvenience.

zoosm3 commented 5 years ago

@neuqlz Hello, thanks for your support. We could upload files with a real Azure Blob Storage. Looking forward to the future update.

hkakutalua commented 4 years ago

Any update on this? Will you support the emulator in the foreseeable future? Thanks.

I can submit a pull request if no one is available for this.

hkakutalua commented 4 years ago

Nice, this weekend will be fun!

superrdean commented 4 years ago

Hi @Henry-Keys

PR is very welcome!

hkakutalua commented 4 years ago

PR Already Sent: https://github.com/microsoft/azure-spring-boot/pull/866