最近正在学习使用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 目标表
会不会是我的账户有问题?account和account_key