简体   繁体   English

Azure表存储模拟器将SOH字符附加到分区键和行键

[英]Azure Table Storage Emulator appending SOH character to Partition and Row Keys

I've just begun using Azure Table Storage on my local machine (via Storage Emulator). 我刚刚开始在本地计算机上使用Azure Table Storage(通过Storage Emulator)。 I'm storing some resource keys in the table storage; 我在表存储中存储了一些资源键; however, when I query the table (even through SQL Server Management Studio) with the Partition Key, Row Key or both, getting no results back. 但是,当我使用分区键,行键或两者来查询表(甚至通过SQL Server Management Studio)时,也没有返回结果。

The code querying the table storage is as follows: 查询表存储的代码如下:

public async Task<TEntity> GetItemAsync(string partitionKey, string rowKey)
    {
        var table = client.GetTableReference(TableName);

        var retrieveOperation = TableOperation.Retrieve<TEntity>(partitionKey, rowKey);

        var retrievedResult = await table.ExecuteAsync(retrieveOperation);

        if (retrievedResult.Result != null)
        {
            return (TEntity)retrievedResult.Result;
        }
        else
        {
            Trace.TraceWarning("The entity could not be retrieved.");
            return null;
        }
    }

When the query is executed, the result contains Http 404. 执行查询时,结果包含Http 404。

Has anyone an idea what the problem might be? 有谁知道可能是什么问题? If it has to do with the SOH character which is being appended, why is Azure Table Storage appending that character at all? 如果与要附加的SOH字符有关,为什么Azure Table Storage根本不附加该字符?

SSMS screenshot from TableRow table TableRow表中的SSMS屏幕截图

Thank you for your support. 谢谢您的支持。

Has anyone an idea what the problem might be? 有谁知道可能是什么问题?

As far as I know, normally the Http 404 error will be happened if the table is not existed. 据我所知,如果表不存在,通常会发生Http 404错误。 I suggest you could firstly check your tablename is existed or not. 我建议您首先可以检查您的表名是否存在。

If it has to do with the SOH character which is being appended, why is Azure Table Storage appending that character at all? 如果与要附加的SOH字符有关,为什么Azure Table Storage根本不附加该字符?

According to Understanding the Table Service Data Model article, the following characters are not allowed in values for the PartitionKey and RowKey properties: Control characters from U+0000 to U+001F, including: 根据“理解表服务数据模型”一文,PartitionKey和RowKey属性的值中不允许使用以下字符:控制字符,从U + 0000到U + 001F,包括:

  • The horizontal tab (\\t) character 水平制表符(\\ t)
  • The linefeed (\\n) character 换行符(\\ n)
  • The carriage return (\\r) character 回车符(\\ r)
  • Control characters from U+007F to U+009F 从U + 007F到U + 009F的控制字符

\ is not allowed. 不允许使用\\ u0001。

I also write a test demo on my computer, we couldn't insert the control character in the partition key and row key. 我还在计算机上编写了一个测试演示,我们无法在分区键和行键中插入控制字符。

My storage emulator version is 4.6 and the azure storage package version is 8.0.1, I guess the reason why you inserted the control character is about your emulator version and package version. 我的存储模拟器版本是4.6,而Azure存储软件包版本是8.0.1,我猜您插入控制字符的原因是关于模拟器版本和软件包版本的。

I suggest you could install the newest version about the emulator and try again. 我建议您可以安装有关模拟器的最新版本,然后重试。

Download Link: https://azure.microsoft.com/en-us/downloads/ 下载链接: https : //azure.microsoft.com/en-us/downloads/

Besides, if the table property type is Edm.String, I suggest you could make sure your inserted value is a UFT-16-encoded value. 此外,如果表属性类型为Edm.String,建议您确保插入的值是UFT-16编码的值。

Edm.String: A UTF-16-encoded value. Edm.String:UTF-16编码的值。 String values may be up to 64 KB in size. 字符串值最大为64 KB。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM