The requested item was created under a different Azure OpenAI resource. Use the ...

2026年10月21日 18:55 15.01 秒 success

错误信息

The requested item was created under a different Azure OpenAI resource. Use the same resource that created the item to access it.

AI 解决方案

🌐 错误翻译

原文:The requested item was created under a different Azure OpenAI resource. Use the same resource that created the item to access it.
译文:所请求的项目是在另一个Azure OpenAI资源下创建的。请使用创建该项目的同一资源来访问它。

🎯 原因分析

  • 根本原因:尝试访问的项目(如部署、模型或数据)并非当前使用的Azure OpenAI资源创建,资源归属不一致。

  • 具体场景:在调用Azure OpenAI接口时,误用了与资源创建时不同的Azure OpenAI资源名称、ID或密钥,导致资源不匹配。
  • 💡 解决方案

    // 修复后的代码(C#示例,需替换为对应语言实现)
    // 1. 确认创建项目时使用的Azure OpenAI资源信息
    string correctResourceName = "your-original-azure-openai-resource-name";
    string correctApiKey = "your-original-resource-api-key";
    string endpoint = $"https://{correctResourceName}.openai.azure.com/";
    
    // 2. 使用正确的资源信息初始化客户端
    var client = new AzureOpenAIClient(
        new Uri(endpoint),
        new AzureKeyCredential(correctApiKey)
    );
    
    // 3. 后续操作保持使用该客户端
    var response = client.GetDeployment("your-target-deployment").Value;
    

    🛡️ 预防措施

  • ✅ 资源信息集中管理:将Azure OpenAI资源名称、密钥、端点统一存储在环境变量或配置文件中,避免硬编码和资源信息混乱。

  • ✅ 资源归属校验:在初始化客户端或发起请求前,校验当前资源信息与项目创建时的资源信息一致性,可在日志中记录资源标识便于排查。