Tag: 蔚cosmosdb

Java – DocumentDB未经授权的访问

我正在尝试编写一个function来从Azure存储DocumentDB中的对象。 我有一段代码: public void saveEvent(Event event) throws DocumentClientException { Document document = new Document(JsonCreator.createJson(event)); //check if document already exists FeedOptions feedOptions = new FeedOptions(); feedOptions.setEnableCrossPartitionQuery(true); FeedResponse eventDocument = documentClient.queryDocuments(COLLECTION_LINK, String.format(SELECT_DOCUMENT, event.getId()), feedOptions); // if there is a document with the ID then replace if (eventDocument.getQueryIterator().hasNext()) { //documentClient.replaceDocument(COLLECTION_LINK, document, null); documentClient.replaceDocument(COLLECTION_LINK, document, null); } else { […]

如何在Document DB java SDK中指定删除文档的NONE分区键?

我只有一个集合,当我尝试使用下面的代码删除文档时 PartitionKey partitionKey = new PartitionKey(“undefined”); RequestOptions requestOptions=new RequestOptions(); requestOptions.setPartitionKey(partitionKey); for(Document currentDocument: existingIMEIDevice){ try { ConfigVariables.documentClient.deleteDocument(currentDocument.getSelfLink(), requestOptions); } catch (DocumentClientException e) { // TODO Auto-generated catch block e.printStackTrace(); } 它抛出exception。 com.microsoft.azure.documentdb.DocumentClientException:消息:{“错误”:[“未找到资源”]} ActivityId:4353e7c0-0b24-4b2a-8ec6-fc2db4059aa0,请求URI:/ apps / 708ed403-166f-44e4-847f -ccaa0cd22d9c / services / d1e2ed4d-7e69-4a3d-9575-3e24b96621b4 / partitions / e3fc6138-06a5-4876-a629-a4be69917ded / replicas / 131533416718986721p,StatusCode:NotFound at com.microsoft.azure.documentdb.internal.ErrorUtils.maybeThrowException(ErrorUtils .java:69)com.microsoft.azure.documentdb.internal.GatewayProxy.performDeleteRequest(GatewayProxy.java:187)at com.microsoft.azure.documentdb.internal.GatewayProxy.doDelete(GatewayProxy.java:99)at com。 micros.aure.documentdb.internal.GatewayProxy.processMessage(GatewayProxy.java:332)at com.microsoft.azure.documentdb.DocumentClient […]