diff --git a/infra/app/api.bicep b/infra/app/api.bicep index a81f243b..103d6194 100644 --- a/infra/app/api.bicep +++ b/infra/app/api.bicep @@ -1,7 +1,8 @@ param name string param location string = resourceGroup().location param tags object = {} - +param subscriptionId string +param azureAiProjectName string param identityName string param identityId string param containerAppsEnvironmentName string @@ -43,6 +44,22 @@ module app '../core/host/container-app-upsert.bicep' = { name: 'AZURE_CLIENT_ID' value: identityId } + { + name: 'AZURE_LOCATION' + value: location + } + { + name: 'AZURE_SUBSCRIPTION_ID' + value: subscriptionId + } + { + name: 'AZURE_RESOURCE_GROUP' + value: resourceGroup().name + } + { + name: 'AZURE_AI_PROJECT_NAME' + value: azureAiProjectName + } { name: 'AZURE_SEARCH_ENDPOINT' value: aiSearchEndpoint diff --git a/infra/main.bicep b/infra/main.bicep index 895febaa..740de8b3 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -202,6 +202,8 @@ module apiContainerApp 'app/api.bicep' = { appinsights_Connectionstring: ai.outputs.applicationInsightsConnectionString bingApiEndpoint: bing.outputs.endpoint bingApiKey: bing.outputs.bingApiKey + subscriptionId: subscription().subscriptionId + azureAiProjectName: ai.outputs.projectName } } diff --git a/requirements.txt b/requirements.txt index 8ef1d47d..e9950118 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,32 +1,32 @@ -# fastapi -# fastapi[standard] -# openai -# requests -# prompty[azure]==0.1.24 -# promptflow -# azure-ai-evaluation -# pandas -# opentelemetry-instrumentation-fastapi -# jsonlines -# python-dotenv==1.0.1 -# azure-search-documents==11.4.0 -# gunicorn==21.2.0 -# jupyter -# opentelemetry-sdk -# opentelemetry-instrumentation -# azure-identity==1.17.1 -# https://remoteevalbugbash.blob.core.windows.net/remoteevalbugbash/azure_ai_project-1.0.0b1-py3-none-any.whl -# gunicorn==21.2.0 -# azure-keyvault-secrets -# aiohttp==3.9.5 -# azure-cognitiveservices-speech==1.37.0 -# nbconvert -# azure-ai-evaluation[remote] -# validators -# azureml-mlflow -# azure-monitor-opentelemetry -# opentelemetry-instrumentation-openai-v2 -azure-ai-inference[opentelemetry] +fastapi +fastapi[standard] +openai +requests +prompty[azure]==0.1.24 +promptflow +azure-ai-evaluation +pandas +opentelemetry-instrumentation-fastapi +jsonlines +python-dotenv==1.0.1 +azure-search-documents==11.4.0 +gunicorn==21.2.0 +jupyter +opentelemetry-sdk +opentelemetry-instrumentation +azure-identity==1.17.1 +https://remoteevalbugbash.blob.core.windows.net/remoteevalbugbash/azure_ai_project-1.0.0b1-py3-none-any.whl +gunicorn==21.2.0 +azure-keyvault-secrets +aiohttp==3.9.5 +azure-cognitiveservices-speech==1.37.0 +nbconvert +azure-ai-evaluation[remote] +validators +azureml-mlflow +azure-monitor-opentelemetry +opentelemetry-instrumentation-openai-v2 +# azure-ai-inference[opentelemetry] # azure-ai-inference[opentelemetry] ./packages/whl packages # azure-ai-projects is not available in PyPI install it from the ./packages/whl packages ./packages/azure_ai_inference-1.0.0b6-py3-none-any.whl diff --git a/src/api/telemetry.py b/src/api/telemetry.py index d4b42b6d..b5f6d10c 100644 --- a/src/api/telemetry.py +++ b/src/api/telemetry.py @@ -30,9 +30,13 @@ def setup_telemetry(app: FastAPI): local_tracing_enabled=os.getenv("LOCAL_TRACING_ENABLED") otel_exporter_endpoint = os.getenv("OTEL_EXPORTER_OTLP_ENDPOINT") - + location = os.environ["AZURE_LOCATION"]+".api.azureml.ms;" + subscription = os.environ["AZURE_SUBSCRIPTION_ID"]+";" + resource_group = os.environ["AZURE_RESOURCE_GROUP"]+";" + project_name = os.environ["AZURE_AI_PROJECT_NAME"]+";" + # Configure OpenTelemetry using Azure AI Project - ai_project_conn_str = os.getenv("AZURE_LOCATION")+".api.azureml.ms;"+os.getenv("AZURE_SUBSCRIPTION_ID")+";"+os.getenv("AZURE_RESOURCE_GROUP")+";"+os.getenv("AZURE_AI_PROJECT_NAME") + ai_project_conn_str = location + subscription +resource_group + project_name # Configure OpenTelemetry using Azure AI Project with AIProjectClient.from_connection_string(