1
1
import logging
2
+ import os
2
3
import azure .functions as func
3
4
import jwt
4
- import os
5
+
6
+ # Decree and declare our project as an Azure Function App subsidiary
7
+ app = func .FunctionApp ()
8
+
9
+ # Configure logging
10
+ logging .basicConfig (level = logging .DEBUG )
11
+ logger = logging .getLogger (__name__ )
5
12
6
13
7
14
def main (req : func .HttpRequest , outbound : func .Out [str ]) -> func .HttpResponse :
8
15
try :
9
- logging .info ("Received HTTP request to upload CSV" )
16
+ logger .info ("Received HTTP request to upload CSV" )
10
17
11
18
# Validate JWT token
12
19
auth_header = req .headers .get ("Authorization" )
@@ -18,15 +25,15 @@ def main(req: func.HttpRequest, outbound: func.Out[str]) -> func.HttpResponse:
18
25
if not validate_jwt (token , audience = os .environ .get ("FUNCTION_APP_CLIENT_ID" )):
19
26
return func .HttpResponse ("Unauthorized" , status_code = 401 )
20
27
21
- logging .info ("Received HTTP request to upload CSV" )
28
+ logger .info ("Received HTTP request to upload CSV" )
22
29
23
30
# Parse raw bytes derived from request body to string
24
31
string_body = req .get_body ().decode ("utf-8" )
25
- logging .info ("Parsed request body to string" )
32
+ logger .info ("Parsed request body to string" )
26
33
27
34
# Upload parsed string body, which conforms to CSV format
28
35
outbound .set (string_body )
29
- logging .info ("Successfully uploaded CSV content" )
36
+ logger .info ("Successfully uploaded CSV content" )
30
37
return func .HttpResponse ("Successfully uploaded CSV content" , status_code = 200 )
31
38
32
39
except Exception as e :
0 commit comments