Erstellen Sie ein benutzerdefiniertes Modell mit Microsoft Entra ID
- Zuletzt aktualisiert2025/10/16
In diesem Thema werden die Schritte zum Konfigurieren der Microsoft Entra ID-Authentifizierung (früher Azure AD) für benutzerdefinierte Modelldefinitionen innerhalb von AI Agent Studio beschrieben, um eine nahtlose Integration Ihrer Modelle mit Automation 360 zu ermöglichen.
- Verwenden Sie Entra ID, wenn der Zielmodell-Anbieter nur OAuth2-Authentifizierung unterstützt.
- Dies ist oft der Fall bei von Azure gehosteten Diensten, wenn die Authentifizierung mit API-Schlüssel nicht parallel zu OAuth2 verwendet werden kann.
- Zum Beispiel verwenden Azure OpenAI-Modelle standardmäßig die API-Schlüssel-Authentifizierung, aber wenn Ihre Sicherheitsanforderungen OAuth2 über Entra ID erzwingen, müssen Sie das Modell über die benutzerdefinierte Modelldefinitionsroute konfigurieren.
Um die Postman-Sammlung (Entra ID-Beispiel) herunterzuladen und zu verwenden, klicken Sie auf diesen Link Postman-Sammlung – Entra ID-Beispiel.
Vorbereitungen
- Ein Azure-Konto mit aktiviertem Entra ID. Erfassen Sie die erforderlichen Details:
- Client-ID
- Geheimer Clientschlüssel
- Autorisierungs-URL
- Token-URL
- Konfigurieren Sie eine OAuth-Verbindung mit Entra ID. Weitere Informationen finden Sie in Microsoft Entra ID-Konfiguration.
Warum ein benutzerdefiniertes Modell und Entra ID verwenden?
Azure OpenAI wird mit API-Schlüssel-Authentifizierung in der Benutzeroberfläche unterstützt; wenn Sie stattdessen OAuth2/Entra ID benötigen, definieren Sie es über die Custom Model API, da ein Anbieter jeweils nur einen Authentifizierungsmechanismus in der Benutzeroberfläche bereitstellen kann.
Prozedur
Benutzerdefinierte Modelldefinition unter Verwendung von Entra ID
Hier ist ein vereinfachtes Beispiel für eine Azure OpenAI GPT-4.1 mini Bereitstellung unter Verwendung von Entra OAuth2:
POST https:/{{ControlRoomURL}}/gai/prompttools/v1/custommodel
{
"name": "AAI Docs Example - Entra",
"version": "0",
"authAction": {
"authType": "OAUTH2",
"oAuth": {
"location": "header",
"keyName": "Authorization",
"prefix": "Bearer "
}
},
"apiType": "REST",
"actions": [
{
"name": "gpt-4.1-mini",
"displayName": "GPT-4.1 mini",
"description": "GPT-4.1 mini provides a balance between intelligence, speed, and cost that makes it an attractive model for many use cases.",
"method": "POST",
"uri": "https://{resourceName}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version={apiVersion}",
"params": [
{
"type": "PATH_PARAM",
"attribute": [
{
"name": "resourceName",
"label": "Resource Name",
"value": {
"type": "TEXT",
"string": "genaitemplateplatformeastca"
}
}
]
},
{
"type": "PATH_PARAM",
"attribute": [
{
"name": "deployment",
"label": "Deployment",
"value": {
"type": "TEXT",
"string": "deploy-gpt-4.1"
}
}
]
},
{
"type": "PATH_PARAM",
"attribute": [
{
"name": "apiVersion",
"label": "API Version",
"value": {
"type": "TEXT",
"string": "2025-01-01-preview"
}
}
]
}
],
"request": {
"raw": {
"body": "{\"model\": \"gpt-4.1\",\"messages\":[{\"role\":\"system\",\"content\":\"system prompt\"},{\"role\":\"user\",\"content\":\"some prompt query\"}],\"max_completion_tokens\":500}",
"variables": [
{
"path": "$.max_completion_tokens",
"attribute": {
"name": "max_completion_tokens",
"label": "Max tokens",
"value": {
"type": "INTEGER",
"number": "2048"
},
"annotations": [
"MODEL_PARAMETER"
],
"canonicalName": "choices[0].completionTokens"
}
},
{
"path": "$.messages[1].content",
"attribute": {
"name": "prompt",
"label": "prompt",
"value": {
"type": "TEXT"
},
"annotations": [
"PROMPT_QUERY"
]
}
},
{
"path": "$.messages[0].content",
"attribute": {
"name": "systemPrompt",
"label": "System Prompt",
"value": {
"type": "TEXT"
},
"annotations": [
"SYSTEM_PROMPT_MESSAGE"
]
}
}
]
}
},
"response": {
"body": "{\n \"id\": \"chatcmpl-APwQdLa9WCQAdZg0dO5OjGr2ER4sX\",\n \"object\": \"chat.completion\",\n \"created\": 1730746163,\n \"model\": \"o3-mini-2025-01-31\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"Sure! They are one of the most mysterious and exciting objects in space.\",\n \"refusal\": null\n },\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 17,\n \"completion_tokens\": 959,\n \"total_tokens\": 976,\n \"prompt_tokens_details\": {\n \"cached_tokens\": 0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 64\n }\n },\n \"system_fingerprint\": \"fp_35c19d48ca\"\n}",
"variables": [
{
"path": "$.usage.completion_tokens",
"attribute": {
"name": "completion_tokens",
"label": "completion_tokens",
"value": {
"type": "INTEGER"
},
"annotations": [
"RESPONSE_PARAMETER"
],
"canonicalName": "choices[0].completionTokens"
}
},
{
"path": "$.choices[0].message.content",
"attribute": {
"name": "content",
"label": "content",
"value": {
"type": "TEXT",
"string": "Some response from LLM"
},
"annotations": [
"RESPONSE_PARAMETER"
],
"canonicalName": "choices[0].value"
}
},
{
"path": "$.model",
"attribute": {
"name": "model",
"label": "model",
"value": {
"type": "TEXT"
},
"annotations": [
"RESPONSE_PARAMETER"
],
"canonicalName": "model_name"
}
},
{
"path": "$.usage.prompt_tokens",
"attribute": {
"name": "prompt_tokens",
"label": "prompt_tokens",
"value": {
"type": "INTEGER"
},
"annotations": [
"RESPONSE_PARAMETER"
],
"canonicalName": "choices[0].promptTokens"
}
},
{
"path": "$.usage.total_tokens",
"attribute": {
"name": "total_tokens",
"label": "total_tokens",
"value": {
"type": "INTEGER"
},
"annotations": [
"RESPONSE_PARAMETER"
],
"canonicalName": "choices[0].totalTokens"
}
}
]
}
}
]
}