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
Convert language examples to tabs and refresh the managed identity guidance for Microsoft Foundry, including environment configuration, branding, and language-specific Azure Identity usage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Copilot SDK's [BYOK mode](../auth/byok.md) accepts static API keys, but Azure deployments often use **Managed Identity** (Entra ID) instead of long-lived keys. Since the SDK doesn't natively support Entra ID authentication, you can use a short-lived bearer token via the `bearer_token` provider config field.
3
+
The Copilot SDK's [BYOK mode](../auth/byok.md) accepts static API keys, but Azure deployments often use **Managed Identity** (Microsoft Entra ID) instead of long-lived keys. Since the SDK doesn't natively support Microsoft Entra authentication, you can use a short-lived bearer token via the `bearer_token` provider config field.
4
4
5
-
This guide shows how to use `DefaultAzureCredential` from the [Azure Identity](https://learn.microsoft.com/python/api/azure-identity/azure.identity.defaultazurecredential) library to authenticate with Azure AI Foundry models through the Copilot SDK.
5
+
This guide shows how to use the Azure Identity SDK's `DefaultAzureCredential` API to authenticate with Microsoft Foundry models through the Copilot SDK.
6
6
7
7
## How it works
8
8
9
-
Azure AI Foundry's OpenAI-compatible endpoint accepts bearer tokens from Entra ID in place of static API keys. The pattern is:
9
+
Microsoft Foundry's OpenAI-compatible endpoint accepts bearer tokens from Microsoft Entra ID in place of static API keys. The pattern is:
10
10
11
-
1. Use `DefaultAzureCredential` to obtain a token for the `https://cognitiveservices.azure.com/.default` scope
11
+
1. Use `DefaultAzureCredential` to obtain a token for the `https://ai.azure.com/.default` scope
12
12
1. Pass the token as the `bearer_token` in the BYOK provider config
13
13
1. Refresh the token before it expires (tokens are typically valid for ~1 hour)
newMessageOptions { Prompt="Hello from Managed Identity!" });
186
-
Console.WriteLine(response?.Data.Content);
187
-
```
230
+
</details>
188
231
189
232
## Environment configuration
190
233
191
234
| Variable | Description | Example |
192
235
|----------|-------------|---------|
193
-
|`AZURE_AI_FOUNDRY_RESOURCE_URL`| Your Azure AI Foundry resource URL |`https://myresource.openai.azure.com`|
236
+
|`AZURE_TOKEN_CREDENTIALS`| When running in **Azure**, set it to `ManagedIdentityCredential`. When running **locally**, set it to either `dev` or a developer tool credential name, such as `AzureCliCredential`. ||
237
+
|`FOUNDRY_RESOURCE_URL`| Your Microsoft Foundry resource URL |`https://<my-resource>.openai.azure.com`|
194
238
195
239
No API key environment variable is needed—authentication is handled by `DefaultAzureCredential`, which automatically supports:
196
240
@@ -199,14 +243,18 @@ No API key environment variable is needed—authentication is handled by `Defaul
199
243
***Environment variables** (`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`): for service principals
200
244
***Workload Identity**: for Kubernetes
201
245
202
-
See the [DefaultAzureCredential documentation](https://learn.microsoft.com/python/api/azure-identity/azure.identity.defaultazurecredential) for the full credential chain.
246
+
See the `DefaultAzureCredential` documentation for the full credential chain:
0 commit comments