Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用SAS从Java批量插入Azure表失败_Java_Azure - Fatal编程技术网

使用SAS从Java批量插入Azure表失败

使用SAS从Java批量插入Azure表失败,java,azure,Java,Azure,如果使用SAS(“共享访问签名”),尝试对azure表使用批插入将失败。 当使用帐户密钥(我想它不太安全)时,它可以工作 示例代码: StorageCredentialsSharedAccessSignature credentials = new StorageCredentialsSharedAccessSignature("sig=....."); CloudTableClient cloudTableClient = new CloudTableClient(new URI("http

如果使用SAS(“共享访问签名”),尝试对azure表使用批插入将失败。 当使用帐户密钥(我想它不太安全)时,它可以工作

示例代码:

StorageCredentialsSharedAccessSignature credentials = new StorageCredentialsSharedAccessSignature("sig=.....");

CloudTableClient cloudTableClient = new CloudTableClient(new URI("https://<storage account>.table.core.windows.net/<tablename>"), credentials);

CloudTable cloudTable = cloudTableClient.getTableReference("<tablename>");

//these 2 will be in a batch
TableServiceEntity d1 = new TableServiceEntity("3333333333333", "22222222222222" + System.currentTimeMillis());
TableServiceEntity d2 = new TableServiceEntity("3333333333333", "eeeeeeeeeee" + System.currentTimeMillis());

//single
TableServiceEntity d3 = new TableServiceEntity("ddddddddddddddddddd", "dddddddddd" + System.currentTimeMillis());

//prepare batch
TableBatchOperation batch = new TableBatchOperation();
batch.insert(d1);
batch.insert(d2);
try {
        // this will work (not batch, just to show that regular insert works)
        cloudTable.execute(TableOperation.insert(d3));

        // this will fail
        cloudTable.execute(batch);

} catch (StorageException e) {
            //here we get "Unsupported Media Type" (415 error)
        e.printStackTrace();
        return;
}
System.out.println("OK");
SAS

sig=&se=2020-01-01T00%3100%3A00Z&sv=2015-04-05&tn=&sp=raud
根据上的问题,请尝试更改以下代码行:

CloudTableClient cloudTableClient = new CloudTableClient(new URI("https://<storage account>.table.core.windows.net/<tablename>"), credentials);
CloudTableClient CloudTableClient=新的CloudTableClient(新URI(“https://.table.core.windows.net/(a)全权证书;
致:

CloudTableClient CloudTableClient=新的CloudTableClient(新URI(“https://.table.core.windows.net(a)全权证书;
基本上不在URI中包含表的名称。它只能是
https://account-name.table.core.windows.net


另外,我不知道您也在上打开了一个与此相关的问题:)。

请共享您的SAS令牌以及详细的错误消息。添加了错误消息
sig=<sig>&se=2020-01-01T00%3A00%3A00Z&sv=2015-04-05&tn=<table name>&sp=raud
CloudTableClient cloudTableClient = new CloudTableClient(new URI("https://<storage account>.table.core.windows.net/<tablename>"), credentials);
CloudTableClient cloudTableClient = new CloudTableClient(new URI("https://<storage account>.table.core.windows.net"), credentials);