File size: 658 Bytes
84ec5fc 28aefca 74ac7c0 84ec5fc 28aefca 84ec5fc 28aefca 84ec5fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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') # Si está utilizando una clave de API
headers = {
'Content-Type': 'application/json',
'x-functions-key': api_key # Si está utilizando una clave de API
}
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}") |