如何使用azure流分析更新cosmosdb中的值作为输出? [英] How to update values in cosmosdb as output using azure stream analutics?

查看:60
本文介绍了如何使用azure流分析更新cosmosdb中的值作为输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次出现类似以下的数据

at first event I get data like below

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

第二天我得到如下数据

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

在这里我想更新cosmos db中的值,我该怎么做?

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

推荐答案

如果您的数据包含唯一的文档ID,ASA支持cosmos db的 upserts 功能.(您的示例数据似乎没有此功能)请参阅此段,关于ASA的宇宙数据库中的upserts.

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.

一些摘录如下:

Stream Analytics与Azure Cosmos DB的集成允许您基于给定的Document ID列在容器中插入或更新记录.

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

如果传入的JSON文档具有一个现有的ID字段,则该字段将自动用作Cosmos DB中的Document ID列,并且所有后续写操作都将被处理,从而导致以下情况之一:

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:

  • 唯一ID导致插入
  • 重复的ID和文档ID"设置为"ID"会导致upsert
  • 重复的ID和未设置的文档ID"导致错误之后,第一个文件

这篇关于如何使用azure流分析更新cosmosdb中的值作为输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆