Update modules/db_connection.py
Browse files- modules/db_connection.py +19 -16
modules/db_connection.py
CHANGED
@@ -1,20 +1,23 @@
|
|
1 |
-
|
2 |
import os
|
3 |
-
from azure.identity import ClientSecretCredential
|
4 |
-
import pymssql
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
9 |
-
client_id = os.getenv('AZURE_CLIENT_ID')
|
10 |
-
client_secret = os.getenv('AZURE_CLIENT_SECRET')
|
11 |
-
tenant_id = os.getenv('AZURE_TENANT_ID')
|
12 |
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
import os
|
|
|
|
|
3 |
|
4 |
+
def call_azure_function(operation, data):
|
5 |
+
function_url = os.getenv('AZURE_FUNCTION_URL')
|
6 |
+
api_key = os.getenv('AZURE_FUNCTION_API_KEY') # Si está utilizando una clave de API
|
|
|
|
|
|
|
7 |
|
8 |
+
headers = {
|
9 |
+
'Content-Type': 'application/json',
|
10 |
+
'x-functions-key': api_key # Si está utilizando una clave de API
|
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}")
|