Answered Azure Storage for Java

  • Tuesday, February 21, 2012 6:24 PM
     
     

    Hi,

    I'm developping a Java app for Azure. I've currently no Azure account so I'm just developping my app on my laptop. I don't plan to subscribe until my testcase app works in local.

    I can connect to my local SQL server. But the table/blob storage doesn't work. I used the java code provided in the documentation. I added the required jar for connecting to storage service. The java code compiles, no problem. But when running the code, the console returns :

    Infos: StorageException encountered:
    Infos: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

    I'm using the default auth parameters (devstoreaccount1 and the very long password Eby8vd.......GMGw==

    The storage emulator is running..... I can browse the storage (by using the PHP azure plugin for eclipse)...

    Does anybody have any idea ? Does the code must run from inside the compute emulator ? Because for convenience, I run my code on a glassfish server which is not running inside the compute emulator.

All Replies

  • Wednesday, February 22, 2012 5:09 AM
     
     

    Hello.

    It seems that a problem is connected with your connection string.

    I received this problem some months ago and killed a day for resolving it. My problem was connected with wrong time on developer machine so when i send a request it was too old for server and was titled as stale (i don't know exactly, what words i can use for this situation, so sorry for my terminology).

    But google helped me with such a suggestions:

    1) Disable proxy.

    2) Check a certificate.

    3) Generate a shared secret signature for your blobs and properly set it up (advice from Steve Marx from somewhere in the forum, as a best practice for blob using).

    But it is local development environment so i think problem does not connected with proxy or cert.

    Maybe you can provide some additional info about request and response? It would be great.

  • Wednesday, February 22, 2012 3:58 PM
     
     

    First of all, thanks you both of you for your answers.

    Alexander, I've run wireshark and noticed that indeed, the request looks weird with the time

    I'm french, configured my laptop in GMT+1 with daylight saving time and I've run the request at 16:46:22. The header "x-ms-date" indicates 15:46:22, so the header is 1 hour too old......the initial HTTP PUT request indicates a timeout of 90....... I guess I must hit the timeout, as you said....

    The response packet contains this : 

    Message :

    Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\x0aRequestId:3160ab68-79ea-4325-ae58-708582a7f9c1\x0aTime:2012-02-22T15:46:18.8446499Z

    AuthenticationErrorDetail :

    The MAC signature found in the HTTP request '/V9ufqkos7fQsPFrG9db1c/ZSRTFQeOCH9R6d660GhM=' is not the same as any computed signature. Server used following string to sign: 'PUT\x0a\x0a\x0a0\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0ax-ms-date:Wed, 22 Feb 2012 15:46:22 GMT\x0ax-ms-version:2011-08-18\x0a/devstoreaccount1/gettingstarted\x0arestype:container\x0atimeout:90'.

  • Wednesday, February 22, 2012 4:15 PM
     
     

    I've run another test just to be sure : i've set my clock at h-1. So currently, the truth is that it's 17h10. I've set my clock at 16h10. Here is the answer from the request to BLOB : 

    Request date header too old: 'Wed, 22 Feb 2012 15:10:28 GMT'

    It's based on GMT.... always 1 hour before my laptop time...

    How could I solve this ? Configuring the computer at GMT+0 ?

  • Wednesday, February 22, 2012 4:30 PM
     
     

    Yes actually, I'm configured with UTC, not GMT, sorry for the mistake.

    I've run another test. I've set my laptop at UTC+0, I've run the query again and the date is exactly the same as it should be, it's correct. It seems it's finally not related to the date. 

    I've the very same message as before : 

    The MAC signature found in the HTTP request 'DABdM6/BdW6qSWVm7ONQgY80t8j/XD5Z7cKpzEwHVqY=' is not the same as any computed signature. Server used following string to sign: 'PUT\x0a\x0a\x0a0\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0a\x0ax-ms-date:Wed, 22 Feb 2012 16:21:22 GMT\x0ax-ms-version:2011-08-18\x0a/devstoreaccount1/essai\x0arestype:container\x0atimeout:90'.

    I'm just running this sample code : https://github.com/WindowsAzure/azure-sdk-for-java

    (of course, I added the microsoft api jar and anyway, the code compiles and throws an error...)

    Anybody has an idea ?

  • Wednesday, February 22, 2012 6:49 PM
     
     Answered

    A few options here, I believe the reason you are having issues is that you are using the devstore credentials without providing endpoints for the local storage. This can be done manually, or you can make use of CloudStorageAccount.getDevelopmentStorageAccount(); and create your service clients from there.

    Otherwise try the following:

    final String AccountName = "devstoreaccount1";
    final String AccountSecurityKey = "Eby8vd....";
    URI BlobEndPoint = new URI("http://127.0.0.1:10000/devstoreaccount1");
    URI QueueEndPoint = new URI("http://127.0.0.1:10001/devstoreaccount1");
    URI TableEndPoint = new URI("http://127.0.0.1:10002/devstoreaccount1");

    CloudBlobClient bClient = new CloudBlobClient(BlobEndPoint, new StorageCredentialsAccountAndKey(AccountName,
                        AccountSecurityKey));

    CloudQueueClient qClient = new CloudQueueClient(QueueEndPoint, new StorageCredentialsAccountAndKey(AccountName,
                        AccountSecurityKey));

    • Marked As Answer by will-b Wednesday, February 22, 2012 7:38 PM
    •  
  • Wednesday, February 22, 2012 7:38 PM
     
     

    Joe, you solved my issue !

    I added the Blob URI, added your statement for CloudBlobClient and that worked ! THANK YOU A LOT !!!