-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_app.py
More file actions
68 lines (56 loc) · 2.25 KB
/
function_app.py
File metadata and controls
68 lines (56 loc) · 2.25 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import azure.functions as func
import logging
from project.config_variables import documentation_storage_name
from project.storage_account_test import *
app = func.FunctionApp()
@app.function_name(name="HttpTrigger1")
@app.route(route="")
def test_function(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
body=req.get_body()
my_json = body.decode('utf8').replace("'", '"')
data = json.loads(my_json)
subscription_id=data['subscription_id']
subscription_name=data['subscription_name']
storage_account=data['storage_account']
partition_key=data['partition_key']
row_key=data['row_key']
last_fetch_time=data['last_fetch_time']
response_for_null_storages={"storage_account":"null"}
try:
if storage_account['tag'] == "True" :
paginated_response = {
"value": [response_for_null_storages],
"nextLink": None
}
return func.HttpResponse(json.dumps(paginated_response), mimetype="application/json")
if(storage_account['name']==documentation_storage_name):
paginated_response = {
"value": [response_for_null_storages],
"nextLink": None
}
return func.HttpResponse(json.dumps(paginated_response), mimetype="application/json")
object_for_alerts_to_excel=storage_account_test(
storage_account['name'],
partition_key,
row_key,
subscription_id,
subscription_name,
storage_account['id'],
last_fetch_time
)
except Exception as e:
logging.info(e)
response_for_null_storages={"storage_account":storage_account['name'],"alert_body":"null"}
paginated_response = {
"value": [response_for_null_storages],
"nextLink": None
}
return func.HttpResponse(json.dumps(paginated_response), mimetype="application/json")
logging.info('object_for_alerts_to_excel-------------')
logging.info(str(object_for_alerts_to_excel))
paginated_response = {
"value": [object_for_alerts_to_excel],
"nextLink": None
}
return func.HttpResponse(json.dumps(paginated_response), mimetype="application/json")