How to update values in cosmosdb as output using azure stream analutics?

别说谁变了你拦得住时间么 提交于 2020-01-16 08:38:28

问题


at first event I get data like below

{
'product_name':'hamam',
'quantity':'100'
}

at second I get data like below

{
'product_name':'hamam',
'quantity':'70'
}

here I wanna update the values in cosmos db, how can I do it?


回答1:


ASA supports upserts feature for cosmos db if your data contains a unique document id.(Your sample data seems does not have it) Please see this paragraph about upserts in ASA for cosmos db.

Some excerpt as below:

Stream Analytics integration with Azure Cosmos DB allows you to insert or update records in your container based on a given Document ID column.

If the incoming JSON document has an existing ID field, that field is automatically used as the Document ID column in Cosmos DB and any subsequent writes are handled as such, leading to one of these situations:

  • unique IDs lead to insert
  • duplicate IDs and 'Document ID' set to 'ID' leads to upsert
  • duplicate IDs and 'Document ID' not set leads to error, after the first document


来源:https://stackoverflow.com/questions/57699026/how-to-update-values-in-cosmosdb-as-output-using-azure-stream-analutics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!