CosmosDB output
afriapps opened this issue · comments
I am trying to use cosmosdb (mongo) as an output based on the inputs you used.
data = {
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"image":"path/image.jpg",
"device":subject.split(",")[1],
"detected":"false",
"detection_type":"null"
}
with open(os.environ['outputCosmosDB'], 'wb') as f:
json.dump(data,f)
I keep getting this error when I explore the data in cosmosdb:
Detected corrupted documents without _id identifier, verify that you are only storing documents through Mongo protocol and not SQL API or DocumentDB SDK.
How should this be done? Would really appreciate an example on this too, your code has been super helpfull
This actually does work IF the api selected is SQL. This does not work with MongoDB API in azure cosmosDB
Thanks for the post!
I tired the same code and got the same message:
{"code":500,"body":"Detected corrupted documents without _id identifier, verify that you are only storing documents through Mongo protocol and not SQL API or DocumentDB SDK."}
According to this, "the DocumentDB output binding is using the DocumentDB API to connect and save information in the database"
So unfortunately it looks you can not store documents into MongoDB via the cosmosdb output binding ...
Cosmos DB team doesn't advice to store into MongoDB by using DocumentDB SDK(SQL).
https://twitter.com/AzureCosmosDB/status/970663023294771201
So I close this. Please let me know if you want to re-open. Thanks.