Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.1k stars 1.21k forks source link

Azure AI Search: Error in Vectorizer 'vector-search-vectorizer' : 'uri' parameter cannot be null or empty #31893

Open FabianHertwig opened 1 day ago

FabianHertwig commented 1 day ago

Describe the bug I want to create an Index and add a vectorizer to it. But I get the error message The request is invalid. Details: definition : Error in Vectorizer 'vector-search-vectorizer' : 'uri' parameter cannot be null or empty.

I am following this guide: https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-configure-vectorizer

There it is ResourceUri, but in the type description search-documents.d.ts it is ResourceUrl.

export declare interface AzureOpenAIParameters {
    /** The resource uri for your Azure Open AI resource. */
    resourceUrl?: string;
    /** ID of your Azure Open AI model deployment on the designated resource. */
    deploymentId?: string;
    /** API key for the designated Azure Open AI resource. */
    apiKey?: string;
    /** The user-assigned managed identity used for outbound connections. */
    authIdentity?: SearchIndexerDataIdentity;
    /** The name of the embedding model that is deployed at the provided deploymentId path. */
    modelName?: AzureOpenAIModelName;
}

Either way, I get the same error.

To Reproduce Steps to reproduce the behaviour:

Create a new index with the following code.

try {
  const result = await client.createIndex({
        name: env.INDEX_NAME,
        fields: [
            {
                type: 'Edm.String',
                name: 'key',
                key: true
            },
            {
                name: 'contentVector',
                type: 'Collection(Edm.Single)',
                searchable: true,
                vectorSearchDimensions: Number(env.EMBEDDING_VECTOR_SIZE),
                vectorSearchProfileName: 'myHnswProfile'
            },
            {
                name: 'content',
                type: 'Edm.String',
                searchable: true
            }
        ],
        vectorSearch: {
            algorithms: [
                {
                    name: 'vector-search-algorithm',
                    kind: 'hnsw'
                }
            ],
            profiles: [
                {
                    name: 'myHnswProfile',
                    algorithmConfigurationName: 'vector-search-algorithm',
                    vectorizerName: 'vector-search-vectorizer'
                }
            ],
            vectorizers: [
                {
                    vectorizerName: 'vector-search-vectorizer',
                    kind: 'azureOpenAI',
                    parameters: {
                        resourceUrl: env.AZURE_OPENAI_API_ENDPOINT,
                        deploymentId: env.AZURE_OPENAI_DEPLOYMENT_NAME,
                        apiKey: env.AZURE_OPENAI_API_KEY,
                    }
                }
            ]
        }
    });

    return new Response(JSON.stringify(result), { status: 201 });
} catch (error) {
    console.error(error);
    return new Response(
        JSON.stringify({ message: 'An error occurred while creating the index.' }),
        {
            status: 500
        }
    );
}

Error message:

RestError: The request is invalid. Details: definition : Error in Vectorizer 'vector-search-vectorizer' : 'uri' parameter cannot be null or empty 
 {
  "name": "RestError",
  "code": "",
  "statusCode": 400,
  "request": {
    "url": "https://REDACTED.search.windows.net/indexes?api-version=2024-07-01",
    "headers": {
      "content-type": "application/json",
      "accept": "application/json;odata.metadata=minimal",
      "accept-encoding": "gzip,deflate",
      "user-agent": "azsdk-js-search-documents/12.1.0 core-rest-pipeline/1.16.2 Node/23.2.0 OS/(arm64-Darwin-24.1.0)",
      "x-ms-client-request-id": "34376bc0-643b-4e55-accb-28a856e38e46",
      "api-key": "REDACTED",
      "content-length": "4625"
    },
    "method": "POST",
    "timeout": 0,
    "disableKeepAlive": false,
    "streamResponseStatusCodes": {},
    "withCredentials": false,
    "tracingOptions": {
      "tracingContext": {
        "_contextMap": {}
      }
    },
    "requestId": "34376bc0-643b-4e55-accb-28a856e38e46",
    "allowInsecureConnection": false,
    "enableBrowserStreams": false
  },
  "details": {
    "error": {
      "code": "",
      "message": "The request is invalid. Details: definition : Error in Vectorizer 'vector-search-vectorizer' : 'uri' parameter cannot be null or empty"
    }
  },
  "message": "The request is invalid. Details: definition : Error in Vectorizer 'vector-search-vectorizer' : 'uri' parameter cannot be null or empty"
}

Expected behavior The index gets created with the vectorizer configured.

Additional context

This issue is related: https://github.com/Azure/azure-sdk-for-js/issues/31458 But I didn't really understand the answer and somehow it got resolved for the author, but the suggested resolution to use ResourceUrl does not work for me. Therefore I opened a new issue.

github-actions[bot] commented 1 day ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @bleroy @markheff @miwelsh @tjacobhi.

jeremymeng commented 1 day ago

Looks that the SDK already maps ResourceUrl to resourceUri https://github.com/Azure/azure-sdk-for-js/blob/917b1a3f54759afd05f005fb6c106f76ce75f321/sdk/search/search-documents/src/generated/service/models/mappers.ts#L3200-L3207

maybe the issue is something else /cc @dgetu