---
title: "Azure AI Foundry"
description: "Enterprise-grade AI models with Azure security, compliance, and regional data residency. Access OpenAI, Llama, Mistral, and more through Azure infrastructure."
seo:
  title: "Azure AI Foundry Integration"
  description: "Access OpenAI and open-source models through Azure AI Foundry. Enterprise-grade security and compliance for regulated industries."
---

## What is the Autohand Azure AI Foundry integration? [#quick-answer]

The Autohand Azure AI Foundry integration connects the coding agent to a model deployment in your Azure environment. It uses the deployment endpoint and either an Azure API key or supported identity credentials.

|  |  |
| --- | --- |
| Status | Available |
| Requires | An Azure AI Foundry resource, a deployed model, its endpoint, and an API key or supported Azure identity. |
| Configure with | Set the Azure endpoint and credentials, name the deployed model, and select the Azure provider in your Autohand configuration. |
| Best for | Organizations using Azure identity, network, compliance, and regional controls. |

:::warning
**Know before you start:** Model availability and features depend on the Azure deployment, API version, subscription, and region.
:::

## 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
- Azure's own compliance certifications, which cover the Azure platform, not Autohand (see Microsoft's compliance documentation)
- Private endpoints and VNet integration

:::tip
**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](https://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

```bash
# 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:

```bash
# 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)

```json
{
  "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:

```json
{
  "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

| Option | Description | Default |
| --- | --- | --- |
| `model` | Model name (for display and model switching) | `gpt-4o` |
| `apiKey` | Your Azure API key | \- |
| `resourceName` | Azure resource name (from `https://{name}.openai.azure.com`) | \- |
| `deploymentName` | Model deployment name in Azure | \- |
| `apiVersion` | Azure OpenAI API version | `2024-10-21` |
| `authMethod` | Authentication method: `api-key`, `entra-id`, or `managed-identity` | `api-key` |
| `baseUrl` | Full endpoint URL override (bypasses resourceName/deploymentName) | \- |

### Environment variables

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

| Variable | Maps to |
| --- | --- |
| `AZURE_OPENAI_KEY` | `azure.apiKey` |
| `AZURE_OPENAI_ENDPOINT` | `azure.baseUrl` |
| `AZURE_OPENAI_DEPLOYMENT` | `azure.deploymentName` |
| `AZURE_OPENAI_API_VERSION` | `azure.apiVersion` |
| `AZURE_TENANT_ID` | `azure.tenantId` |
| `AZURE_CLIENT_ID` | `azure.clientId` |
| `AZURE_CLIENT_SECRET` | `azure.clientSecret` |

## Authentication methods [#authentication]

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.

```json
{
  "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](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app).

```json
{
  "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"
  }
}
```

:::tip
**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)](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview).

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

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

## Available models [#models]

Azure AI Foundry supports multiple model families.

### OpenAI models

| Model | Context | Best for |
| --- | --- | --- |
| `gpt-4o` | 128K | Most capable, multimodal |
| `gpt-4o-mini` | 128K | Fast and cost-effective |
| `gpt-4-turbo` | 128K | Complex reasoning |

### Open-source models

| Model | Context | Best for |
| --- | --- | --- |
| `Meta-Llama-3.1-70B` | 128K | Open-source, flexible |
| `Mistral-Large-2` | 128K | Efficient reasoning |
| `Phi-3-medium` | 128K | Microsoft 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

- [Azure AI Foundry Portal](https://ai.azure.com)
- [Azure AI Services](https://azure.microsoft.com/en-us/products/ai-services)
- [Azure OpenAI Documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/)
- [Azure OpenAI API Reference](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference)
- [Microsoft Entra ID (Azure AD) Platform](https://learn.microsoft.com/en-us/entra/identity-platform/)
- [Managed Identities for Azure Resources](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview)
- [Register an Application in Entra ID](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app)
- [Azure OpenAI Pricing](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/)
- [Azure Status](https://status.azure.com)

## Troubleshooting

### Common issues

| Issue | Solution |
| --- | --- |
| 401 Unauthorized | Check API key or Azure AD credentials |
| 404 Deployment not found | Verify deployment name matches exactly |
| 429 Rate limited | Increase TPM quota in [Azure portal](https://portal.azure.com) |
| Region not available | Deploy model in a supported region |

### Debug mode

```bash
# 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"}]}'
```

**How do I configure the Autohand Azure AI Foundry integration?**

Set the Azure endpoint and credentials, name the deployed model, and select the Azure provider in your Autohand configuration.

**What does the Autohand Azure AI Foundry integration require?**

An Azure AI Foundry resource, a deployed model, its endpoint, and an API key or supported Azure identity.

**What limitations should I know about?**

Model availability and features depend on the Azure deployment, API version, subscription, and region.
