简体   繁体   English

azure blob 存储“未找到帐户信息的有效组合”

[英]azure blob storage "No valid combination of account information found"

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(字符串错误)在 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 操作文档:

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 在 web 部署发布过程中被弄乱了,但我不确定如何解决这个问题?

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...ie UseDevelopmentStorage=true;DevelopmentStorageProxyUri=https://127.0.0.1 instead 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 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.将“https”放入实际上为我们搞砸了一切。 Worker role would throw an exception ("Handshack failed due to an unexpected packet format.") and then cycle between unknown and destroyed. Worker 角色会抛出异常(“Handshack 由于意外的数据包格式而失败。”)然后在未知和销毁之间循环。 Removed the "s" in "https" and made sure there were no white spaces and voila.删除了“https”中的“s”并确保没有空格,瞧。

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.这应该可以帮助任何有这个解析问题的人。

Store your storage connection string in AppSettings, not in ConnectionStrings section.将您的存储连接字符串存储在 AppSettings 中,而不是在 ConnectionStrings 部分中。 And, pasting here the actual connection string will help us help you (you may put * for the account key).并且,在此处粘贴实际的连接字符串将有助于我们为您提供帮助(您可以将*作为帐户密钥)。

I think, that could not be the cause of the problem as was expressed by Sandino Di Mattia.我认为,这不可能是 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.将 SDK 升级到 2.0 时,我也遇到了同样的情况,结果发现 API 的连接字符串解析器不再容忍连接字符串中的空格,并且在任何地方都没有提到。 If this kind of change was intentional, I would call it a nasty move...如果这种改变是故意的,我会称其为令人讨厌的举动......

I got this error because missed the prefix BlobEndpoint= before Blob SAS URL :我收到此错误是因为在Blob SAS URL之前错过了前缀BlobEndpoint=

wrong appsettings.json错误的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正确的appsettings.json

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

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.在大型合并导致某人在我的 Web.config 中将“AccountName”改为“Accountname”之前,我遇到过此错误。 Using the correct casing fixed the error.使用正确的外壳修复了错误。

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.如果您确定从Azure服务复制的连接字符串与您粘贴的相同,那么为了可读性,请检查您是否提供了任何回车/空格,这也是导致您出现该问题的原因之一有经验的。 I tried to give +1 for @scottndecker but couldn't since I don't have 15 reputation.我试图为@scottndecker +1 但不能,因为我没有 15 声望。

Don't forget to include the "https://" or "https://" when using the proxyUri.使用 proxyUri 时不要忘记包含“https://”或“https://”。 Like:像:

UseDevelopmentStorage=true;DevelopmentStorageProxyUri=https://127.0.0.1

我得到这个是因为我不小心在字符串的末尾添加了一个换行符 (\\r\\n)。

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.您需要使用Microsoft.WindowsAzure.Storage命名空间并确保连接字符串中没有多余的空间。

I got this error because I used the wrong nuget package, (I am using dot net 4.6.1)我收到此错误是因为我使用了错误的 nuget 包,(我使用的是 dot net 4.6.1)

The wrong package was: WindowsAzureStorage.Helper错误的包是:WindowsAzureStorage.Helper

The correct package is: WindowsAzure.Storage正确的包是:WindowsAzure.Storage

and make sure you use the namespace: using Microsoft.WindowsAzure.Storage;并确保使用命名空间: using Microsoft.WindowsAzure.Storage;

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.当我使用 @Microsoft.KeyVault(SecretUri=https...) 将存储连接字符串从应用程序设置文字迁移到密钥库引用时遇到此错误我创建了一个新的函数应用程序并且忘记打开系统分配身份并授予应用程序访问密钥库的权限。 Hence, the symptom was an undefined app settings value - a failed storage connection attempt.因此,症状是未定义的应用程序设置值 - 存储连接尝试失败。

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同样适用于:eventHubConnectionString、storageAccountName 和 storageAccountKey

To solve this issue on azure, don't use the default string but use a minimalistic version such as :要在 azure 上解决此问题,请不要使用默认字符串,而是使用简约版本,例如:

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

Without whitespace or line breaks!!没有空格或换行符!!

The error message doesn't say anything about the account key being wrong, but that was the problem in my case.错误消息没有说明帐户密钥错误,但这就是我的问题。

I was developing a new application and copied/pasted the key from our team's config file.我正在开发一个新应用程序并从我们团队的配置文件中复制/粘贴了密钥。 I started getting this error in the new application, but the only one worked just fine.我开始在新应用程序中收到此错误,但只有一个工作正常。 It turns out that somewhere in our config file, a + was replaced by \+ .事实证明,在我们的配置文件中的某个地方,一个+被替换为\+ After coping/pasting the correct key, the new app worked just fine.处理/粘贴正确的密钥后,新应用程序运行良好。

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 WindowsAzure namespace and added WindowsAzure.Storage in my code.所以我只是删除了WindowsAzure命名空间并在我的代码中添加了WindowsAzure.Storage

Previous Code:以前的代码:

using Microsoft.WindowsAzure;

Fixed Code:固定代码:

using Microsoft.WindowsAzure.Storage;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 队列触发错误使用.Net.Sdk.Functions 3.0.13:错误索引方法'Function1',存储:未找到帐户信息的有效组合 - Azure queue trigger error using .Net.Sdk.Functions 3.0.13: Error indexing method 'Function1',Storage: No valid combination of account info found Azure SAS blob 存储帐户的令牌不起作用 - Azure SAS token for blob storage account not working 无法从 Azure Blob 读取:“org.apache.hadoop.fs.azure.AzureException:找不到 Azure 存储帐户的凭据 - Cannot read from Azure Blob: "org.apache.hadoop.fs.azure.AzureException: No credentials found for Azure storage account Azure function C#:写入 Azure 上的块 blob(csv 文件)存储帐户创建了两个版本的 blob - Azure function C#: Writing to Block blob (csv file) on Azure Storage Account creates two versions of the blob 来自 PUT 的 Azure Blob 存储文档中的“404 Resource Not Found” - "404 Resource Not Found" From Azure Blob Storage Document from PUT 为 Microsoft Azure Blob 存储自动化 Snowpipe - 错误:找不到通道的队列 - Automating Snowpipe for Microsoft Azure Blob Storage - error: Queue not found for channel 如何在 azure 存储帐户内的不同访问层中查找 blob 的大小? - How to find size of blob in different access tier inside an azure storage account? Azure Data Lake Gen2 存储帐户 blob 与 adf 选择 - Azure Data Lake Gen2 Storage Account blob vs adf choice 测试 Azure Blob 存储 SDK - Testing Azure Blob Storage SDK Azure Blob 存储文件访问 - Azure Blob Storage file access
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM