test2 / modules /db_connection.py
AIdeaText's picture
Update modules/db_connection.py
0d3433c verified
raw
history blame
No virus
578 Bytes
import requests
import os
def call_azure_function(operation, data):
function_url = os.getenv('AZURE_FUNCTION_URL')
api_key = os.getenv('AZURE_FUNCTION_API_KEY')
headers = {
'Content-Type': 'application/json',
'x-functions-key': api_key
}
payload = {
'operation': operation,
'data': data
}
response = requests.post(function_url, json=payload, headers=headers)
if response.status_code == 200:
return response.json()
else:
raise Exception(f"Error calling Azure Function: {response.text}")