Friday, October 2, 2009

400 Bad Request accessing Azure Blob Storage

This one was kind of dumb. I'm posting it in hope someone doesn't loose as much time as I've lost. When I was trying to retrive a Blob Container object from Azure Blog Storage, I kept getting a "400 Bad Request" exception. After 3 hours I gave up and asked a friend to look at my code. In 3 minutes he spot the bug: I was using the Table Storage credentials on the acces to the Blob Storage.

Wrong code:
BlobStorage blobs = BlobStorage.Create(
StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration());
Right code:
BlobStorage blobs = BlobStorage.Create(
StorageAccountInfo.GetDefaultBlobStorageAccountFromConfiguration());
The StorageAccountInfo class has 3 methods to retrieve default credentials: GetDefaultTableStorageAccountFromConfiguration(), GetDefaultBlobStorageAccountFromConfiguration(), and GetDefaultQueueStorageAccountFromConfiguration(). One for each storage Azure has. Big names with little differences between them...

1 comment:

  1. Thanks a lot! I've had looking for this for hours.!!

    ReplyDelete