You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-foundry/foundry-models/how-to/configure-entra-id.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,21 @@
1
1
---
2
2
title: Configure key-less authentication with Microsoft Entra ID
3
3
titleSuffix: Azure AI Foundry
4
-
description: Learn how to configure key-less authorization to use Azure AI Foundry Models with Microsoft Entra ID.
4
+
description: Learn how to configure key-less authorization to use Azure AI Foundry Models with Microsoft Entra ID and enhance security.
5
5
ms.service: azure-ai-foundry
6
6
ms.subservice: azure-ai-foundry-model-inference
7
7
ms.topic: how-to
8
-
ms.date: 08/29/2025
8
+
ms.date: 09/26/2025
9
9
ms.custom: ignite-2024, github-universe-2024
10
10
author: msakande
11
11
ms.author: mopeakande
12
12
recommendations: false
13
13
zone_pivot_groups: azure-ai-models-deployment
14
14
ms.reviewer: fasantia
15
15
reviewer: santiagxf
16
+
ai-usage: ai-assisted
17
+
18
+
#CustomerIntent: As a developer, I want to configure keyless authentication with Microsoft Entra ID for Azure AI Foundry Models so that I can secure my AI model deployments without relying on API keys and leverage role-based access control for better security and compliance.
16
19
---
17
20
18
21
# Configure key-less authentication with Microsoft Entra ID
@@ -118,11 +118,11 @@ ChatCompletionsClient client = new ChatCompletionsClientBuilder()
118
118
.buildClient();
119
119
```
120
120
121
-
Explore our [samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-inference/src/samples) and read the [API reference documentation](https://aka.ms/azsdk/azure-ai-inference/java/reference) to get yourself started.
121
+
Explore our [samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-inference/src/samples) and read the [API reference documentation](https://aka.ms/azsdk/azure-ai-inference/java/reference) to get started.
122
122
123
123
# [REST](#tab/rest)
124
124
125
-
Use the reference section to explore the API design and which parameters are available and indicate authentication token in the header `Authorization`. For example, the reference section for [Chat completions](../../model-inference/reference/reference-model-inference-chat-completions.md) details how to use the route `/chat/completions` to generate predictions based on chat-formatted instructions. Notice that the path `/models` is included to the root of the URL:
125
+
Use the reference section to explore the API design and see which parameters are available. Indicate the authentication token in the header `Authorization`. For example, the reference section for [Chat completions](../../model-inference/reference/reference-model-inference-chat-completions.md) details how to use the route `/chat/completions` to generate predictions based on chat-formatted instructions. The path `/models` is included in the root of the URL:
Tokens have to be issued with scope `https://cognitiveservices.azure.com/.default`.
135
+
Tokens must be issued with scope `https://cognitiveservices.azure.com/.default`.
136
136
137
137
For testing purposes, the easiest way to get a valid token for your user account is to use the Azure CLI. In a console, run the following Azure CLI command:
Copy file name to clipboardExpand all lines: articles/ai-foundry/foundry-models/includes/configure-entra-id/about-credentials.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@ author: santiagxf
4
4
ms.author: fasantia
5
5
ms.service: azure-ai-foundry
6
6
ms.subservice: azure-ai-foundry-model-inference
7
-
ms.date: 01/23/2025
7
+
ms.date: 09/26/2025
8
8
ms.topic: include
9
9
---
10
10
11
11
### Options for credential when using Microsoft Entra ID
12
12
13
-
`DefaultAzureCredential` is an opinionated, ordered sequence of mechanisms for authenticating to Microsoft Entra ID. Each authentication mechanism is a class derived from the `TokenCredential` class and is known as a credential. At runtime, `DefaultAzureCredential` attempts to authenticate using the first credential. If that credential fails to acquire an access token, the next credential in the sequence is attempted, and so on, until an access token is successfully obtained. In this way, your app can use different credentials in different environments without writing environment-specific code.
13
+
`DefaultAzureCredential` is an opinionated, ordered sequence of mechanisms for authenticating to Microsoft Entra ID. Each authentication mechanism is a class derived from the `TokenCredential` class and is known as a credential. At runtime, `DefaultAzureCredential` attempts to authenticate by using the first credential. If that credential fails to acquire an access token, the next credential in the sequence is attempted, and so on, until an access token is successfully obtained. In this way, your app can use different credentials in different environments without writing environment-specific code.
14
14
15
-
When the preceding code runs on your local development workstation, it looks in the environment variables for an application service principal or at locally installed developer tools, such as Visual Studio, for a set of developer credentials. Either approach can be used to authenticate the app to Azure resources during local development.
15
+
When the preceding code runs on your local development workstation, it looks in the environment variables for an application service principal or at locally installed developer tools, such as Visual Studio, for a set of developer credentials. You can use either approach to authenticate the app to Azure resources during local development.
16
16
17
17
When deployed to Azure, this same code can also authenticate your app to other Azure resources. `DefaultAzureCredential` can retrieve environment settings and managed identity configurations to authenticate to other services automatically.
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
+
The example in this article is based on code samples in the [Azure-Samples/azureai-model-inference-bicep](https://github.com/Azure-Samples/azureai-model-inference-bicep) repository. To run the commands locally without copying or pasting file content, use the following commands to clone the repository and go to the folder for your coding language:
@@ -33,24 +33,24 @@ cd azureai-model-inference-bicep/infra
33
33
34
34
## Understand the resources
35
35
36
-
The tutorial helps you create:
36
+
In this tutorial, you create the following resources:
37
37
38
-
> [!div class="checklist"]
39
-
> * An Azure AI Foundry (formerly known Azure AI Services) resource with key access disabled. For simplicity, this template doesn't deploy models.
40
-
> * A role-assignment for a given security principal with the role **Cognitive Services User**.
41
38
42
-
You are using the following assets to create those resources:
39
+
* An Azure AI Foundry resource (formerly known as Azure AI Services resource) with key access disabled. For simplicity, this template doesn't deploy models.
40
+
* A role-assignment for a given security principal with the role **Cognitive Services User**.
43
41
44
-
1. Use the template `modules/ai-services-template.bicep` to describe your Azure AI Foundry (formerly known Azure AI Services) resource:
42
+
To create these resources, use the following assets:
43
+
44
+
1. Use the template `modules/ai-services-template.bicep` to describe your Azure AI Foundry resource:
> 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
+
> This template accepts the `allowKeys`parameter. Set it to `false`to disable key access in the resource. This configuration is optional.
52
52
53
-
2. Use the template `modules/role-assignment-template.bicep` to describe a role assignment in Azure:
53
+
1. Use the template `modules/role-assignment-template.bicep` to describe a role assignment in Azure:
54
54
55
55
__modules/role-assignment-template.bicep__
56
56
@@ -66,36 +66,36 @@ In your console, follow these steps:
7. The template outputs the Azure AI Foundry Models endpoint that you can use to consume any of the model deployments you have created.
93
+
1. The template outputs the Azure AI Foundry Models endpoint that you can use to consume any of the model deployments you created.
94
94
95
95
96
96
## Use Microsoft Entra ID in your code
97
97
98
-
Once you configured Microsoft Entra ID 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:
98
+
After you configure Microsoft Entra ID in your resource, update your code to use it when consuming the inference endpoint. The following example shows how to use a chat completions model:
@@ -107,7 +107,7 @@ Once you configured Microsoft Entra ID in your resource, you need to update your
107
107
108
108
## Disable key-based authentication in the resource
109
109
110
-
Disabling key-based authentication is advisable when you implemented Microsoft Entra ID and fully addressed compatibility or fallback concerns in all the applications that consume the service. You can achieve it by changing the property `disableLocalAuth`:
110
+
Disable key-based authentication when you implement Microsoft Entra ID and fully address compatibility or fallback concerns in all the applications that consume the service. Change the `disableLocalAuth` property to disable key-based authentication:
* Your Azure AI Foundry (formerly known Azure AI Services) resource name.
20
+
* Your Azure AI Foundry resource (formerly known as Azure AI Services resource) name.
21
21
22
-
* The resource group where the Azure AI Foundry (formerly known Azure AI Services) resource is deployed.
22
+
* The resource group where you deployed the Azure AI Foundry resource.
23
23
24
24
25
25
## Configure Microsoft Entra ID for inference
26
26
27
27
Follow these steps to configure Microsoft Entra ID for inference:
28
28
29
29
30
-
1.Log in into your Azure subscription:
30
+
1.Sign in to your Azure subscription.
31
31
32
32
```azurecli
33
33
az login
34
34
```
35
35
36
-
2. If you have more than one subscription, select the subscription where your resource is located:
36
+
1. If you have more than one subscription, select the subscription where your resource is located.
37
37
38
38
```azurecli
39
39
az account set --subscription "<subscription-id>"
40
40
```
41
41
42
-
3. Set the following environment variables with the name of the Azure AI Foundry (formerly known Azure AI Services) resource you plan to use and resource group.
42
+
1. Set the following environment variables with the name of the Azure AI Foundry resource you plan to use and resource group.
43
43
44
44
```azurecli
45
45
ACCOUNT_NAME="<ai-services-resource-name>"
46
46
RESOURCE_GROUP="<resource-group>"
47
47
```
48
48
49
-
4. Get the full name of your resource:
49
+
1. Get the full name of your resource.
50
50
51
51
```azurecli
52
-
RESOURCE_ID=$(az resource show -g $RESOURCE_GROUP -n $ACCOUNT_NAME --resource-type "Microsoft.CognitiveServices/accounts")
52
+
RESOURCE_ID=$(az resource show -g $RESOURCE_GROUP -n $ACCOUNT_NAME --resource-type "Microsoft.CognitiveServices/accounts" --query id --output tsv)
53
53
```
54
54
55
-
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
+
1. 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:
56
56
57
-
__Your own logged in account:__
57
+
**Your own signed in account:**
58
58
59
59
```azurecli
60
60
OBJECT_ID=$(az ad signed-in-user show --query id --output tsv)
61
61
```
62
62
63
-
__A security group:__
63
+
**A security group:**
64
64
65
65
```azurecli
66
66
OBJECT_ID=$(az ad group show --group "<group-name>" --query id --output tsv)
67
67
```
68
68
69
-
__A service principal:__
69
+
**A service principal:**
70
70
71
71
```azurecli
72
72
OBJECT_ID=$(az ad sp show --id "<service-principal-guid>" --query id --output tsv)
73
73
```
74
74
75
-
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
+
1. Assign the **Cognitive Services User** role to the service principal (scoped to the resource). By assigning a role, you grant the service principal access to this resource.
76
76
77
77
```azurecli
78
78
az role assignment create --assignee-object-id $OBJECT_ID --role "Cognitive Services User" --scope $RESOURCE_ID
79
79
```
80
80
81
-
8. The selected user can now use Microsoft Entra ID for inference.
81
+
1. The selected user can now use Microsoft Entra ID for inference.
82
82
83
83
> [!TIP]
84
-
> Keep in mind that Azure role assignments may take up to five minutes to propagate. Adding or removing users from a security group propagates immediately.
84
+
> Keep in mind that Azure role assignments can take up to five minutes to propagate. Adding or removing users from a security group propagates immediately.
85
85
86
86
87
87
## Use Microsoft Entra ID in your code
88
88
89
-
Once Microsoft Entra ID is 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
+
After you configure Microsoft Entra ID in your resource, update your code to use it when consuming the inference endpoint. The following example shows how to use a chat completions model:
0 commit comments