Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

azure blob storage "No valid combination of account information found"

I have an MVC4 project that I am running using Azure websites preview.

My problem is that I cant upload a blob into my blob storage container when I have deployed my website to azure, however the upload works fine when I'm debugging locally.

This is the exception and stack trace I get when deployed and I try to upload to a container:

No valid combination of account information found. at Microsoft.WindowsAzure.Storage.CloudStorageAccount.b__0(String err) at Microsoft.WindowsAzure.Storage.CloudStorageAccount.TryParse(String s, CloudStorageAccount& accountInformation, Action`1 error) at Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(String connectionString) at MyProj.Controllers.ImageController.Upload(ImageViewModel model)

Specifically as per the stack trace it is the .Parse method which is failing.

The code I am using to connect to the blob storage is straight from the azure how-to documentation:

string connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

Once again, this works fine when I running locally on my dev box, I can upload successfully with no problems. However it gives me this error when deployed and I attempt to do exactly the same thing.

I'm guessing my storageConnectionString is being messed with during the web deploy publish process but I'm unsure about how to resolve this?

like image 909
Oliver Tomlinson Avatar asked Dec 17 '12 11:12

Oliver Tomlinson


3 Answers

Be sure that

1) You are using the proper protocol for diagnostics (double click the role -> configuration tab -> select the configuration -> under "Diagnostics", click the ellipsis -> try to click OK...if it gives error that you must use https, change the connection strings to https)

and

2) No white spaces allowed...i.e. UseDevelopmentStorage=true;DevelopmentStorageProxyUri=https://127.0.0.1 instead of UseDevelopmentStorage=true; DevelopmentStorageProxyUri=https://127.0.0.1

(note space after the semi-colon)

Check for https and white space in all connection strings on the Settings tab

---EDIT----

Putting "https" in actually screwed everything up for us. Worker role would throw an exception ("Handshack failed due to an unexpected packet format.") and then cycle between unknown and destroyed. Removed the "s" in "https" and made sure there were no white spaces and voila.

like image 170
Scott Decker Avatar answered Oct 19 '22 17:10

Scott Decker


Another way of getting the CloadStorageAccount instance is doing this

StorageCredentials credentials = new StorageCredentials(accountName, accountKey);
CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, true);

This should help anyone that has this parsing problem.

like image 45
Andreas Avatar answered Oct 19 '22 16:10

Andreas


Store your storage connection string in AppSettings, not in ConnectionStrings section. And, pasting here the actual connection string will help us help you (you may put * for the account key).

like image 16
astaykov Avatar answered Oct 19 '22 17:10

astaykov