Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

storage key not a valid base64 encoding - azure storage - android

I am trying to upload a text blob to azure storage blob using the following code:

public static final String storageConnectionString = "DefaultEndpointsProtocol=http;"
        + "AccountName=MY_STORAGE_ACNT;"
        + "AccountKey=[MYKEY]";


CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);

        CloudBlobClient blobClient = account.createCloudBlobClient();

        CloudBlobContainer container = blobClient.getContainerReference("ubiety");

        container.createIfNotExists();
        BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
        containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
        container.uploadPermissions(containerPermissions);
        CloudBlockBlob blob1 = container.getBlockBlobReference("storage_name");
        blob1.uploadText("Hello, World1");

This is a mere copy paste of the sample at BlobBasics Sample, still

I get the error

StorageKey is not a valid Base64 Encoded string.

Can someone please help. I am very sure, i am using the correct key provided at the azure portal

Thank you.

like image 237
Lakshman Rao Pilaka Avatar asked Oct 20 '25 04:10

Lakshman Rao Pilaka


1 Answers

Looking at the sample link you've given it looks like you're using the Java Storage library rather than the Android Storage library. If you use the Android storage library and it's associated samples that should work correctly.

like image 119
Emily Gerner Avatar answered Oct 22 '25 03:10

Emily Gerner