Skip to content

Commit b3761f3

Browse files
committed
feat: entra ID
1 parent 5acda83 commit b3761f3

File tree

6 files changed

+333
-0
lines changed

6 files changed

+333
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Configure key-less access with Microsoft Entra ID
3+
titleSuffix: Azure AI Foundry
4+
description: Learn how to configure key-less authorization to use Azure AI model inference with Microsoft Entra ID.
5+
ms.service: azure-ai-model-inference
6+
ms.topic: how-to
7+
ms.date: 10/01/2024
8+
ms.custom: ignite-2024, github-universe-2024
9+
manager: nitinme
10+
author: mrbullwinkle
11+
ms.author: fasantia
12+
recommendations: false
13+
zone_pivot_groups: azure-ai-models-deployment
14+
---
15+
16+
# Configure key-less access with Microsoft Entra ID
17+
18+
::: zone pivot="ai-foundry-portal"
19+
[!INCLUDE [portal](../includes/configure-entra-id/portal.md)]
20+
::: zone-end
21+
22+
::: zone pivot="programming-language-cli"
23+
[!INCLUDE [cli](../includes/configure-entra-id/cli.md)]
24+
::: zone-end
25+
26+
::: zone pivot="programming-language-bicep"
27+
[!INCLUDE [bicep](../includes/configure-entra-id/bicep.md)]
28+
::: zone-end
29+
30+
## Next steps
31+
32+
* [Develop applications using Azure AI model inference service in Azure AI services](../supported-languages.md)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
manager: nitinme
3+
author: mrbullwinkle
4+
ms.author: fasantia
5+
ms.service: azure-ai-model-inference
6+
ms.date: 12/15/2024
7+
ms.topic: include
8+
zone_pivot_groups: azure-ai-models-deployment
9+
---
10+
11+
[!INCLUDE [Header](intro.md)]
12+
13+
* Install the [Azure CLI](/cli/azure/).
14+
15+
* Identify the following information:
16+
17+
* Your Azure subscription ID.
18+
19+
## About this tutorial
20+
21+
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, use the following commands to clone the repository and go to the folder for your coding language:
22+
23+
```azurecli
24+
git clone https://github.com/Azure-Samples/azureai-model-inference-bicep
25+
```
26+
27+
The files for this example are in:
28+
29+
```azurecli
30+
cd azureai-model-inference-bicep/infra
31+
```
32+
33+
## Understand the resources
34+
35+
The tutorial helps you create:
36+
37+
> [!div class="checklist"]
38+
> * An Azure AI Services resource with key access disabled. For simplicity, this template doesn't deploy models.
39+
> * A role-assignment for a given security principal with the role **Cognitive Services User**.
40+
41+
You are using the following assets to create those resources:
42+
43+
1. Use the template `modules/ai-services-template.bicep` to describe your Azure AI Services resource:
44+
45+
__modules/ai-services-template.bicep__
46+
47+
:::code language="bicep" source="~/azureai-model-inference-bicep/infra/modules/ai-services-template.bicep":::
48+
49+
> [!TIP]
50+
> Notice that this template can take the parameter `allowKeys` which, when `false` will disable the use of keys in the resource. This configuration is optional.
51+
52+
2. Use the template `modules/role-assignment-template.bicep` to describe a role assignment in Azure:
53+
54+
__modules/role-assignment-template.bicep__
55+
56+
:::code language="bicep" source="~/azureai-model-inference-bicep/infra/modules/role-assignment-template.bicep":::
57+
58+
## Create the resources
59+
60+
In your console, follow these steps:
61+
62+
1. Define the main deployment:
63+
64+
__deploy-simple-entra-id.bicep__
65+
66+
:::code language="bicep" source="~/azureai-model-inference-bicep/infra/deploy-simple-entra-id.bicep":::
67+
68+
2. Log into Azure:
69+
70+
```azurecli
71+
az login
72+
```
73+
74+
3. Ensure you are in the right subscription:
75+
76+
```azurecli
77+
az account set --subscription "<subscription-id>"
78+
```
79+
80+
4. Run the deployment:
81+
82+
```azurecli
83+
RESOURCE_GROUP="<resource-group-name>"
84+
SECURITY_PRINCIPAL_ID="<your-security-principal-id>"
85+
86+
az deployment group create \
87+
--resource-group $RESOURCE_GROUP \
88+
--securityPrincipalId $SECURITY_PRINCIPAL_ID
89+
--template-file deploy-simple-entra-id.bicep
90+
```
91+
92+
7. The template outputs the Azure AI model inference endpoint that you can use to consume any of the model deployments you have created.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
manager: nitinme
3+
author: mrbullwinkle
4+
ms.author: fasantia
5+
ms.service: azure-ai-model-inference
6+
ms.date: 12/15/2024
7+
ms.topic: include
8+
zone_pivot_groups: azure-ai-models-deployment
9+
---
10+
11+
[!INCLUDE [Header](intro.md)]
12+
13+
* Install the [Azure CLI](/cli/azure/).
14+
15+
* Identify the following information:
16+
17+
* Your Azure subscription ID.
18+
19+
* Your Azure AI Services resource name.
20+
21+
* The resource group where the Azure AI Services resource is deployed.
22+
23+
24+
## Configure Microsoft Entra ID for inference
25+
26+
Follow these steps to configure Microsoft Entra ID for inference in you Azure AI Services resource:
27+
28+
29+
1. Log in into your Azure subscription:
30+
31+
```azurecli
32+
az login
33+
```
34+
35+
2. If you have more than 1 subscription, select the subscription where your resource is located:
36+
37+
```azurecli
38+
az account set --subscription "<subscription-id>"
39+
```
40+
41+
3. Set the following environment variables with the name of the Azure AI Services resource you plan to use and resource group.
42+
43+
```azurecli
44+
ACCOUNT_NAME="<ai-services-resource-name>"
45+
RESOURCE_GROUP="<resource-group>"
46+
```
47+
48+
4. Get the full name of your resource:
49+
50+
```azurecli
51+
RESOURCE_ID=$(az resource show -g $RESOURCE_GROUP -n $ACCOUNT_NAME --resource-type "Microsoft.CognitiveServices/accounts")
52+
```
53+
54+
5. Get the object ID of the security principal you want to assign permissions to. The following example shows how to get the object ID associated with:
55+
56+
__Your own logged in account__
57+
58+
```azurecli
59+
OBJECT_ID=$(az ad signed-in-user show --query id --output tsv)
60+
```
61+
62+
__A security group__
63+
64+
```azurecli
65+
OBJECT_ID=$(az ad group show --group "<group-name>" --query id --output tsv)
66+
```
67+
68+
__A service principal__
69+
70+
```azurecli
71+
OBJECT_ID=$(az ad sp show --id "<service-principal-guid>" --query id --output tsv)
72+
```
73+
74+
6. Assign the **Cognitive Services User** role to the service principal (scoped to the resource). By assigning a role, you're granting service principal access to this resource.
75+
76+
```azurecli
77+
az role assignment create --assignee-object-id $OBJECT_ID --role "Cognitive Services User" --scope $RESOURCE_ID
78+
```
79+
80+
8. The selected user can now use Microsoft Entra ID for inference.
81+
82+
> [!TIP]
83+
> Keep in mind that Azure role assignments may take up to five minutes to propagate. When working with security groups, adding or removing users from the security group propagates immediately.
84+
85+
86+
## Use Microsoft Entra ID in your code
87+
88+
Once Microsoft Entra ID has been configured in your resource, you need to update your code to use it when consuming the inference endpoint. The following example shows how to use a chat completions model:
89+
90+
[!INCLUDE [code](../code-create-chat-client-entra.md)]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[!INCLUDE [Feature preview](../../../../ai-studio/includes/feature-preview.md)]
2+
3+
Models deployed to Azure AI model inference in Azure AI Services support key-less authorization using Microsoft Entra ID. It enhances security, simplifies the user experience, reduces operational complexity, and provides robust compliance support for modern development. This makes it a strong choice for organizations adopting secure and scalable identity management solutions. You can [configure Microsoft Entra ID authorization in the resource](#configure-microsoft-entra-id-for-inferenced) and, optionally, [disable key-based authentication to prevent any user to still use keys to access the service](#disable-key-based-authentication-in-the-resource).
4+
5+
This article explains how to configure Microsoft Entra ID for inference in Azure AI model inference.
6+
7+
## Understand roles in the context of resource in Azure
8+
9+
Microsoft Entra ID uses the idea of Role-based Access Control (RBAC) for authorization. Roles are central to managing access to your cloud resources. A role is essentially a collection of permissions that define what actions can be performed on specific Azure resources. By assigning roles to users, groups, service principals, or managed identities—collectively known as security principals—you control their access within your Azure environment to specific resources.
10+
11+
When you assign a role, you specify the security principal, the role definition, and the scope. This combination is known as a role assignment. Azure AI model inference is a capability of the Azure AI Services resources, and hence, access to the service is controlled by the roles assigned to that particular resource.
12+
13+
You identify two different types of access to the resources:
14+
15+
* **Administration access**: The actions that are related with the administration of the resources. These type of operations usually change the state of the resource and its configuration. In Azure, those operations are usually considered control-plane operations and can be executed using the Azure Portal, the Azure CLI, or with infrastructure as code. Examples of these are create new model deployments, change content filtering configurations, change the version of the model served, change SKU of a deployment.
16+
* **Developer access**: The actions that are related with the consumption of the resources. These type of operations consumes the capabilities of the resource. For example, invoking the chat completions API. However, the user can't change the state of the resource and its configuration.
17+
18+
In Azure, administration operations are always performed using Microsoft Entra ID. Roles like **Cognitive Services Contributor** allow you to perform those operations. On the other hand, developer operations can be performed using either access keys or/and Microsoft Entra ID. Roles like **Cognitive Services User** allow you to perform those operations.
19+
20+
> [!IMPORTANT]
21+
> Having administration access to a resource doesn't necessarily grants developer access to it. Explicit access by granting roles is still required. This is analogous to how database servers work. Having administrator access to the database server doesn't mean you can read the data inside of a database.
22+
23+
Follow these steps to configure developer access to Azure AI model inference in the Azure AI Services resource.
24+
25+
## Prerequisites
26+
27+
To complete this article, you need:
28+
29+
* An Azure subscription. If you are using [GitHub Models](https://docs.github.com/en/github-models/), you can upgrade your experience and create an Azure subscription in the process. Read [Upgrade from GitHub Models to Azure AI model inference](../../how-to/quickstart-github-models.md) if it's your case.
30+
31+
* An Azure AI services resource. For more information, see [Create an Azure AI Services resource](/articles/ai-foundry/model-inference/how-to/quickstart-create-resources.md).
32+
33+
* Administrator roles for the scope of the Azure AI Services resource or the resource group where it's deployed.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
manager: nitinme
3+
author: mrbullwinkle
4+
ms.author: fasantia
5+
ms.service: azure-ai-model-inference
6+
ms.date: 12/15/2024
7+
ms.topic: include
8+
zone_pivot_groups: azure-ai-models-deployment
9+
---
10+
11+
[!INCLUDE [Header](intro.md)]
12+
13+
## Configure Microsoft Entra ID for inference
14+
15+
Follow these steps to configure Microsoft Entra ID for inference if you are using **projects or hubs** in Azure AI Foundry. If your are not using them, Start from step 5 using the Azure portal.
16+
17+
1. Go to the [Azure portal](https://portal.azure.com) and locate the Azure AI Services resource you are using. If you are using Azure AI Foundry with projects or hubs, you can navigate to it by:
18+
19+
1. Go to [Azure AI Foundry portal](https://ai.azure.com).
20+
21+
2. On the landing page, select **Open management center**.
22+
23+
3. Go to the section **Connected resources** and select the connection to the Azure AI Services resource that you want to configure. If it's not listed, select **View all** to see the full list.
24+
25+
4. On the **Connection details** section, under **Resource**, select the name of the Azure resource. A new page opens.
26+
27+
5. You are now in [Azure portal](https://portal.azure.com) where you can manage all the aspects of the resource itself.
28+
29+
2. On the left navigation bar, select **Access control (IAM)**.
30+
31+
> [!TIP]
32+
> Use the **View my access** option to verify which roles are already assigned to you.
33+
34+
3. Select **Role assignments** and then select **Add** > **Add role assignment**.
35+
36+
4. On **Job function roles**, type **Cognitive Services User**. The list of roles is filtered out.
37+
38+
5. Select the role and select **Next**.
39+
40+
6. On **Members**, select the user or group you want to grant access to. We recommend using security groups whenever possible as they are easier to manage and maintain.
41+
42+
7. Select **Next** and finish the wizard.
43+
44+
8. The selected user can now use Microsoft Entra ID for inference.
45+
46+
> [!TIP]
47+
> Keep in mind that Azure role assignments may take up to five minutes to propagate. When working with security groups, adding or removing users from the security group propagates immediately.
48+
49+
Notice that key-based access is still possible for users that already have keys available to them. If you want to revoke the keys, in the Azure portal, on the left navigation, select **Resource Management** > **Keys and Endpoints** > **Regenerate Key1** and **Regenerate Key2**.
50+
51+
52+
## Use Microsoft Entra ID in your code
53+
54+
Once Microsoft Entra ID has been configured in your resource, you need to update your code to use it when consuming the inference endpoint. The following example shows how to use a chat completions model:
55+
56+
[!INCLUDE [code](../code-create-chat-client-entra.md)]
57+
58+
59+
## Use Microsoft Entra ID in your project
60+
61+
Even when your resource has Microsoft Entra ID configured, your projects may still be using keys to consume predictions from the resource. To change this behavior, you have to update the connections from your projects to use Microsoft Entra ID. Follow these steps:
62+
63+
1. Go to [Azure AI Foundry portal](https://ai.azure.com).
64+
65+
2. Navigate to the projects or hubs that are using the Azure AI Services resource through a connection.
66+
67+
3. Select **Management center**.
68+
69+
3. Go to the section **Connected resources** and select the connection to the Azure AI Services resource that you want to configure. If it's not listed, select **View all** to see the full list.
70+
71+
4. On the **Connection details** section, next to **Access details**, select the edit icon.
72+
73+
5. Under **Authentication**, change the value to **Microsoft Entra ID**.
74+
75+
6. Select **Update**.
76+
77+
7. Your connection is configured to work with Microsoft Entra ID now.
78+
79+
80+
## Disable key-based authentication in the resource
81+
82+
Disabling key-based authentication is advisable when you’ve implemented Microsoft Entra ID and fully addressed compatibility or fallback concerns in all the applications that consume the service.
83+
84+

articles/ai-foundry/model-inference/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ items:
5454
href: ./how-to/configure-content-filters.md
5555
- name: Use blocklists
5656
href: ./how-to/use-blocklists.md
57+
- name: Configure key-less authentication with Microsoft Entra ID
58+
href: ./how-to/configure-entra-id.md
5759
- name: Manage cost
5860
href: ./how-to/manage-costs.md
5961
- name: Quotas and limits

0 commit comments

Comments
 (0)