osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to fix azure-blob component “Server failed to authenticate the request”


Tried azure-blob component as producer
public void configure() throws Exception {
    from("file://C:/input/ftp?noop=true")
        .routeId("azureFileImporter")
        .noAutoStartup()
        .log("Downloading file ${header.CamelFileName} complete.")
        .to(

"azure-blob://accountName/containerName/blockBlob?credentials=#azureAuthCreds&operation=updateBlockBlob")
        .end();
  }

azureAuthCreds bean is-
@Bean
  protected StorageCredentials azureAuthCreds() {
    return new StorageCredentialsAccountAndKey(
        "account",
        Base64.encode("azureAccountKey".getBytes()));
  }

Error is-
Route: azureFileImporter started and consuming from:
file://C:/input/ftp?noop=true
2018-12-26 21:33:29.181  INFO 69720 --- [://C:/ input/ftp]
azureFileImporter                        : Downloading file 181023_8145.DAT
complete.
2018-12-26 21:33:31.313 ERROR 69720 --- [://C:/ input/ftp]
o.a.camel.processor.DefaultErrorHandler  : Failed delivery for (MessageId:
ID-x-1545840183139-0-2 on ExchangeId: ID-x-1545840183139-0-1). Exhausted
after delivery attempt: 1 caught: java.io.IOException

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor
                                                Elapsed (ms)
[azureFileImporter ] [azureFileImporter ] [file://C:/input/ftp?noop=true
                                             ] [      2130]
[azureFileImporter ] [log1              ] [log
                                             ] [         5]
[azureFileImporter ] [to1               ]
[azure-blob://azzountName/containerName/blockBlob?credentials=#azureAuthCreds&operation=upda]
[      2119]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------

java.io.IOException: null
at
com.microsoft.azure.storage.core.Utility.initIOException(Utility.java:770)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.blob.BlobOutputStreamInternal.writeBlock(BlobOutputStreamInternal.java:443)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.blob.BlobOutputStreamInternal.access$000(BlobOutputStreamInternal.java:52)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.blob.BlobOutputStreamInternal$1.call(BlobOutputStreamInternal.java:387)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.blob.BlobOutputStreamInternal$1.call(BlobOutputStreamInternal.java:384)
~[azure-storage-5.5.0.jar:na]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_192]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
~[na:1.8.0_192]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_192]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[na:1.8.0_192]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[na:1.8.0_192]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_192]
Caused by: com.microsoft.azure.storage.StorageException: Server failed to
authenticate the request. Make sure the value of Authorization header is
formed correctly including the signature.
at
com.microsoft.azure.storage.StorageException.translateException(StorageException.java:89)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.core.StorageRequest.materializeException(StorageRequest.java:315)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:175)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.blob.CloudBlockBlob.uploadBlockInternal(CloudBlockBlob.java:1078)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.blob.CloudBlockBlob.uploadBlock(CloudBlockBlob.java:1050)
~[azure-storage-5.5.0.jar:na]
at
com.microsoft.azure.storage.blob.BlobOutputStreamInternal.writeBlock(BlobOutputStreamInternal.java:437)
~[azure-storage-5.5.0.jar:na]
... 9 common frames omitted


On Wed, Dec 26, 2018 at 10:37 AM Shafeeq Muhammad <
shafeeqe.muhammad@xxxxxxxxx> wrote:

> Hi,
> This is the full error stack:-
>
> 2018-12-26 10:29:05.128  WARN 39352 --- [i/pim/blockBlob]
> o.a.c.c.azure.blob.BlobServiceConsumer   : Consumer
> Consumer[azure-blob://account1/container1/blockBlob?credentials=%23azureAuth]
> failed polling endpoint:
> azure-blob://account1/container1/blockBlob?credentials=%23azureAuth. Will
> try again at next poll. Caused by:
> [com.microsoft.azure.storage.StorageException - Server failed to
> authenticate the request. Make sure the value of Authorization header is
> formed correctly including the signature.]
>
> com.microsoft.azure.storage.StorageException: Server failed to
> authenticate the request. Make sure the value of Authorization header is
> formed correctly including the signature.
>     at
> com.microsoft.azure.storage.StorageException.translateFromHttpStatus(StorageException.java:175)
> ~[azure-storage-5.5.0.jar:na]
>     at
> com.microsoft.azure.storage.StorageException.translateException(StorageException.java:94)
> ~[azure-storage-5.5.0.jar:na]
>     at
> com.microsoft.azure.storage.core.StorageRequest.materializeException(StorageRequest.java:315)
> ~[azure-storage-5.5.0.jar:na]
>     at
> com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:175)
> ~[azure-storage-5.5.0.jar:na]
>     at
> com.microsoft.azure.storage.blob.CloudBlob.downloadAttributes(CloudBlob.java:1239)
> ~[azure-storage-5.5.0.jar:na]
>     at
> com.microsoft.azure.storage.blob.BlobInputStream.<init>(BlobInputStream.java:155)
> ~[azure-storage-5.5.0.jar:na]
>     at
> com.microsoft.azure.storage.blob.CloudBlob.openInputStream(CloudBlob.java:2383)
> ~[azure-storage-5.5.0.jar:na]
>     at
> org.apache.camel.component.azure.blob.BlobServiceUtil.doGetBlob(BlobServiceUtil.java:97)
> ~[camel-azure-2.22.1.jar:2.22.1]
>     at
> org.apache.camel.component.azure.blob.BlobServiceUtil.getBlockBlob(BlobServiceUtil.java:67)
> ~[camel-azure-2.22.1.jar:2.22.1]
>     at
> org.apache.camel.component.azure.blob.BlobServiceUtil.getBlob(BlobServiceUtil.java:51)
> ~[camel-azure-2.22.1.jar:2.22.1]
>     at
> org.apache.camel.component.azure.blob.BlobServiceConsumer.getBlob(BlobServiceConsumer.java:57)
> ~[camel-azure-2.22.1.jar:2.22.1]
>     at
> org.apache.camel.component.azure.blob.BlobServiceConsumer.poll(BlobServiceConsumer.java:44)
> ~[camel-azure-2.22.1.jar:2.22.1]
>     at
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
> [camel-core-2.22.1.jar:2.22.1]
>     at
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
> [camel-core-2.22.1.jar:2.22.1]
>     at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> [na:1.8.0_192]
>     at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
> [na:1.8.0_192]
>     at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
> [na:1.8.0_192]
>     at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
> [na:1.8.0_192]
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> [na:1.8.0_192]
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> [na:1.8.0_192]
>     at java.lang.Thread.run(Thread.java:748) [na:1.8.0_192]
>
> On Sun, Dec 23, 2018 at 6:14 PM Sergey Beryozkin <sberyozkin@xxxxxxxxx>
> wrote:
>
>> Hi,
>> I'm pretty sure I did run the tests against a test account I had at a time
>> and it worked, I could see the blobs being uploaded (the secret has to be
>> base64-encoded as far as I recall). But the tests are currently ignored as
>> I could not solve the issue of setting up a test account during the actual
>> Camel build (the Azure emulator can only run on Win if I remember it
>> correctly...)
>>
>> thanks, Sergey
>>
>> On Sun, Dec 23, 2018 at 12:25 PM Claus Ibsen <claus.ibsen@xxxxxxxxx>
>> wrote:
>>
>> > Hi
>> >
>> > Have you tried look at the unit tests to see if there is an test that
>> > may help you on the way.
>> >
>> > And if possible can you post the full stracktrace, maybe edit the post
>> > on SO. And also try with newer Camel versions if possible.
>> >
>> > On Sat, Dec 22, 2018 at 11:13 AM Shafeeq Muhammad
>> > <shafeeqe.muhammad@xxxxxxxxx> wrote:
>> > >
>> > > Hi,
>> > >
>> > > I'm setting up apache-camel in spring boot application. And it is
>> worked
>> > > fine for file and ftp consumer/producer. But while trying to use
>> > azure-blob
>> > > component as consumer the following error appears.
>> > >
>> > > *com.microsoft.azure.storage.StorageException: Server failed to
>> > > authenticate the request. Make sure the value of Authorization header
>> is
>> > > formed correctly including the signature.*
>> > >
>> > > *My router is*
>> > >
>> > > *@Component*
>> > >
>> > > *public class AzureFileImporter extends RouteBuilder {*
>> > >
>> > > *@Bean*
>> > >
>> > > *protected StorageCredentials azureAuth() {*
>> > >
>> > > *return new StorageCredentialsAccountAndKey(*
>> > >
>> > > *    "AccountName",*
>> > >
>> > > *    "PlainAccountKey");*
>> > >
>> > > *}*
>> > >
>> > > *@Override*
>> > >
>> > > *public void configure() throws Exception {*
>> > >
>> > > * from("azure-blob:AccountName/ContainerName/blockBlob? *
>> > >
>> > > *  credentials=#azureAuth")*
>> > >
>> > > *    .routeId("azureFileImporter")*
>> > >
>> > > *    .noAutoStartup()*
>> > >
>> > > *    .log("Downloading file ${header.CamelFileName} complete.")*
>> > >
>> > > *    .to("file://input/ftp")*
>> > >
>> > > *    .end();*
>> > >
>> > > * }*
>> > >
>> > > *}*
>> > >
>> > > *While using azure-blob component with same account as producer no
>> error
>> > is
>> > > thrown. But the blob is not uploaded into the storage. Also tried with
>> > > Base64 encoding of the key.*
>> > >
>> > >
>> > > *Versions used:*
>> > >
>> > > *apache-camel : 2.22.1*
>> > >
>> > > *springBootVersion = '2.0.5.RELEASE'*
>> > >
>> > > Link to my stackoverflow question: here
>> > > <
>> >
>> https://stackoverflow.com/questions/53887740/how-to-fix-server-failed-to-authenticate-the-request-error-in-apache-camel-azu
>> > >
>> >
>> >
>> >
>> > --
>> > Claus Ibsen
>> > -----------------
>> > http://davsclaus.com @davsclaus
>> > Camel in Action 2: https://www.manning.com/ibsen2
>> >
>>
>