AIdeaText commited on
Commit
b122c14
1 Parent(s): 9323bdb

Update modules/db_connection.py

Browse files
Files changed (1) hide show
  1. modules/db_connection.py +15 -10
modules/db_connection.py CHANGED
@@ -5,19 +5,24 @@ def call_azure_function(operation, data):
5
  function_url = os.getenv('AZURE_FUNCTION_URL')
6
  api_key = os.getenv('AZURE_FUNCTION_API_KEY')
7
 
 
 
 
 
8
  headers = {
9
  'Content-Type': 'application/json',
10
  'x-functions-key': api_key
11
  }
12
 
13
- payload = {
14
- 'operation': operation,
15
- 'data': data
16
- }
17
 
18
- response = requests.post(function_url, json=payload, headers=headers)
19
-
20
- if response.status_code == 200:
21
- return response.json()
22
- else:
23
- raise Exception(f"Error calling Azure Function: {response.text}")
 
 
5
  function_url = os.getenv('AZURE_FUNCTION_URL')
6
  api_key = os.getenv('AZURE_FUNCTION_API_KEY')
7
 
8
+ print(f"Calling Azure Function: {function_url}")
9
+ print(f"Operation: {operation}")
10
+ print(f"Data: {data}")
11
+
12
  headers = {
13
  'Content-Type': 'application/json',
14
  'x-functions-key': api_key
15
  }
16
 
17
+ try:
18
+ response = requests.post(function_url, json={'operation': operation, 'data': data}, headers=headers)
19
+ print(f"Response status code: {response.status_code}")
20
+ print(f"Response content: {response.text}")
21
 
22
+ if response.status_code == 200:
23
+ return response.json()
24
+ else:
25
+ raise Exception(f"Error calling Azure Function: {response.text}")
26
+ except requests.exceptions.RequestException as e:
27
+ print(f"Request exception: {str(e)}")
28
+ raise