0

While trying to run the simple example from Storage-blobs-java-v10-quickstart and using the reference listed in API reference document as:

String accountName = "acsazurestore";
String accountKey = "qjC6s44AmSbAkJ7Xqdsks/jjZDIYRTY8qg...."; [not the full one]

SharedKeyCredentials sharedKeyCredentials = new SharedKeyCredentials(accountName, accountKey);

While compiling (mvn compile exec:java), the program fails with the below error message:

Caused by: java.lang.IllegalArgumentException: Input byte array has wrong 4-byte ending unit
at java.util.Base64$Decoder.decode0(Base64.java:704)
at java.util.Base64$Decoder.decode(Base64.java:526)
at java.util.Base64$Decoder.decode(Base64.java:549)
at com.microsoft.azure.storage.blob.SharedKeyCredentials.<init>(SharedKeyCredentials.java:60)
at quickstart.Quickstart.main(Quickstart.java:162)

Appreciate any help!

Suren Konathala
  • 3,497
  • 5
  • 43
  • 73

1 Answers1

1

It should work even with a fake account key. I assume that it may occur in the other code line. If it is not that case. I recommend that you could create a new project and add the following dependency.

<dependency>
        <groupId>com.microsoft.azure</groupId>

        <artifactId>azure-storage-blob</artifactId>

        <version>10.1.0</version>

</dependency>

And just add the following code and test again.

public static void main(String... args) throws Exception
    {
        String accountName = "accountName";
        String accountKey = "xxxxxxxxxxx";

        try {
            SharedKeyCredentials sharedKeyCredentials = new SharedKeyCredentials(accountName, accountKey);
            System.out.print(sharedKeyCredentials.getAccountName());
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        }

    }

Test Result:

enter image description here

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47