Azure OpenAI Integration

Updated on Aug 14, 2026

Use this integration when your app is implemented in Python, TypeScript, or .NET.

Setup

  1. Install SDK
bash
pip install progress-observability
  1. Instrument your app
python
Observability.instrument(
    app_name=os.getenv("OBSERVABILITY_APP_NAME"),
    api_key=os.getenv("OBSERVABILITY_API_KEY")
)
  1. Complete example
python
import os

from dotenv import load_dotenv
from openai import AzureOpenAI

from progress.observability import Observability

load_dotenv()

# LLM INSTRUMENTATION
Observability.instrument(
    app_name=os.getenv("OBSERVABILITY_APP_NAME"),
    api_key=os.getenv("OBSERVABILITY_API_KEY"),
)


def main() -> None:
    client = AzureOpenAI(
        azure_endpoint=os.getenv("AZURE_API_ENDPOINT", ""),
        api_key=os.getenv("AZURE_API_KEY", ""),
        api_version=os.getenv("AZURE_API_VERSION", "2024-10-21"),
    )
    deployment = (
        os.getenv("AZURE_OPENAI_DEPLOYMENT")
        or os.getenv("AZURE_OPENAI_API_DEPLOYMENT_NAME")
        or "gpt-4o-mini"
    )

    response = client.chat.completions.create(
        model=deployment,
        max_tokens=256,
        messages=[
            {"role": "system", "content": "You are a helpful AI assistant."},
            {"role": "user", "content": "What is the capital of France?"},
        ],
    )



try:
    main()
finally:
    Observability.shutdown()

To get a richer trace tree when building agents on top of this provider, use the @agent, @tool, @workflow, or @task decorators. See the Python SDK for details.

  1. Install SDK
bash
npm install @progress/observability
  1. Instrument your app
TS
import '@progress/observability/register/hooks';
import { Observability } from '@progress/observability';
await Observability.instrument({
 appName: process.env.OBSERVABILITY_APP_NAME,
 apiKey: process.env.OBSERVABILITY_API_KEY
});
  1. Complete example
TS
import '@progress/observability/register/hooks';
import 'dotenv/config';

import { AzureOpenAI } from 'openai';
import { Observability } from '@progress/observability';

const azureModel = 'gpt-4o-mini';
const azureApiVersion = process.env.AZURE_API_VERSION || '2024-06-01';
const azureDeployment =
  process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME || azureModel;

async function main() {
  await Observability.instrument({
    appName: process.env.OBSERVABILITY_APP_NAME ?? 'weather-agent-azure-sdk',
    apiKey: process.env.OBSERVABILITY_API_KEY,
  });

  try {
    const client = new AzureOpenAI({
      apiKey: process.env.AZURE_API_KEY,
      endpoint: process.env.AZURE_API_ENDPOINT,
      apiVersion: azureApiVersion,
      deployment: azureDeployment,
    });

    const result = await client.chat.completions.create({
      model: azureModel,
      max_completion_tokens: 256,
      messages: [
        { role: 'system', content: 'You are a helpful AI assistant.' },
        { role: 'user', content: 'What is the capital of France?' },
      ],
    });

  } finally {
    await Observability.shutdown();
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

To get a richer trace tree when building agents on top of this provider, use the @agent, @tool, @workflow, or @task decorators. See the TypeScript SDK for details.

  1. Install SDK
bash
dotnet add package Progress.Observability.Instrumentation
  1. Instrument your app
cs
try
{
 chatClient = chatClient.AddObservability((options) =>
 {
 options.AppName = Environment.GetEnvironmentVariable("OBSERVABILITY_APP_NAME")!;
 options.ApiKey = Environment.GetEnvironmentVariable("OBSERVABILITY_API_KEY")!;
 });
 
 // Your code here.
}
finally
{
 // Call the Shutdown() method before exiting your agent to flush any remaining data.
 ObservabilityTracer.Shutdown();
}
  1. Complete example
cs
using Microsoft.Extensions.AI;
using Azure.AI.OpenAI;
using System.ClientModel;
using Progress.Observability.Extensions.AI;
using DotNetEnv;

namespace Examples.AzureOpenAI;

public class Program
{
 public static async Task Main(string[] args)
 {
     try
     {
         Env.Load("../../.env");

         IChatClient chatClient = new AzureOpenAIClient(
             new Uri(Environment.GetEnvironmentVariable("AZURE_API_ENDPOINT")!),
             new ApiKeyCredential(Environment.GetEnvironmentVariable("AZURE_API_KEY")!))
             .GetChatClient("gpt-4o-mini")
             .AsIChatClient()
             .AddObservability((options) =>
             {
                 options.AppName = "AzureOpenAI Example";
                 options.ApiKey = Environment.GetEnvironmentVariable("OBSERVABILITY_API_KEY")!;
             });

         var response = await chatClient.GetResponseAsync(
             "What is the capital of France?");

         Console.WriteLine(response.Text ?? "No assistant text returned.");
     }
     finally
     {
         ObservabilityTracer.Shutdown();
     }
 }
}

To get a richer trace tree when building agents on top of this provider, use custom spans. See the .NET SDK for details.

In this article
Setup
Not finding the help you need?
Contact Support