当前位置: 首页 > article >正文

Azure OpenAI Ingesion Job API returns 404 Resource not found

题意:Azure OpenAI Ingestion Job API 返回 404 资源未找到。

问题背景:

Im following the documentation from Azure on the ingestion job API here: Ingestion Jobs - Create - REST API (Azure Azure AI Services) | Microsoft Learn

我正在按照Azure的文档操作,关于Ingestion Job API的内容在这里:Ingestion Jobs - Create - REST API (Azure Azure AI Services) | Microsoft Learn

No matter the body of my request or the api-key in the request headers, I get { error: { code: '404', message: 'Resource not found' } } from the server. The endpoint im using is the one found in the Azure portal under Azure OpenAI resource -> Resource Management -> Keys and Endpoints -> Endpoint. The Azure OpenAI resource is deployed in Sweden Central.

无论我请求的主体内容或请求头中的 API 密钥如何,服务器返回的都是 `{ error: { code: '404', message: 'Resource not found' } }`。我使用的端点是在 Azure 门户中的 Azure OpenAI 资源 -> 资源管理 -> 密钥和端点 -> 端点下找到的。Azure OpenAI 资源部署在瑞典中部区域。

Here is my request code:

以下是我的请求代码:

const jobId = 'testing2793619'; // The ID of the job to be created

    const url = `${openaiEndpoint}/openai/ingestion/jobs/${jobId}?api-version=2024-07-01-preview`;

    const requestBody = {
        kind: "SystemCompute",
        searchServiceConnection: {
            kind: "EndpointWithKey",
            endpoint: searchEndpoint, // Replace with your Azure AI Search service endpoint,
            key: searchAdminApiKey // Replace with your Azure AI Search admin API key
        },
        datasource: {
            kind: "Storage", 
            connection: {
                kind: "ConnectionString",
                connectionString: blobStorageConnectionString
            },
            containerName: "testcontainer",
            chunking: {
                maxChunkSizeInTokens: 2048 // Customize as needed
            }
        },
        dataRefreshIntervalInHours: 24, // Customize as needed
        completionAction: "cleanUpTempAssets" // or "cleanUpTempAssets" depending on your needs
    };

    try {
        const response = await fetch(url, {
            method: 'PUT',
            headers: {
                'Content-Type': 'application/json',
                'api-key': openaiApiKey
            },
            body: JSON.stringify(requestBody)
        });

        if (response.ok) {
            const data = await response.json();
            console.log('Request successful:', data);
            return data;
        } else {
            const errorData = await response.json();
            console.error('Request failed ingestion:', errorData);
        }
    } catch (error) {
        console.error('Error:', error);
    }

问题解决:

The 404 Resource not found error occurs when trying to create an ingestion job using the Azure OpenAI Ingestion Job API due to an invalid endpoint URL and API key.

Below is how we configure the endpoint URL and API key:

以下是我们配置端点 URL 和 API 密钥的方式:

async function createIngestionJob() {
    const endpoint = "https://AzureOpenapiName.openai.azure.com"; 
    const jobId = "ingestion-job"; // Replace with your job ID
    const apiVersion = "2024-07-01-preview";
 try {
        const response = await axios.put(
            `${endpoint}/openai/ingestion/jobs/${jobId}?api-version=${apiVersion}`,
            requestBody,
            { headers }
        );
const headers = {
        'api-key': 'YOUR_API_KEY', 
        'Content-Type': 'application/json'
    };

The javascript code below is for creation of an ingestion job using the Azure OpenAI Service with an endpoint and API version.

以下的 JavaScript 代码用于使用 Azure OpenAI 服务创建一个 Ingestion Job,包括端点和 API 版本的配置。

const axios = require('axios');

async function createIngestionJob() {
    const endpoint ="https://AzureOpenapiName.openai.azure.com"; 
    const jobId = "ingestion-job"; // Replace with your job ID
    const apiVersion = "2024-07-01-preview";

  
    const headers = {
        'api-key': 'YOUR_API_KEY', 
        'Content-Type': 'application/json',
        'mgmt-user-token': 'YOUR_MGMT_USER_TOKEN', // If required
        'aml-user-token': 'YOUR_AML_USER_TOKEN'    // If required
    };
    const requestBody = {
        "kind": "SystemCompute",
        "searchServiceConnection": {
            "kind": "EndpointWithManagedIdentity",
            "endpoint": "https://aykame-dev-search.search.windows.net"
        },
        "datasource": {
            "kind": "Storage",
            "connection": {
                "kind": "EndpointWithManagedIdentity",
                "endpoint": "https://mystorage.blob.core.windows.net/",
                "resourceId": "/subscriptions/1234567-abcd-1234-5678-1234abcd/resourceGroups/my-resource/providers/Microsoft.Storage/storageAccounts/mystorage"
            },
            "containerName": "container",
            "chunking": {
                "maxChunkSizeInTokens": 2048
            },
            "embeddings": [
                {
                    "connection": {
                        "kind": "RelativeConnection"
                    },
                    "deploymentName": "Ada"
                }
            ]
        },
        "dataRefreshIntervalInHours": 24,
        "completionAction": "keepAllAssets"
    };

    try {
        const response = await axios.put(
            `${endpoint}/openai/ingestion/jobs/${jobId}?api-version=${apiVersion}`,
            requestBody,
            { headers }
        );
        
        console.log('Ingestion job created successfully:', response.data);
        console.log('Operation location:', response.headers['operation-location']);
    } catch (error) {
        console.error('Error creating ingestion job:', error.response.data);
    }
}

createIngestionJob();


http://www.kler.cn/a/290752.html

相关文章:

  • 测序文章数据上传找哪里
  • CCF-GESP 等级考试 2023年12月认证C++五级真题解析
  • 多旋翼无人机理论 | 四旋翼动力学数学模型与Matlab仿真
  • 蓝牙BLE开发——解决iOS设备获取MAC方式
  • VSCode 插件开发实战(十二):如何集成Git操作能力
  • JS面试题|[2024-12-26]
  • 【图论入门】图的存储
  • 【编程底层思考】什么是JVM对象内存分配的空间分配担保,咋担保的?
  • [环境配置]Pycharm手动安装汉化插件
  • Redis缓存预热方案详解:提升应用性能与用户体验
  • ActiViz实战:使用Actor2D画一个二维网格
  • Unity | 内存优化之资源冗余问题
  • python办公自动化:使用`Python-PPTX` 应用动画效果
  • 【Python】数据可视化之核密度
  • 监控MySQL数据恢复策略性能:深入指南
  • 【专题】2024年中国游戏出海洞察报告合集PDF分享(附原数据表)
  • ubuntu20.04(wsl2)测试 arcface 人脸识别(计算特征向量)
  • chapter01 Java语言概述 知识点Note
  • hadoop强制退出安全模式命令
  • 深入解析Spring Boot中的`@Transactional`注解
  • 学习之SQL语句DQL(数据库操作语言)之多表查询(内外连接,自连接,子查询)
  • web渗透:SSRF漏洞
  • Xinstall引领免邀请码下载新潮流,便捷又安全
  • 性能测试⼯具-——JMeter
  • 基于Java+SpringBoot+Vue+MySQL的地方美食分享网站
  • RDD、DataFrame、DataSet(Spark)