You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you point me to where the Azure Provider code is or can the current version be updated. The MS preferred way is to epically in enterprise organizations is to use it behind an APIM with application regenerations. It's basically just proxying the auth beforehand and then obscuring the "keys" to the load balanced instances in the APIM so that way people don't have full access to the instances.
Ex for app registration you get a token and pass it as the bearer token to the APIM for auth instead of a subscription key.
import requests
import os
###############################
# Variables you will need
# Load sensitive information from environment variables, such as client id/secret
# Can source as you see fit, but you will need these
# #############################
client_id = "customId"
client_secret = "topSecret"
tenant_id = "123-123-4124-124"
token_url = f'https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token'
###############################
# example function
# #############################
def get_azure_openai_api_token(client_id: str, client_secret: str, token_url: str):
"""
Obtain an access token from Azure AD using app registration client credentials.
Args:
client_id (str): The client ID of the Azure app registration.
client_secret (str): The client secret of the Azure app registration.
token_url (str): The URL to obtain the OAuth2 token from Azure AD.
Returns:
str: The access token if the request is successful, None otherwise.
Raises:
requests.exceptions.RequestException: If there is an issue with the
HTTP request.
"""
token_data = {
'grant_type': 'client_credentials',
'client_id': client_id,
'client_secret': client_secret,
'scope': 'https://cognitiveservices.azure.com/.default'
}
try:
token_r = requests.post(token_url, data=token_data)
token_r.raise_for_status()
return token_r.json().get('access_token')
except requests.exceptions.RequestException as e:
print(f"Error obtaining access token: {e}")
return None
###############################
# Example usage
# #############################
token = get_azure_openai_api_token(client_id, client_secret, token_url)
print(token)
The text was updated successfully, but these errors were encountered:
Can you point me to where the Azure Provider code is or can the current version be updated. The MS preferred way is to epically in enterprise organizations is to use it behind an APIM with application regenerations. It's basically just proxying the auth beforehand and then obscuring the "keys" to the load balanced instances in the APIM so that way people don't have full access to the instances.
https://github.com/microsoft/AzureOpenAI-with-APIM
Ex for app registration you get a token and pass it as the bearer token to the APIM for auth instead of a subscription key.
The text was updated successfully, but these errors were encountered: