You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启用私有端点的Azure AI Foundry用DefaultAzureCredential报500错误

问题

我有一个启用私有端点且禁用其他网络访问的Azure AI Foundry Hub,Hub下包含一个用于部署无服务器端点模型的Azure AI Project。使用AzureKeyCredential("key")调用模型时一切正常,但使用DefaultAzureCredential()时会返回Internal Server error 500错误。

经调试确认:

  • DefaultAzureCredential认证成功,且通过AzureCLICredential完成了认证流程
  • 堆栈跟踪未提供详细错误信息,仅返回500错误
  • 禁用私有端点后,使用DefaultAzureCredential可正常调用模型

发送POST请求时立即返回500错误:

azure.core.exceptions.HttpResponseError: (None) Internal server error

测试代码1

import logging
from azure.ai.inference import ChatCompletionsClient
from azure.ai.inference.models import AssistantMessage, SystemMessage, UserMessage
from azure.core.credentials import AzureKeyCredential
from azure.identity import DefaultAzureCredential
from azure.core.pipeline.policies import HttpLoggingPolicy


endpoint = "https://abc.eastus.models.ai.azure.com"
model_name = "se-Mistral-large"


# 使用DefaultAzureCredential认证
client = ChatCompletionsClient(
    endpoint=endpoint,
    credential=DefaultAzureCredential()    
)

response = client.complete(
        messages=[   
            {         
                "role": "user",
                "content": "I am going to Paris, what should I see?"
            }
        ],
        max_tokens=2048,   
        temperature=0.8,
        top_p=0.1, 
        model=model_name
    )
print(response.choices[0].message.content)

测试代码2(同样返回500错误)

credential = DefaultAzureCredential()
token = credential.get_token("https://ml.azure.com/.default")
client = ChatCompletionsClient(
        endpoint="https://abc.eastus.models.ai.azure.com",
        credential=AzureKeyCredential(token.token)
)

请求与响应日志

2025-05-15 16:37:43,989 - ERROR - Request Headers: {'Content-Type': 'application/json', 'Content-Length': '136', 'Accept': 'application/json', 'x-ms-client-request-id': 'e9e6ba1a-31aa-11f0-8e44-7c1e528244e5', , 'User-Agent': 'azsdk-python-ai-inference/1.0.0b9 Python/3.13.3 (Windows-2022Server-10.0.20348-SP0)', 'Authorization': 'Bearer token'}
2025-05-15 16:37:44,005 - ERROR - Request Body: {"messages": [{"role": "user", "content": "I am going to London, what should I see?"}], "max_tokens": 2048, "model": "se-Mistral-large"}
2025-05-15 16:37:44,006 - ERROR - Response Headers: {'Content-Length': '111', 'Content-Type': 'application/json', 'x-request-id': '6023e2cb-7220-4f9a-a439-5c84ea572f02', 'x-ms-error-reason': 'ExpressionValueEvaluationFailure', 'Request-Context': 'appId=cid-v1:38659f32-9fc9-4714-92e6-1412a97fbbfc', 'Date': 'Thu, 15 May 2025 16:37:43 GMT'}
2025-05-15 16:37:44,007 - ERROR - Response Body: { "statusCode": 500, "message": "Internal server error", "activityId": "6023e2cb-7220-4f9a-a439-5c84ea572f02" }

请问是否缺少相关权限或配置?


内容的提问来源于stack exchange,提问作者Bokambo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 03:22:44