表存储访问因不支持的媒体类型而失败 [英] Table Storage access fails with Unsupported Media Type
问题描述
尝试在Azure Stack中获取CloudTable设置的实例。 Microsoft.WindowsAzure.Storage抛出StorageException:不支持的媒体类型。 该表是空的,我只是尝试使用以下代码获取对该表的引用:
Trying to get an instance of a CloudTable setup in Azure Stack. Microsoft.WindowsAzure.Storage throws a StorageException: Unsupported Media Type. The table is empty, I'm simply trying to get a reference to the table with the following code:
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Threading.Tasks;
namespace MyProject.Utilities.AzureStorage
{
public static class TableHelper
{
public static async Task<CloudTable> GetCloudTable(string connectionString, string tableName)
{
if (string.IsNullOrEmpty(connectionString) || string.IsNullOrEmpty(tableName))
{
throw new ArgumentException();
}
var storageAccount = CloudStorageAccount.Parse(connectionString);
var client = storageAccount.CreateCloudTableClient();
var table = client.GetTableReference(tableName.ToLowerInvariant());
await table.CreateIfNotExistsAsync();
return table;
}
}
}
Unhandled Exception: System.AggregateException: One or more errors occurred. (Unsupported Media Type) ---> Microsoft.WindowsAzure.Storage.StorageException: Unsupported Media Type
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
at Microsoft.WindowsAzure.Storage.Table.CloudTable.<>c__DisplayClass41_0.<<CreateIfNotExistsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at MyProject.Utilities.AzureStorage.TableHelper.GetCloudTable(String connectionString, String tableName)
ASDK版本是1.1811.0.101
ASDK version is 1.1811.0.101
.NETStandard库是2.0.3
.NETStandard library is 2.0.3
Windows.Azure.Storage使用的是版本8.7.0
Windows.Azure.Storage is using version 8.7.0
推荐答案
这是奇怪的。
你是正确构建命令,如果表格为空,则无关紧要。
This is Strange. You are properly structuring the command, and it should not matter if the table is empty.
你能做出一个新表使用这些命令?如果表有数据怎么办?
Are you able to make a new Table using these commands? What about if a table has data?
这篇关于表存储访问因不支持的媒体类型而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!