hmhmh89019 2021-08-11 03:37 采纳率: 0%
浏览 13
已结题

Microsoft Azure table java 查询出错 Microsoft Azure table java 查询出错

最近正在学习使用Java操作Azure storage table 我正按照官方文档 尝试用实体接收从storage table查询出的数据
有报这个错。
贴上我的实体截图 和storage table 字段截图以及关键代码

报错:

Caused by: com.microsoft.azure.storage.table.TableServiceException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
    at com.microsoft.azure.storage.table.TableServiceException.generateTableServiceException(TableServiceException.java:52)
    at com.microsoft.azure.storage.table.CloudTableClient$2.preProcessResponse(CloudTableClient.java:417)
    at com.microsoft.azure.storage.table.CloudTableClient$2.preProcessResponse(CloudTableClient.java:392)
    at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:148)
    at com.microsoft.azure.storage.core.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:109)

关键代码:

 public static void queryData() {
        try {
            // Define constants for filters.
            final String PARTITION_KEY = "PartitionKey";
            final String ROW_KEY = "RowKey";
            final String TIMESTAMP = "Timestamp";

            // Retrieve storage account from connection-string.
            CloudStorageAccount storageAccount =
                    CloudStorageAccount.parse(storageConnectionString);

            // Create the table client.
            CloudTableClient tableClient = storageAccount.createCloudTableClient();

            // Create a cloud table object for the table.
            CloudTable cloudTable = tableClient.getTableReference("TrackPage");

            // Create a filter condition where the partition key is "Smith".
            String partitionFilter = TableQuery.generateFilterCondition(
                    PARTITION_KEY,
                    QueryComparisons.EQUAL,
                    "o6FlbuA--3zEsy4pE_x4TCEzLoh8");

       /*     // Create a filter condition where the row key is less than the letter "E".
            String rowFilter = TableQuery.generateFilterCondition(
                    ROW_KEY,
                    QueryComparisons.LESS_THAN,
                    "E");

            // Combine the two conditions into a filter expression.
            String combinedFilter = TableQuery.combineFilters(partitionFilter,
                    Operators.AND, rowFilter);*/


            // Specify a range query, using "Smith" as the partition key,
            // with the row key being up to the letter "E".
            TableQuery<CustomerEntity> rangeQuery =
                    TableQuery.from(CustomerEntity.class)
                            .where(partitionFilter);

            // Loop through the results, displaying information about the entity
            Iterable<CustomerEntity> execute = cloudTable.execute(rangeQuery);

实体:


@Data
public class CustomerEntity implements TableEntity {

    public String CreateTime;
    public String Env;
    public String GuId;
    public String Type;
    public String UnionId;
    public String Url;
    ...

azure storage table 目标表

img

会不会是我的账户有问题?account和account_key

展开全部

  • 写回答

1条回答 默认 最新

    编辑
    预览

    报告相同问题?

    问题事件

    • 系统已结题 8月18日
    • 创建了问题 8月11日
    手机看
    程序员都在用的中文IT技术交流社区

    程序员都在用的中文IT技术交流社区

    专业的中文 IT 技术社区,与千万技术人共成长

    专业的中文 IT 技术社区,与千万技术人共成长

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    客服 返回
    顶部