> This page is for version 2.1.6 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 2.1.6 (Latest) (default): https://docs.nvidia.com/nim/large-language-models/2.1.6/llms.txt
> - 2.1.5: https://docs.nvidia.com/nim/large-language-models/2.1.5/llms.txt
> - 2.1.4: https://docs.nvidia.com/nim/large-language-models/2.1.4/llms.txt
> - 2.0.13: https://docs.nvidia.com/nim/large-language-models/2.0.13/llms.txt
> - 2.0.12: https://docs.nvidia.com/nim/large-language-models/2.0.12/llms.txt
> - 2.0.11: https://docs.nvidia.com/nim/large-language-models/2.0.11/llms.txt
> - 2.0.10: https://docs.nvidia.com/nim/large-language-models/2.0.10/llms.txt
> - 2.0.9: https://docs.nvidia.com/nim/large-language-models/2.0.9/llms.txt
> - 2.0.8: https://docs.nvidia.com/nim/large-language-models/2.0.8/llms.txt
> - 2.0.4-pb6: https://docs.nvidia.com/nim/large-language-models/2.0.4-pb6/llms.txt
> - Archive: https://docs.nvidia.com/nim/large-language-models/archive/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nim/large-language-models/llms.txt.

# Azure

> Deploy NIM LLM and VLM on Microsoft Azure using Azure Kubernetes Service with Helm or Microsoft Foundry managed online endpoints.

This guide covers deploying NIM LLM and VLM on Microsoft Azure, which supports two deployment paths:

* **AKS (Azure Kubernetes Service)**: Self-managed Kubernetes deployment using the NIM LLM and VLM Helm chart. Provides full control over infrastructure, including GPU node pools and persistent storage.
* **Microsoft Foundry**: Managed deployment using Azure ML Managed Online Endpoints. Simplifies infrastructure management with built-in health checks.

## Deploy on Azure Kubernetes Service (AKS)

To deploy NIM LLM and VLM on Azure Kubernetes Service (AKS), create an AKS cluster with GPU nodes and prepare the environment for NIM LLM workloads.

To deploy on AKS, complete the following steps.

### Prerequisites

Install the following tools before proceeding:

* [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli)
* [kubectl](https://kubernetes.io/docs/tasks/tools/)
* [Helm](https://helm.sh/docs/intro/install/)

> **Tip**
>
> If you use preview AKS features, also install the [aks-preview](https://github.com/Azure/azure-cli-extensions/tree/main/src/aks-preview) extension.

Log in to Azure:

```bash
az login --use-device-code
```

You also need an [NGC API key](https://org.ngc.nvidia.com/setup/api-key) with access to NIM LLM and VLM container images and Helm charts.

### Create an AKS Cluster with GPU Nodes

Complete the following steps to create the AKS cluster, add a GPU node pool, and get the cluster credentials.

1. Create a resource group and AKS cluster:

   ```bash
   export RESOURCE_GROUP="nim-resource-group"
   export REGION="southcentralus"
   export AKS_NAME="nim-cluster"

   az group create --name $RESOURCE_GROUP --location $REGION
   az aks create --resource-group $RESOURCE_GROUP --name $AKS_NAME \
     --location $REGION --generate-ssh-keys
   ```

   For detailed steps, refer to the [AKS quickstart guide](https://learn.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-cli).

2. Add a GPU node pool. Skip automatic GPU driver installation so the NVIDIA GPU Operator manages drivers later in this guide.

   ```bash
   az aks nodepool add --resource-group $RESOURCE_GROUP --cluster-name $AKS_NAME \
     --name gpupool --node-count 1 --node-vm-size Standard_ND96amsr_A100_v4 \
     --gpu-driver none --node-osdisk-size 2048 --max-pods 110
   ```

   > **Note**
   >
   > Azure CLI 2.72.2 or later is required for `--gpu-driver none`. On older CLI versions, use `--skip-gpu-driver-install` instead (deprecated after August 2025).

   > **Tip**
   >
   > Choose a GPU-enabled VM size that matches your model requirements. For supported options, refer to [GPU workloads in AKS](https://learn.microsoft.com/en-us/azure/aks/use-nvidia-gpu?tabs=add-ubuntu-gpu-node-pool#supported-gpu-enabled-vms).

3. Get the cluster credentials:

   ```bash
   az aks get-credentials --resource-group $RESOURCE_GROUP --name $AKS_NAME \
     --overwrite-existing
   ```

### Install the NVIDIA GPU Operator

Install the NVIDIA GPU Operator after the AKS cluster is ready.

1. Add the NVIDIA Helm repository:

   ```bash
   helm repo add nvidia https://helm.ngc.nvidia.com/nvidia --pass-credentials
   ```

2. Update the local Helm repository index:

   ```bash
   helm repo update
   ```

3. Install the GPU Operator:

   ```bash
   helm install --create-namespace --namespace gpu-operator \
     nvidia/gpu-operator --wait --generate-name
   ```

For more information, refer to the [NVIDIA GPU Operator documentation](https://docs.nvidia.com/datacenter/cloud-native/gpu-operator/latest/getting-started.html).

### Create Kubernetes Secrets

Create the namespace and secrets that the Helm deployment uses.

1. Set the required environment variables:

   ```bash
   export NGC_API_KEY="${YOUR_NGC_API_KEY}"
   export NAMESPACE="nim-llm"
   export IMAGE_PULL_SECRET="ngc-secret"
   ```

2. Create the namespace:

   ```bash
   kubectl create namespace $NAMESPACE
   ```

3. Create the NGC image pull secret:

   ```bash
   kubectl create secret docker-registry $IMAGE_PULL_SECRET \
     --namespace $NAMESPACE \
     --docker-server=nvcr.io \
     --docker-username='$oauthtoken' \
     --docker-password="$NGC_API_KEY"
   ```

4. Create the NGC API key secret:

   ```bash
   kubectl create secret generic ngc-api \
     --namespace $NAMESPACE \
     --from-literal=NGC_API_KEY="$NGC_API_KEY"
   ```

Optional: For gated Hugging Face models, create an additional secret.

1. Set the Hugging Face token:

   ```bash
   export HF_TOKEN="${YOUR_HF_TOKEN}"
   ```

2. Create the secret:

   ```bash
   kubectl create secret generic hf-token \
     --namespace $NAMESPACE \
     --from-literal=HF_TOKEN="$HF_TOKEN"
   ```

### Deploy NIM LLM and VLM with Helm

To deploy NIM LLM and VLM with Helm, complete the following steps:

1. Fetch the Helm chart from NGC:

   ```bash
   export NIM_LLM_CHART_VERSION="1.0.0"   # Set to your desired chart version
   helm fetch https://helm.ngc.nvidia.com/nim/charts/nim-llm-${NIM_LLM_CHART_VERSION}.tgz \
     --username='$oauthtoken' --password=$NGC_API_KEY
   ```

2. Optional: View the default chart values to understand available configuration options:

   ```bash
   helm show values nim-llm-${NIM_LLM_CHART_VERSION}.tgz
   ```

   > **Tip**
   >
   > For help choosing the right model configuration for your `values.yaml`, refer to [Model Profiles and Selection](/nim/large-language-models/deployment/model-profiles-and-selection).

3. Deploy using a custom values file:

   ```bash
   helm install my-nim nim-llm-${NIM_LLM_CHART_VERSION}.tgz \
     --namespace $NAMESPACE \
     -f path/to/your/custom-values.yaml
   ```

### Verify the Deployment

Complete the following steps to confirm that the service is reachable and serving inference requests.

1. Get the service endpoint:

   ```bash
   kubectl -n $NAMESPACE get svc -l app.kubernetes.io/name=nim-llm
   ```

2. Check the health endpoint (set `NIM_EXTERNAL_IP` from the service EXTERNAL-IP):

   ```bash
   export NIM_EXTERNAL_IP=$(kubectl -n $NAMESPACE get svc -l app.kubernetes.io/name=nim-llm -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}')
   curl -s "http://${NIM_EXTERNAL_IP}:8000/v1/health/ready"
   ```

3. Send an inference request:

   ```bash
   curl -X POST "http://${NIM_EXTERNAL_IP}:8000/v1/chat/completions" \
     -H "Content-Type: application/json" \
     -d '{
       "model": "meta/llama-3.1-8b-instruct",
       "messages": [{"role": "user", "content": "Hello!"}],
       "max_tokens": 128
     }'
   ```

## Deploy on Microsoft Foundry

To deploy NIM on Microsoft Foundry, provision the Azure Machine Learning resources and prepare your environment for NIM as a managed online endpoint.

To deploy on Microsoft Foundry, complete the following steps.

### Prerequisites

Before you deploy NIM to Microsoft Foundry, complete the following prerequisites:

* The [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) and Azure ML extension:

  ```bash
  az extension add -n ml -y
  ```

* An [Azure Machine Learning workspace](https://learn.microsoft.com/en-us/azure/machine-learning/quickstart-create-resources?view=azureml-api-2#create-the-workspace):

  ```bash
  az ml workspace create --name ${WORKSPACE_NAME} --resource-group ${RESOURCE_GROUP}
  ```

* An NGC API key for pulling NIM container images and downloading model artifacts.

* The [Azure AI ML Python SDK](https://pypi.org/project/azure-ai-ml/):

  ```bash
  pip install azure-ai-ml azure-identity
  ```

> **Note**
>
> Some Azure regions have limited GPU quota. If you encounter quota errors, refer to [Troubleshoot online endpoints: OutOfQuota](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-troubleshoot-online-endpoints?view=azureml-api-2\&tabs=cli#error-outofquota).

### Deploy with the Python SDK

The following steps deploy a NIM container as an Azure ML managed online endpoint.

> **Tip**
>
> The `nim_model_profile` variable determines which model configuration is used. For help choosing the right profile, refer to [Model Profiles and Selection](/nim/large-language-models/deployment/model-profiles-and-selection).

1. Create the ML client and endpoint:

   ```python
   from azure.ai.ml import MLClient
   from azure.ai.ml.entities import (
       ManagedOnlineEndpoint,
       ManagedOnlineDeployment,
       Environment,
       OnlineRequestSettings,
       ProbeSettings,
   )
   from azure.identity import DefaultAzureCredential

   subscription_id = "<your-subscription-id>"
   resource_group = "<your-resource-group>"
   workspace_name = "<your-workspace-name>"
   endpoint_name = "<your-endpoint-name>"
   acr_image = "<your-acr-or-ngc-nim-image-uri>"
   ngc_api_key = "<your-ngc-api-key>"
   nim_model_profile = "<your-nim-model-profile>"
   instance_type = "Standard_NC24ads_A100_v4"

   client = MLClient(
       credential=DefaultAzureCredential(),
       subscription_id=subscription_id,
       resource_group_name=resource_group,
       workspace_name=workspace_name,
   )

   endpoint = ManagedOnlineEndpoint(
       name=endpoint_name,
       description=f"NIM deployment: {acr_image}",
       auth_mode="key",
   )
   client.online_endpoints.begin_create_or_update(endpoint).result()
   ```

2. Define the environment and deployment:

   ```python
   env = Environment(
       name=f"nim-env-{endpoint_name}",
       image=acr_image,
       inference_config={
           "liveness_route": {"port": 8000, "path": "/v1/health/live"},
           "readiness_route": {"port": 8000, "path": "/v1/health/ready"},
           "scoring_route": {"port": 8000, "path": "/"},
       },
   )

   deployment = ManagedOnlineDeployment(
       name="nim",
       endpoint_name=endpoint_name,
       environment=env,
       instance_type=instance_type,
       instance_count=1,
       environment_variables={
           "NGC_API_KEY": ngc_api_key,
           "NIM_MODEL_PROFILE": nim_model_profile,
       },
       request_settings=OnlineRequestSettings(
           request_timeout_ms=90000,
           max_concurrent_requests_per_instance=1,
       ),
       liveness_probe=ProbeSettings(
           initial_delay=600, period=30, timeout=10, failure_threshold=30
       ),
       readiness_probe=ProbeSettings(
           initial_delay=600, period=30, timeout=10, failure_threshold=30
       ),
   )
   client.online_deployments.begin_create_or_update(deployment).result()
   ```

3. Route traffic to the deployment:

   ```python
   endpoint = client.online_endpoints.get(endpoint_name)
   endpoint.traffic = {"nim": 100}
   client.online_endpoints.begin_create_or_update(endpoint).result()
   ```

4. Retrieve the endpoint URL and key:

   ```python
   endpoint_info = client.online_endpoints.get(endpoint_name)
   keys = client.online_endpoints.get_keys(endpoint_name)
   endpoint_url = endpoint_info.scoring_uri.rstrip("/")
   api_key = keys.primary_key
   ```

### Verify the Deployment

Send an inference request to the endpoint:

```python
import httpx

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

payload = {
    "model": "meta/llama-3.1-8b-instruct",  # or your deployed model name
    "messages": [{"role": "user", "content": "Hello!"}],
    "max_tokens": 128,
}

with httpx.Client(timeout=60) as http:
    response = http.post(
        f"{endpoint_url}/v1/chat/completions",
        headers=headers,
        json=payload,
    )
    response.raise_for_status()
    print(response.json())
```

## Next Steps

Refer to the following Azure documentation for more information:

* [Azure Kubernetes Service (AKS) documentation](https://learn.microsoft.com/en-us/azure/aks/)
* [Microsoft Foundry documentation](https://learn.microsoft.com/en-us/azure/foundry/)
* [Model Profiles and Selection](/nim/large-language-models/deployment/model-profiles-and-selection) — Choose `nim_model_profile` for your GPU SKU