简体   繁体   中英

How to update values in cosmos db using azure stream analytics query language?

I'm looking to update data using azures stream analytics query lanuage, for example, at the first event, my data will be like below,

{
 'Name':'product1',
'sales':100
}

at the second event

{
  'name':'product1'
   'sales':200
}

and I wanna sum sales for both of the event, for example,

{
  'name':'product1',
  'sales':200
}

I take this case as an extension of this case: How to update values in cosmosdb as output using azure stream analutics? to the words i mentioned before, ASA supports upserts feature for cosmos db if your data contains a unique document id. For you, if your Name property is unique key, it could be applied.

However,you wanna sum function now, Azure Function output in ASA could be applied.You could pass the unique Name and the sales as params into Azure Function,then query the data with unique Name and do the sum calculate.Finally,update the data by the unique Name .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM