← Blog

Azure AI Services for Developers: What's Actually Useful in 2026

·5 min read·AzureAICloudAzure OpenAILLMPythonTypeScript

Azure AI has matured considerably. If you're building on Azure infrastructure or your org already has an Azure Enterprise Agreement, there are real advantages to using Azure AI services over third-party providers — compliance, data residency, private networking, and consumption billing through existing credits.

This post covers the services that are worth knowing and how to use them with real code.


Overview of Azure AI Services

ServiceWhat It Does
Azure OpenAI ServiceGPT-4o, GPT-4, o-series via your Azure subscription
Azure AI FoundryPlatform for deploying, fine-tuning, and managing models
Azure AI SearchHybrid vector + keyword search with semantic ranking
Azure Document IntelligenceOCR, document parsing, form extraction
Azure AI SpeechSTT, TTS, translation
Azure Content SafetyModeration and safety filters for AI outputs
Azure AI VisionImage analysis, OCR, face detection

Azure OpenAI Service

Azure OpenAI gives you access to OpenAI models (GPT-4o, o4-mini, DALL-E) under your Azure subscription, with private endpoints and no data sent to OpenAI's infrastructure.

Setup

pip install openai  # Azure uses the OpenAI Python SDK
from openai import AzureOpenAI
 
client = AzureOpenAI(
    azure_endpoint="https://YOUR_RESOURCE.openai.azure.com/",
    api_key="YOUR_AZURE_OPENAI_KEY",
    api_version="2024-12-01-preview"
)
 
response = client.chat.completions.create(
    model="gpt-4o",  # deployment name in Azure
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain Azure AI Foundry in 2 sentences."}
    ]
)
 
print(response.choices[0].message.content)

With Streaming

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": prompt}],
    stream=True
)
 
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

With Managed Identity (no API keys in production)

from azure.identity import DefaultAzureCredential, get_bearer_token_provider
from openai import AzureOpenAI
 
token_provider = get_bearer_token_provider(
    DefaultAzureCredential(),
    "https://cognitiveservices.azure.com/.default"
)
 
client = AzureOpenAI(
    azure_endpoint="https://YOUR_RESOURCE.openai.azure.com/",
    azure_ad_token_provider=token_provider,
    api_version="2024-12-01-preview"
)

This is the recommended pattern for production — no secrets in environment variables.


Azure AI Search (with Vector Search)

Azure AI Search is a fully managed search service with built-in support for hybrid search: combining traditional keyword (BM25) ranking with vector similarity. It's the backbone of most production RAG systems on Azure.

Create an Index with Vector Fields

from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
    SearchIndex, SimpleField, SearchableField,
    SearchField, SearchFieldDataType, VectorSearch,
    HnswAlgorithmConfiguration, VectorSearchProfile
)
from azure.core.credentials import AzureKeyCredential
 
index_client = SearchIndexClient(
    endpoint="https://YOUR_SEARCH.search.windows.net",
    credential=AzureKeyCredential("YOUR_KEY")
)
 
index = SearchIndex(
    name="docs",
    fields=[
        SimpleField(name="id", type=SearchFieldDataType.String, key=True),
        SearchableField(name="content", type=SearchFieldDataType.String),
        SearchableField(name="title", type=SearchFieldDataType.String, filterable=True),
        SearchField(
            name="content_vector",
            type=SearchFieldDataType.Collection(SearchFieldDataType.Single),
            searchable=True,
            vector_search_dimensions=1536,
            vector_search_profile_name="myHnswProfile"
        )
    ],
    vector_search=VectorSearch(
        algorithms=[HnswAlgorithmConfiguration(name="myHnsw")],
        profiles=[VectorSearchProfile(name="myHnswProfile", algorithm_configuration_name="myHnsw")]
    )
)
 
index_client.create_or_update_index(index)

Hybrid Search (Vector + Keyword)

from azure.search.documents import SearchClient
from azure.search.documents.models import VectorizedQuery
 
search_client = SearchClient(
    endpoint="https://YOUR_SEARCH.search.windows.net",
    index_name="docs",
    credential=AzureKeyCredential("YOUR_KEY")
)
 
# Generate embedding for the query
query_embedding = get_embedding("What is the refund policy?")
 
results = search_client.search(
    search_text="refund policy",  # BM25 keyword search
    vector_queries=[
        VectorizedQuery(
            vector=query_embedding,
            k_nearest_neighbors=5,
            fields="content_vector"
        )
    ],
    top=5,
    select=["id", "title", "content"]
)
 
for result in results:
    print(f"[{result['@search.score']:.3f}] {result['title']}")
    print(result['content'][:200])

Hybrid search consistently outperforms pure vector or pure keyword search for most Q&A use cases.


Azure Document Intelligence

Document Intelligence (formerly Form Recognizer) extracts structured data from PDFs, images, and scanned documents. Useful for processing invoices, contracts, IDs, and forms at scale.

from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.ai.documentintelligence.models import AnalyzeDocumentRequest
from azure.core.credentials import AzureKeyCredential
 
client = DocumentIntelligenceClient(
    endpoint="https://YOUR_DI.cognitiveservices.azure.com/",
    credential=AzureKeyCredential("YOUR_KEY")
)
 
# Analyze a PDF from URL
poller = client.begin_analyze_document(
    "prebuilt-document",
    AnalyzeDocumentRequest(url_source="https://example.com/contract.pdf")
)
 
result = poller.result()
 
# Extract tables
for table in result.tables:
    print(f"Table with {table.row_count} rows, {table.column_count} cols")
    for cell in table.cells:
        print(f"  [{cell.row_index},{cell.column_index}]: {cell.content}")
 
# Extract key-value pairs
for kv in result.key_value_pairs:
    if kv.key and kv.value:
        print(f"{kv.key.content}: {kv.value.content}")

Invoice Model

poller = client.begin_analyze_document(
    "prebuilt-invoice",
    AnalyzeDocumentRequest(url_source=invoice_url)
)
 
invoice = poller.result()
 
for doc in invoice.documents:
    fields = doc.fields
    print("Vendor:", fields.get("VendorName", {}).get("content"))
    print("Total:", fields.get("InvoiceTotal", {}).get("content"))
    print("Due:", fields.get("DueDate", {}).get("content"))

Azure AI Foundry

Azure AI Foundry (formerly Azure ML + Azure AI Studio) is the unified platform for managing AI projects on Azure. Key features:

  • Model catalog — deploy open-source models (Llama 3, Mistral, Phi-4) via managed endpoints
  • Prompt flow — visual + code-based pipeline builder for RAG and agent workflows
  • Evaluations — built-in eval framework for comparing models and prompts
  • Fine-tuning — supervised fine-tuning for Azure OpenAI models

Deploy a Model from the Catalog

from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential
 
client = MLClient(
    DefaultAzureCredential(),
    subscription_id="YOUR_SUB",
    resource_group_name="YOUR_RG",
    workspace_name="YOUR_WORKSPACE"
)
 
# Deploy Phi-4 to a managed endpoint
from azure.ai.ml.entities import ManagedOnlineEndpoint, ManagedOnlineDeployment
 
endpoint = ManagedOnlineEndpoint(name="phi4-endpoint", auth_mode="key")
client.online_endpoints.begin_create_or_update(endpoint).result()
 
deployment = ManagedOnlineDeployment(
    name="phi4",
    endpoint_name="phi4-endpoint",
    model="azureml://registries/azureml/models/Phi-4/versions/1",
    instance_type="Standard_NC24ads_A100_v4",
    instance_count=1
)
client.online_deployments.begin_create_or_update(deployment).result()

RAG Pipeline on Azure (End to End)

Combining Azure OpenAI + AI Search for a production RAG system:

from openai import AzureOpenAI
from azure.search.documents import SearchClient
from azure.search.documents.models import VectorizedQuery
from azure.core.credentials import AzureKeyCredential
 
openai_client = AzureOpenAI(
    azure_endpoint=AZURE_OPENAI_ENDPOINT,
    api_key=AZURE_OPENAI_KEY,
    api_version="2024-12-01-preview"
)
 
search_client = SearchClient(
    endpoint=AZURE_SEARCH_ENDPOINT,
    index_name="docs",
    credential=AzureKeyCredential(AZURE_SEARCH_KEY)
)
 
def embed(text: str) -> list[float]:
    response = openai_client.embeddings.create(
        model="text-embedding-3-small",
        input=text
    )
    return response.data[0].embedding
 
def rag_query(question: str) -> str:
    # Retrieve
    query_vector = embed(question)
    results = search_client.search(
        search_text=question,
        vector_queries=[VectorizedQuery(vector=query_vector, k_nearest_neighbors=5, fields="content_vector")],
        top=5,
        select=["title", "content"]
    )
 
    context = "\n\n".join(
        f"Source: {r['title']}\n{r['content']}"
        for r in results
    )
 
    # Generate
    response = openai_client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {
                "role": "system",
                "content": "Answer based on the provided context. If the answer isn't in the context, say so."
            },
            {
                "role": "user",
                "content": f"Context:\n{context}\n\nQuestion: {question}"
            }
        ]
    )
 
    return response.choices[0].message.content

When to Use Azure AI vs. Direct Providers

ScenarioRecommendation
Enterprise compliance requirementsAzure AI — data residency, GDPR
Already on Azure EAAzure AI — billing through credits
Need private networkingAzure AI with Private Endpoint
Fastest access to new modelsDirect OpenAI / Anthropic
Open-source model deploymentAzure AI Foundry or self-hosted
Cost optimization with spot computeAzure ML batch endpoints

The main reason to use Azure AI over direct API access is compliance and infrastructure integration — not capability. For pure development speed, direct provider APIs are simpler to work with.


Useful Links