问题:访问azure开发表存储我缺少什么?
注意:我可以访问我的天蓝色CLOUD存储(当然使用不同的代码),但是在尝试访问开发存储时我失败了。
我正在使用:
Microsoft Azure存储模拟器v4.0 < - 更改为v4.2已修复问题
var cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
var tableClient = cloudStorageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("MYTEMPTABLE");
var iscreated = table.CreateIfNotExists();
最后一个语句给出了这个异常
The remote server returned an error: (400) Bad Request.
The value for one of the HTTP headers is not in the correct format.
RequestId:f0b37575-30f4-45c1-bec3-2620c3c605e7
Time:2015-11-04T16:12:37.4719620Z
栈跟踪
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 816
at Microsoft.WindowsAzure.Storage.Table.TableOperation.Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\TableOperation.cs:line 41
at Microsoft.WindowsAzure.Storage.Table.CloudTable.Exists(Boolean primaryOnly, TableRequestOptions requestOptions, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\CloudTable.cs:line 1605
at Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExists(TableRequestOptions requestOptions, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\CloudTable.cs:line 1024
at USPS.Cloud.Integration.AspProviders.UspsReturnsStorageBase.CreateStorageAccountFromConnectionString() in ... <my local code call stack>
仅供参考:在搜索MSDN,StackOverflow等时,我找到了3种方法来获取CloudStorageAccount对象来访问存储模拟器。前2个给出了上面的错误。第3个给出403错误。
CloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudStorageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
var devAccountName = "devstoreaccount1";
var devAccountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
var devCredentials = new StorageCredentials(devAccountName, devAccountKey);
var cloudStorageAccount = new CloudStorageAccount(devCredentials, true);
更新
如答案中所述,我没有正确的模拟器版本。 开发存储连接1&amp; 2以上工作。在@Emily Gerner的回答链接之后 - MSFT引导我做了一个工作选项3.
var devConnectionString = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;";
CloudStorageAccount = CloudStorageAccount.Parse(devConnectionString);
答案 0 :(得分:4)
第三个不起作用,因为您没有设置模拟器端点,而是发送到服务帐户devstoreaccount1而不是本地模拟器。例如,尝试使用TableEndpoint = http://127.0.0.1:10002/devstoreaccount1。如有必要,Azure emulator docs会提供更多详细信息。
如果您看到README section on the Emulator,您将看到最新的存储库版本需要min emulator版本4.2。这也应该提供下载链接。您获得400 Bad Request,因为您正在使用的库版本使用旧仿真器无法知道的服务版本。
答案 1 :(得分:0)
查看AzureStorage NugetPackage&gt; 6.0.0适用于Azure SDK 2.8(存储模拟器4.8)
答案 2 :(得分:0)
我也得到400错误。在我的情况下,我无法启动Azure存储模拟器。原因是其他一些进程正在侦听该端口。所以我去改变了AzureStorageEmulator.exe中的端口号。您可以在@ C:\ Program Files(x86)\ Microsoft SDKs \ Azure \ Storage Emulator中找到此配置文件。或者,无论您安装模拟器。之后,模拟器启动了。但这400仍然没有消失。所以我在配置文件中使用了这个设置。 &#34; UseDevelopmentStorage = TRUE; DevelopmentStorageProxyUri = http://ipv4.fiddler&#34; [Azure October 2012 SDK broke UseDevelopmentStorage=true。看着提琴手,我意识到请求被定向到端口号10000.我发现无法改变它。所以我杀死了使用该端口的任何进程。将我的配置文件重置回原始状态。现在blob,队列和表正在使用原始端口号。 Azure存储模拟器已重新启动。现在奇迹般地400错误消失了。