forked from yokawasa/azure-functions-python-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
32 lines (25 loc) · 795 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
"""
Azure Functions Queue Trigger
- Get a document ID from Queue as a queue message, select a document object from Cosmos DB by using the document ID, and finally dump the object
"""
import os
import sys
import json
def functions_process(doc):
print(doc)
def functions_main():
## function's starting point
print ("Starting the operation...")
cosmosdb_data = open(os.environ['inputDocument']).read()
docs=json.loads(cosmosdb_data)
if len(docs) < 1:
errorlog("No documents obtained via Azure Function Queue & CosmosDB binding")
sys.exit(0)
doc = docs[0]
## process doc
print ("Processing document")
functions_process(doc)
## Output results if needed
print ("The end of operation")
functions_main()