ref:
https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
https://sqlworldwide.com/how-to-use-managed-identity-with-azure-function-app/
steps :
- Assign a managed identity to the Azure Function.
- Grant the managed identity access to the Logic App.
- Obtain an access token for the managed identity within the Azure Function.
from azure.identity import DefaultAzureCredential
from azure.core.credentials import AccessToken
def get_access_token() -> str:
credential = DefaultAzureCredential()
token: AccessToken = credential.get_token("https://management.azure.com/.default")
return token.token
- Call the Logic App using the access token.
import requests
def call_logic_app(logic_app_url: str, access_token: str):
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
data = {
# Your request data here
}
response = requests.post(logic_app_url, headers=headers, json=data)
# Handle the response as needed