> ## Documentation Index
> Fetch the complete documentation index at: https://hobbyist-e43fa225.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy models using Azure CLI and Bicep

> Learn how to add and configure Microsoft Foundry Models in your Foundry resource for use in inference applications using Azure CLI and Bicep templates.

export const ZonePivot = ({group, options = [], defaultValue, label = "Choose an experience"}) => {
  const values = options.map(option => option.id);
  const optionKey = options.map(option => `${option.id}:${option.title}`).join("|");
  const [activePivot, setActivePivot] = useState(defaultValue || values[0]);
  const slugify = value => value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
  const resolvePivot = () => {
    if (typeof window === "undefined") return defaultValue || values[0];
    const params = new URLSearchParams(window.location.search);
    const requested = params.get("pivots");
    if (requested) {
      const requestedIds = requested.split(",").map(value => value.trim()).filter(Boolean);
      const match = requestedIds.find(id => values.includes(id));
      if (match) return match;
    }
    const hash = window.location.hash.replace(/^#/, "");
    if (hash) {
      const match = options.find(option => option.id === hash || slugify(option.title) === hash);
      if (match) return match.id;
    }
    try {
      const stored = window.localStorage.getItem(`foundry-zone-pivot:${group}`);
      if (values.includes(stored)) return stored;
    } catch {
      return defaultValue || values[0];
    }
    return defaultValue || values[0];
  };
  const publishPivotChange = value => {
    if (typeof window === "undefined") return;
    window.dispatchEvent(new CustomEvent("foundry-zone-pivot-change", {
      detail: {
        group,
        value
      }
    }));
  };
  const syncTableOfContents = () => {
    if (typeof window === "undefined") return;
    window.requestAnimationFrame(() => {
      const toc = document.getElementById("table-of-contents-content");
      if (!toc) return;
      const links = Array.from(toc.querySelectorAll('a[href^="#"]'));
      for (const link of links) {
        const item = link.closest("li");
        const rawId = link.getAttribute("href")?.slice(1);
        if (!item || !rawId) continue;
        let id = rawId;
        try {
          id = decodeURIComponent(rawId);
        } catch {}
        item.style.display = document.getElementById(id) ? "" : "none";
      }
    });
  };
  useEffect(() => {
    const resolvedPivot = resolvePivot();
    setActivePivot(resolvedPivot);
    publishPivotChange(resolvedPivot);
    window.setTimeout(syncTableOfContents, 0);
  }, [group, defaultValue, values.join("|"), optionKey]);
  const selectPivot = value => {
    setActivePivot(value);
    if (typeof window !== "undefined") {
      try {
        window.localStorage.setItem(`foundry-zone-pivot:${group}`, value);
      } catch {}
      const url = new URL(window.location.href);
      const current = url.searchParams.get("pivots");
      const preserved = current ? current.split(",").map(id => id.trim()).filter(id => id && !values.includes(id)) : [];
      url.searchParams.set("pivots", [...preserved, value].join(","));
      window.history.replaceState(null, "", `${url.pathname}${url.search}${url.hash}`);
    }
    publishPivotChange(value);
    window.setTimeout(syncTableOfContents, 0);
  };
  if (options.length < 2) return null;
  return <div className="not-prose my-6 border-b border-slate-200 pb-3 dark:border-slate-800">
      <div className="mb-2 text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400">
        {label}
      </div>
      <div className="flex flex-wrap gap-2" role="tablist" aria-label={label}>
        {options.map(option => {
    const selected = option.id === activePivot;
    return <button key={option.id} type="button" role="tab" aria-selected={selected} onClick={() => selectPivot(option.id)} className={`rounded-md border px-3 py-1.5 text-sm font-medium transition ${selected ? "border-slate-900 bg-slate-900 text-white shadow-sm dark:border-slate-100 dark:bg-slate-100 dark:text-slate-950" : "border-slate-200 bg-white text-slate-700 hover:border-slate-400 hover:text-slate-950 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-200 dark:hover:border-slate-500"}`}>
              {option.title}
            </button>;
  })}
      </div>
    </div>;
};

export const ZoneContent = ({group, value, options = [], values = [], defaultValue, children}) => {
  const optionKey = options.map(option => `${option.id}:${option.title}`).join("|");
  const [activePivot, setActivePivot] = useState(defaultValue || values[0]);
  const slugify = value => value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
  const resolvePivot = () => {
    if (typeof window === "undefined") return defaultValue || values[0];
    const params = new URLSearchParams(window.location.search);
    const requested = params.get("pivots");
    if (requested) {
      const requestedIds = requested.split(",").map(value => value.trim()).filter(Boolean);
      const match = requestedIds.find(id => values.includes(id));
      if (match) return match;
    }
    const hash = window.location.hash.replace(/^#/, "");
    if (hash) {
      const match = options.find(option => option.id === hash || slugify(option.title) === hash);
      if (match) return match.id;
    }
    try {
      const stored = window.localStorage.getItem(`foundry-zone-pivot:${group}`);
      if (values.includes(stored)) return stored;
    } catch {
      return defaultValue || values[0];
    }
    return defaultValue || values[0];
  };
  useEffect(() => {
    setActivePivot(resolvePivot());
  }, [group, defaultValue, values.join("|"), optionKey]);
  useEffect(() => {
    const onPivotChange = event => {
      if (event.detail?.group === group && values.includes(event.detail.value)) {
        setActivePivot(event.detail.value);
      }
    };
    window.addEventListener("foundry-zone-pivot-change", onPivotChange);
    return () => window.removeEventListener("foundry-zone-pivot-change", onPivotChange);
  }, [group, values.join("|")]);
  if (activePivot !== value) return null;
  return <>{children}</>;
};

<Info>
  Azure AI Inference beta SDK is deprecated and will be retired on August 26, 2026. Switch to the generally available [OpenAI/v1 API](https://aka.ms/openai/v1) with a stable OpenAI SDK. Follow the [migration guide](../how-to/model-inference-to-openai-migration) to switch to OpenAI/v1, using the SDK for your preferred programming language.
</Info>

In this article, you learn how to add a new model deployment to a Foundry Models endpoint. The deployment is available for inference in your Foundry resource when you specify the deployment name in your requests.

## Prerequisites

To complete this article, you need the following:

* An Azure subscription. If you're using GitHub Models, you can upgrade your experience and create an Azure subscription in the process. For more information, see [Upgrade from GitHub Models to Foundry Models](/models/quickstart-github-models).

* A Foundry project. This project type is managed under a Foundry resource (formerly known as Azure AI Services resource). If you don't have a Foundry project, see [Create a project for Microsoft Foundry](../../how-to/create-projects).

* Azure role-based access control (RBAC) permissions to create and manage deployments. You need the **Cognitive Services Contributor** role or equivalent permissions for the Foundry resource.

* [Foundry Models from partners and community](/models/models-from-partners) require access to **Azure Marketplace**. Ensure you have the [permissions required to subscribe to model offerings](../how-to/configure-marketplace). [Foundry Models sold by Azure](/models/models-sold-directly-by-azure) don't have this requirement.

<ZonePivot group="programming-language-bicep__programming-language-cli" options={[{"id": "programming-language-cli", "title": "Speech CLI"}, {"id": "programming-language-bicep", "title": "Bicep"}]} defaultValue="programming-language-cli" />

<ZoneContent group="programming-language-bicep__programming-language-cli" value="programming-language-cli" options={[{"id": "programming-language-cli", "title": "Speech CLI"}, {"id": "programming-language-bicep", "title": "Bicep"}]} values={["programming-language-cli", "programming-language-bicep"]} defaultValue="programming-language-cli">
  * Install the [Azure CLI](https://learn.microsoft.com/cli/azure/) (version 2.60 or later) and the `cognitiveservices` extension.

    ```azurecli theme={null}
    az extension add -n cognitiveservices
    ```

  * Some commands in this tutorial use the `jq` tool, which might not be installed on your system. For installation instructions, see [Download `jq`](https://stedolan.github.io/jq/download/).

  * Identify the following information:

    * Your Azure subscription ID

    * Your Foundry resource name

    * The resource group where you deployed the Foundry resource

  ## Add models

  To add a model, first identify the model that you want to deploy. Query the available models as follows:

  1. Sign in to your Azure subscription.

     ```azurecli theme={null}
     az login
     ```

  2. If you have more than one subscription, select the subscription where your resource is located.

     ```azurecli theme={null}
     az account set --subscription $subscriptionId
     ```

  3. Set the following environment variables with the name of the Foundry resource you plan to use and resource group.

     ```azurecli theme={null}
     accountName="<ai-services-resource-name>"
     resourceGroupName="<resource-group>"
     location="eastus2"
     ```

  4. If you haven't created a Foundry resource yet, create one.

     ```azurecli theme={null}
     az cognitiveservices account create -n $accountName -g $resourceGroupName --custom-domain $accountName --location $location --kind AIServices --sku S0
     ```

     Reference: [az cognitiveservices account](https://learn.microsoft.com/cli/azure/cognitiveservices/account)

  5. Check which models are available to you and under which SKU. SKUs, also known as [deployment types](/models/deployment-types), define how Azure infrastructure processes requests. Models might offer different deployment types. The following command lists all the model definitions available:

     ```azurecli theme={null}
     az cognitiveservices account list-models \
         -n $accountName \
         -g $resourceGroupName \
     | jq '.[] | { name: .name, format: .format, version: .version, sku: .skus[0].name, capacity: .skus[0].capacity.default }'
     ```

     The output includes available models with their properties:

     ```output theme={null}
     {
       "name": "Phi-4-mini-instruct",
       "format": "Microsoft",
       "version": "1",
       "sku": "GlobalStandard",
       "capacity": 1
     }
     ```

     Reference: [az cognitiveservices account list-models](https://learn.microsoft.com/cli/azure/cognitiveservices/account#az-cognitiveservices-account-list-models)

  6. Identify the model you want to deploy. You need the properties `name`, `format`, `version`, and `sku`. The property `format` indicates the provider offering the model. Depending on the type of deployment, you might also need capacity.

  7. Add the model deployment to the resource. The following example adds `Phi-4-mini-instruct`:

     ```azurecli theme={null}
     az cognitiveservices account deployment create \
         -n $accountName \
         -g $resourceGroupName \
         --deployment-name Phi-4-mini-instruct \
         --model-name Phi-4-mini-instruct \
         --model-version 1 \
         --model-format Microsoft \
         --sku-capacity 1 \
         --sku-name GlobalStandard
     ```

     Reference: [az cognitiveservices account deployment](https://learn.microsoft.com/cli/azure/cognitiveservices/account/deployment)

  8. Verify the deployment completed successfully:

     ```azurecli theme={null}
     az cognitiveservices account deployment show \
         --deployment-name Phi-4-mini-instruct \
         -n $accountName \
         -g $resourceGroupName \
     | jq '.properties.provisioningState'
     ```

     The output should display `"Succeeded"`. The model is ready to use after provisioning completes.

     Reference: [az cognitiveservices account list-models](https://learn.microsoft.com/cli/azure/cognitiveservices/account#az-cognitiveservices-account-deployment-show)

  You can deploy the same model multiple times if needed as long as it's under a different deployment name. This capability is useful if you want to test different configurations for a given model, including content filters.

  ## Use the model

  <Note>
    This section is identical for both the CLI and Bicep approaches.
  </Note>

  You can consume deployed models using the [Endpoints for Foundry Models](/models/endpoints) for the resource. When you construct your request, specify the parameter `model` and insert the model deployment name you created. You can programmatically get the URI for the inference endpoint by using the following code:

  **Inference endpoint**

  ```azurecli theme={null}
  az cognitiveservices account show  -n $accountName -g $resourceGroupName | jq '.properties.endpoints["Azure AI Model Inference API"]'
  ```

  To make requests to the Foundry Models endpoint, append the route `models`. For example: `https://<resource>.services.ai.azure.com/models`. See the [Azure AI Model Inference API reference](https://learn.microsoft.com/rest/api/microsoft-foundry/modelinference/) for all supported operations.

  **Inference keys**

  ```azurecli theme={null}
  az cognitiveservices account keys list  -n $accountName -g $resourceGroupName
  ```

  ## Manage deployments

  You can see all the deployments available using the CLI:

  1. Run the following command to see all the active deployments:

     ```azurecli theme={null}
     az cognitiveservices account deployment list -n $accountName -g $resourceGroupName
     ```

     Reference: [az cognitiveservices account deployment list](https://learn.microsoft.com/cli/azure/cognitiveservices/account/deployment#az-cognitiveservices-account-deployment-list)

  2. You can see the details of a given deployment:

     ```azurecli theme={null}
     az cognitiveservices account deployment show \
         --deployment-name "Phi-4-mini-instruct" \
         -n $accountName \
         -g $resourceGroupName
     ```

     Reference: [az cognitiveservices account deployment show](https://learn.microsoft.com/cli/azure/cognitiveservices/account/deployment#az-cognitiveservices-account-deployment-show)

  3. You can delete a given deployment as follows:

     ```azurecli theme={null}
     az cognitiveservices account deployment delete \
         --deployment-name "Phi-4-mini-instruct" \
         -n $accountName \
         -g $resourceGroupName
     ```

     Reference: [az cognitiveservices account deployment delete](https://learn.microsoft.com/cli/azure/cognitiveservices/account/deployment#az-cognitiveservices-account-deployment-delete)
</ZoneContent>

<ZoneContent group="programming-language-bicep__programming-language-cli" value="programming-language-bicep" options={[{"id": "programming-language-cli", "title": "Speech CLI"}, {"id": "programming-language-bicep", "title": "Bicep"}]} values={["programming-language-cli", "programming-language-bicep"]} defaultValue="programming-language-cli">
  * Install the [Azure CLI](https://learn.microsoft.com/cli/azure/).

  * Identify the following information:

    * Your Azure subscription ID

  * Your Foundry resource (formerly known as Azure AI Services resource) name

  * The resource group where the Foundry resource is deployed

  * The model name, provider, version, and SKU you want to deploy. You can use the Foundry portal or the Azure CLI to find this information. In this example, you deploy the following model:

    * **Model name**: `Phi-4-mini-instruct`
    * **Provider**: `Microsoft`
    * **Version**: `1`
    * **Deployment type**: Global standard

  ## Set up the environment

  The example in this article is based on code samples contained in the [Azure-Samples/azureai-model-inference-bicep](https://github.com/Azure-Samples/azureai-model-inference-bicep) repository. To run the commands locally without having to copy or paste file content, clone the repository:

  ```bash theme={null}
  git clone https://github.com/Azure-Samples/azureai-model-inference-bicep
  ```

  The files for this example are in:

  ```bash theme={null}
  cd azureai-model-inference-bicep/infra
  ```

  ## Permissions required to subscribe to Models from partners and community

  [Foundry Models from partners and community](../../concepts/models-from-partners) available for deployment (for example, Cohere models) require Azure Marketplace. Model providers define the license terms and set the price for use of their models using Azure Marketplace.

  When deploying third-party models, ensure you have the following permissions in your account:

  * On the Azure subscription:
  * `Microsoft.MarketplaceOrdering/agreements/offers/plans/read`
  * `Microsoft.MarketplaceOrdering/agreements/offers/plans/sign/action`
  * `Microsoft.MarketplaceOrdering/offerTypes/publishers/offers/plans/agreements/read`
  * `Microsoft.Marketplace/offerTypes/publishers/offers/plans/agreements/read`
  * `Microsoft.SaaS/register/action`
  * On the resource group—to create and use the SaaS resource:
  * `Microsoft.SaaS/resources/read`
  * `Microsoft.SaaS/resources/write`
    The **Owner** and **Contributor** built-in roles on the Azure subscription include these permissions. If you don't have the required permissions, ask your subscription administrator to assign you the **Contributor** role, or [create a custom role](https://learn.microsoft.com/azure/role-based-access-control/custom-roles) that includes the listed actions.

  To verify your permissions, go to the [Azure portal](https://portal.azure.com), open your subscription, select **Access control (IAM)** > **Check access**, and review your assigned roles.

  <Tip>
    `Microsoft.SaaS/register/action` is a one-time registration of the SaaS resource provider on the subscription. After registration, it doesn't need to be repeated for each deployment.
  </Tip>

  ## Add the model

  1. Use the template `ai-services-deployment-template.bicep` to describe model deployments:

     **ai-services-deployment-template.bicep**

     ```bicep theme={null}
     // Source: ai-services-deployment-template.bicep (not available)
     ```

  2. Run the deployment:

     ```azurecli theme={null}
     RESOURCE_GROUP="<resource-group-name>"
     ACCOUNT_NAME="<azure-ai-model-inference-name>" 
     MODEL_NAME="Phi-4-mini-instruct"
     PROVIDER="Microsoft"
     VERSION=1

     az deployment group create \
         --resource-group $RESOURCE_GROUP \
         --template-file ai-services-deployment-template.bicep \
         --parameters accountName=$ACCOUNT_NAME modelName=$MODEL_NAME modelVersion=$VERSION modelPublisherFormat=$PROVIDER
     ```

  3. Verify the deployment completed successfully:

     ```azurecli theme={null}
     az cognitiveservices account deployment show \
         --deployment-name $MODEL_NAME \
         -n $ACCOUNT_NAME \
         -g $RESOURCE_GROUP \
     | jq '.properties.provisioningState'
     ```

     The output should display `"Succeeded"`.

  ## Use the model

  <Note>
    This section is identical for both the CLI and Bicep approaches.
  </Note>

  You can consume deployed models using the [Endpoints for Foundry Models](/models/endpoints) for the resource. When you construct your request, specify the parameter `model` and insert the model deployment name you created. You can programmatically get the URI for the inference endpoint by using the following code:

  **Inference endpoint**

  ```azurecli theme={null}
  az cognitiveservices account show  -n $accountName -g $resourceGroupName | jq '.properties.endpoints["Azure AI Model Inference API"]'
  ```

  To make requests to the Foundry Models endpoint, append the route `models`. For example: `https://<resource>.services.ai.azure.com/models`. See the [Azure AI Model Inference API reference](https://learn.microsoft.com/rest/api/microsoft-foundry/modelinference/) for all supported operations.

  **Inference keys**

  ```azurecli theme={null}
  az cognitiveservices account keys list  -n $accountName -g $resourceGroupName
  ```
</ZoneContent>

## Troubleshooting

| Error                    | Cause                                                                          | Resolution                                                                            |
| ------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
| **Quota exceeded**       | Your subscription reached the deployment quota for the selected SKU or region. | Check your quota in the Foundry portal or request an increase through Azure support.  |
| **Authorization failed** | The identity used doesn't have the required RBAC role.                         | Assign the **Cognitive Services Contributor** role on the Foundry resource.           |
| **Model not available**  | The model isn't available in your region or subscription.                      | Run `az cognitiveservices account list-models` to check available models and regions. |
| **Extension not found**  | The `cognitiveservices` CLI extension isn't installed.                         | Run `az extension add -n cognitiveservices` to install the extension.                 |

## Related content

* [Elevated-role tasks in Microsoft Foundry](../../concepts/administrator-guide#deploy-and-manage-models) — role requirements for model deployment and quota management.
* [Generate text responses with Foundry Models](/models/generate-responses)
* [Deployment types in Foundry Models](/models/deployment-types)
* [Instant access to models in Microsoft Foundry (preview)](/models/instant-models)
* [Deploy Foundry Models to managed compute](/models/deploy-foundry-models)
* [Quotas and limits for Foundry Models](/models/quotas-limits)
