Overview

Azure AI Foundry (formerly Azure AI Studio) provides enterprise access to leading AI models. When integrated with Autohand, you get:

  • Access to GPT-4, GPT-4o, and OpenAI models on Azure
  • Open-source models like Llama 3.1, Mistral, and Phi
  • Enterprise security with API Key, Microsoft Entra ID, or Managed Identity
  • Data residency in your chosen Azure region
  • Compliance certifications (SOC 2, HIPAA, GDPR)
  • Private endpoints and VNet integration

Enterprise choice: Azure AI Foundry is ideal for organizations that need Azure compliance, regional data residency, or existing Azure infrastructure integration.

Setup

Get started with Azure AI Foundry.

Prerequisites

  • Azure subscription with AI Foundry access
  • Azure AI Foundry project created
  • Model deployment in your project

Get your credentials

  1. Go to ai.azure.com and sign in
  2. Open your AI Foundry project
  3. Navigate to Deployments and select your model
  4. Copy the endpoint URL and API key

Configure Autohand

# Set environment variables
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_OPENAI_KEY="xxxxxxxxxxxxxxxxxxxxxxxx"
export AZURE_OPENAI_DEPLOYMENT="gpt-4o"
export AZURE_OPENAI_API_VERSION="2024-10-21"

# Or use the interactive wizard
autohand
/model
# Select "azure" from the provider list and follow the prompts

Verify your configuration:

# Start with Azure provider
autohand --provider azure --model gpt-4o

# Test with a prompt
autohand --prompt "Hello, which model are you?"

CLI configuration

Configure Azure AI Foundry in your ~/.autohand/config.json. Autohand supports two styles: structured fields (recommended) or a direct base URL override.

Structured configuration (recommended)

{
  "provider": "azure",
  "azure": {
    "model": "gpt-4o",
    "apiKey": "your-azure-api-key",
    "resourceName": "your-resource",
    "deploymentName": "gpt-4o",
    "apiVersion": "2024-10-21",
    "authMethod": "api-key"
  }
}

Base URL override

For proxies, custom endpoints, or Azure AI Foundry model-as-a-service:

{
  "provider": "azure",
  "azure": {
    "model": "gpt-4o",
    "apiKey": "your-azure-api-key",
    "baseUrl": "https://your-resource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-10-21"
  }
}

Configuration options

OptionDescriptionDefault
modelModel name (for display and model switching)gpt-4o
apiKeyYour Azure API key-
resourceNameAzure resource name (from https://{name}.openai.azure.com)-
deploymentNameModel deployment name in Azure-
apiVersionAzure OpenAI API version2024-10-21
authMethodAuthentication method: api-key, entra-id, or managed-identityapi-key
baseUrlFull endpoint URL override (bypasses resourceName/deploymentName)-

Environment variables

All configuration options can be set via environment variables. These override values in config.json:

VariableMaps to
AZURE_OPENAI_KEYazure.apiKey
AZURE_OPENAI_ENDPOINTazure.baseUrl
AZURE_OPENAI_DEPLOYMENTazure.deploymentName
AZURE_OPENAI_API_VERSIONazure.apiVersion
AZURE_TENANT_IDazure.tenantId
AZURE_CLIENT_IDazure.clientId
AZURE_CLIENT_SECRETazure.clientSecret

Authentication methods

Autohand supports three authentication methods for Azure OpenAI. Choose based on your security requirements.

API Key (default)

The simplest option. Use the API key from your Azure OpenAI resource.

{
  "provider": "azure",
  "azure": {
    "authMethod": "api-key",
    "apiKey": "your-azure-api-key",
    "resourceName": "your-resource",
    "deploymentName": "gpt-4o",
    "apiVersion": "2024-10-21"
  }
}

Microsoft Entra ID (Azure AD)

Use OAuth2 client credentials for enterprise environments. Requires an app registration in Microsoft Entra ID.

{
  "provider": "azure",
  "azure": {
    "authMethod": "entra-id",
    "tenantId": "your-tenant-id",
    "clientId": "your-client-id",
    "clientSecret": "your-client-secret",
    "resourceName": "your-resource",
    "deploymentName": "gpt-4o",
    "apiVersion": "2024-10-21"
  }
}

App permissions: Your Entra ID app registration needs the Cognitive Services OpenAI User role assigned on the Azure OpenAI resource.

Managed Identity

For workloads running inside Azure (VMs, App Service, AKS, etc.). No credentials needed — Azure handles authentication automatically via the Instance Metadata Service (IMDS).

{
  "provider": "azure",
  "azure": {
    "authMethod": "managed-identity",
    "resourceName": "your-resource",
    "deploymentName": "gpt-4o",
    "apiVersion": "2024-10-21"
  }
}

Production recommended: Managed Identity is the most secure option for Azure-hosted workloads. No secrets to rotate or leak.

Available models

Azure AI Foundry supports multiple model families.

OpenAI models

ModelContextBest for
gpt-4o128KMost capable, multimodal
gpt-4o-mini128KFast and cost-effective
gpt-4-turbo128KComplex reasoning

Open-source models

ModelContextBest for
Meta-Llama-3.1-70B128KOpen-source, flexible
Mistral-Large-2128KEfficient reasoning
Phi-3-medium128KMicrosoft research model

Best practices

  • Use Managed Identity: Prefer managed identities over API keys for Azure-hosted production workloads.
  • Use Entra ID: For non-Azure environments, use Entra ID app credentials instead of API keys.
  • Choose your region: Deploy models in regions that meet your data residency requirements.
  • Monitor usage: Use Azure Cost Management to track AI spending.
  • Set quotas: Configure TPM (tokens per minute) limits to control costs.
  • Rotate API keys: If using API keys, rotate them regularly via the Azure portal.

Resources

Troubleshooting

Common issues

IssueSolution
401 UnauthorizedCheck API key or Azure AD credentials
404 Deployment not foundVerify deployment name matches exactly
429 Rate limitedIncrease TPM quota in Azure portal
Region not availableDeploy model in a supported region

Debug mode

# Enable verbose logging
AUTOHAND_DEBUG=true autohand --provider azure

# Test Azure endpoint directly
curl "https://your-resource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-10-21" \
  -H "api-key: ${AZURE_OPENAI_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "Hello"}]}'