C# 天蓝色 blob 存储“找不到有效的帐户信息组合”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13913589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
azure blob storage "No valid combination of account information found"
提问by Oliver Tomlinson
I have an MVC4 project that I am running using Azure websites preview.
我有一个正在使用 Azure 网站预览版运行的 MVC4 项目。
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.
我的问题是,当我将网站部署到 azure 时,我无法将 blob 上传到我的 blob 存储容器中,但是当我在本地调试时,上传工作正常。
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)
未找到有效的帐户信息组合。在 Microsoft.WindowsAzure.Storage.CloudStorageAccount.b__0(String err) 在 Microsoft.WindowsAzure.Storage.CloudStorageAccount.TryParse(String s, CloudStorageAccount& accountInformation, Action`1 error) 在 Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(String connectionString)在 MyProj.Controllers.ImageController.Upload(ImageViewModel 模型)
Specifically as per the stack trace it is the .Parse method which is failing.
特别是根据堆栈跟踪,它是失败的 .Parse 方法。
The code I am using to connect to the blob storage is straight from the azure how-to documentation:
我用来连接到 blob 存储的代码直接来自 azure how-to 文档:
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?
我猜我的 storageConnectionString 在网络部署发布过程中被搞乱了,但我不确定如何解决这个问题?
采纳答案by astaykov
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).
将您的存储连接字符串存储在 AppSettings 中,而不是在 ConnectionStrings 部分中。并且,在此处粘贴实际的连接字符串将有助于我们为您提供帮助(您可以将*作为帐户密钥)。
回答by user2115104
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...
我认为,这不可能是 Sandino Di Mattia 所说的问题的原因。将 SDK 升级到 2.0 时,我也遇到了同样的情况,结果发现 API 的连接字符串解析器不再容忍连接字符串中的空格,并且在任何地方都没有提到。如果这种改变是故意的,我会称其为令人讨厌的举动......
回答by scottndecker
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)
1)您正在使用正确的诊断协议(双击角色-> 配置选项卡-> 选择配置-> 在“诊断”下,单击省略号-> 尝试单击确定...如果出现错误,您必须使用 https,将连接字符串更改为 https)
and
和
2) No white spaces allowed...i.e.
UseDevelopmentStorage=true;DevelopmentStorageProxyUri=https://127.0.0.1instead of
UseDevelopmentStorage=true; DevelopmentStorageProxyUri=https://127.0.0.1
2) 不允许有空格...即
UseDevelopmentStorage=true;DevelopmentStorageProxyUri=https://127.0.0.1代替
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
检查“设置”选项卡上所有连接字符串中的 https 和空格
---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.
将“https”放入实际上为我们搞砸了一切。Worker 角色会抛出异常(“Handshack 由于意外的数据包格式而失败。”)然后在未知和销毁之间循环。删除了“https”中的“s”并确保没有空格,瞧。
回答by Andreas
Another way of getting the CloadStorageAccount instance is doing this
获取 CloadStorageAccount 实例的另一种方法是这样做
StorageCredentials credentials = new StorageCredentials(accountName, accountKey);
CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, true);
This should help anyone that has this parsing problem.
这应该可以帮助任何有这个解析问题的人。
回答by ganesan arunachalam
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.
如果您确定从Azure服务复制的连接字符串与您粘贴的相同,那么为了可读性,请检查您是否提供了任何回车/空格,这也是导致您出现该问题的原因之一有经验的。我试图为@scottndecker +1 但不能,因为我没有 15 声望。
回答by Keith Holloway
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.
还要注意,连接字符串中的大小写很重要。在大型合并导致某人在我的 Web.config 中将“AccountName”改为“Accountname”之前,我遇到过此错误。使用正确的外壳修复了错误。
回答by Rafa Heringer
Don't forget to include the "https://" or "https://" when using the proxyUri. Like:
使用 proxyUri 时不要忘记包含“https://”或“https://”。喜欢:
UseDevelopmentStorage=true;DevelopmentStorageProxyUri=https://127.0.0.1
UseDevelopmentStorage=true;DevelopmentStorageProxyUri=https://127.0.0.1
回答by Per
I got this because I had accidently added a newline character (\r\n) at the end of the string.
我得到这个是因为我不小心在字符串的末尾添加了一个换行符 (\r\n)。
回答by Dheeraj Jain
I also got the same issue, and i found it in the namespace. The CloudStorageAccount class is present in both the namespaces
我也遇到了同样的问题,我在命名空间中找到了它。CloudStorageAccount 类存在于两个命名空间中
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
So I just removed WindowsAzurenamespace and added WindowsAzure.Storagein my code.
所以我只是删除了WindowsAzure命名空间并添加WindowsAzure.Storage到我的代码中。
Previous Code:
以前的代码:
using Microsoft.WindowsAzure;
Fixed Code:
固定代码:
using Microsoft.WindowsAzure.Storage;
回答by upendra singh
I was facing same issue. You need to use Microsoft.WindowsAzure.Storagename space and make sure there is not an extra space in connection string.
我面临同样的问题。您需要使用Microsoft.WindowsAzure.Storage名称空间并确保连接字符串中没有多余的空间。

