azure blob storage "No valid combination of account information found"
Asked Answered
M

15

30

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?

Marchpane answered 17/12, 2012 at 11:47 Comment(4)
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).Apperception
Okay, I've moved the connection string into AppSettings and this is working fine now. Bizarre! Thanks for the help :)Marchpane
So, @Apperception - how's about reposting as an answer, so oTomo can mark as such... :)Stabler
It's kinda strange that this fixes the error. In the end CloudStorageAccount.Parse is called with the same connection string so it should work all the same...Gluey
A
17

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).

Apperception answered 17/12, 2012 at 18:27 Comment(4)
I tried this but still get the "no valid combination of account information found" error. My connection string key/value is key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***;BlobEndpoint=customEndpoint". var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);Eurypterid
Why would this make any difference? In the end it's just a string, and ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString works just fine for me... Needless to say, saving this as a connection string makes more sense.Kyanite
Yes, Ohad, probably. But not in 2012, when the Connection Strings provider of the COnfiguration Manager had no idea of Azure Storage Connection Strings, and when the question was posted and answered ....Apperception
Check also for start and end quotes.Apograph
F
36

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.

Frasier answered 16/10, 2013 at 15:47 Comment(10)
NOTE: This was only happening for devs using Compute Emulator 2.0 or greater.Frasier
Adding the DevelopmentStorageProxyUri to the connection string got me connected.Watereddown
I had spaces between the " = true" - I think VS introduced them when I copied and pasted before wrapping in speech marks, and I didnt notice!Dimetric
Removing the white spaces did it for me. Thanks! Good tutorial: codeproject.com/Articles/490178/…Kermie
I didn't know a space would be a problem!! removing spaces had solved the problem. Thanks!Culminate
https was the problem, !Unprovided
Re-iterating the importance of whitespace: I just ran into the same problem because my connection string had a \r\n at the end. Run .Trim() on the string read from your source.Statuette
Work for me. Trim the connection stringBehaviorism
I had True instead of true. It's case sensitive as well.Distribute
No white spaces allowed, fixed the issue for me. tks.Windhover
H
19

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.

Hendrix answered 30/6, 2014 at 8:20 Comment(1)
the class StorageCredentials is now abstract class use the class StorageCredentialsAccountAndKey insteadContagium
A
17

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).

Apperception answered 17/12, 2012 at 18:27 Comment(4)
I tried this but still get the "no valid combination of account information found" error. My connection string key/value is key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***;BlobEndpoint=customEndpoint". var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);Eurypterid
Why would this make any difference? In the end it's just a string, and ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString works just fine for me... Needless to say, saving this as a connection string makes more sense.Kyanite
Yes, Ohad, probably. But not in 2012, when the Connection Strings provider of the COnfiguration Manager had no idea of Azure Storage Connection Strings, and when the question was posted and answered ....Apperception
Check also for start and end quotes.Apograph
F
8

I got this error because missed the prefix BlobEndpoint= before Blob SAS URL:

wrong appsettings.json

{
  "TestBlobWriter": {
    "ConnectionString": "https://test.blob.core.windows.net/test-container?sp=*&st=*&se=*&spr=*&sv=*&sr=*&sig=*",
    "ContainerName": "test-container"
  }
}

correct appsettings.json

{
  "TestBlobWriter": {
    "ConnectionString": "BlobEndpoint=https://test.blob.core.windows.net/test-container?sp=*&st=*&se=*&spr=*&sv=*&sr=*&sig=*",
    "ContainerName": "test-container"
  }
}
Fluctuate answered 8/4, 2021 at 6:59 Comment(0)
E
3

I think, that could not be the cause of the problem as was expressed by Sandino Di Mattia. I had the same one when upgraded the SDK to the 2.0 and turned out that the API's connection string parser tolerates no more whitespaces in the connection string and it was not mentioned anywhere. If this kind of change was intentional, I would call it a nasty move...

Excite answered 23/4, 2013 at 12:16 Comment(1)
I'm unfortunately seeing this same issue trying to connect to an azure queue. The string is in app settings, and there is no whitespace to be found in the string :(Krystenkrystin
S
2

Be aware, too, that casing in the connection string matters. I experienced this error before when a large merge caused someone to "AccountName" to "Accountname" in my Web.config. Using the correct casing fixed the error.

Solicitor answered 24/8, 2016 at 16:11 Comment(0)
G
1

If you are very sure that, the connection string copied from Azure service is same as you pasted, then please check whether you have given any carriage return / space for the sake of readability, it's also one of the reasons caused that issue which you have experienced. I tried to give +1 for @scottndecker but couldn't since I don't have 15 reputation.

Ghiselin answered 14/4, 2015 at 5:5 Comment(0)
G
0

Don't forget to include the "https://" or "https://" when using the proxyUri. Like:

UseDevelopmentStorage=true;DevelopmentStorageProxyUri=https://127.0.0.1

Grimbal answered 17/12, 2017 at 23:4 Comment(0)
C
0

I got this because I had accidently added a newline character (\r\n) at the end of the string.

Chichi answered 12/1, 2018 at 14:48 Comment(0)
G
0

I also got the same issue, and i found it in the namespace. The CloudStorageAccount class is present in both the namespaces

using Microsoft.WindowsAzure;

using Microsoft.WindowsAzure.Storage;

So I just removed WindowsAzure namespace and added WindowsAzure.Storage in my code.

Previous Code:

using Microsoft.WindowsAzure;

Fixed Code:

using Microsoft.WindowsAzure.Storage;
Gunman answered 10/8, 2018 at 5:33 Comment(0)
B
0

I was facing same issue. You need to use Microsoft.WindowsAzure.Storage name space and make sure there is not an extra space in connection string.

Bootie answered 19/9, 2018 at 10:34 Comment(0)
A
0

I got this error because I used the wrong nuget package, (I am using dot net 4.6.1)

The wrong package was: WindowsAzureStorage.Helper

The correct package is: WindowsAzure.Storage

and make sure you use the namespace: using Microsoft.WindowsAzure.Storage;

Audio answered 19/3, 2019 at 12:47 Comment(1)
I don't think the asker got the error from that typo.Goggles
P
0

I encountered this error when I had migrated a storage connection string from app settings literal to a keyvault reference using @Microsoft.KeyVault(SecretUri=https...) I'd created a new function app and had forgotten to turn on system-assigned identity and given the app access to keyvault. Hence, the symptom was an undefined app settings value - a failed storage connection attempt.

Paltry answered 16/5, 2019 at 5:19 Comment(0)
C
0

I will share the solution of my problem. I was thinking that the brackets must stay and enter the information inside them. After removing the brackets, my problem was solved.

From:

string eventHubName = "{Event Hub name}";

To:

string eventHubName = "Event Hub name";

The same goes for: eventHubConnectionString, storageAccountName and storageAccountKey

Crispin answered 1/8, 2019 at 13:47 Comment(1)
Thank you @SurajRao for the remarks, is this better now?Crispin
P
0

To solve this issue on azure, don't use the default string but use a minimalistic version such as :

<add name="StorageConnection" 
    connectionString="DefaultEndpointsProtocol=https;AccountName=name;AccountKey=yourkey;EndpointSuffix=core.windows.net" />

Without whitespace or line breaks!!

Pulsation answered 24/2, 2021 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.