azure.search.documents.indexes.models.AIServicesVisionVectorizer used in AI Search throws "Could not complete vectorization action. The vectorization endpoint returned status code '400' (BadRequest)"
Hi!
I'm facing an issue with using AIServicesVisionVectorizer vectorizer when doing either a text or image vector query search against the AI Search index.
I used azure-python-sdk library azure-search-documents 11.6.0b9 version.
This is the sample code used to create the index:
azure_vision_endpoint = os.getenv("AZURE_VISION_ENDPOINT")
azure_vision_key = os.getenv("AZURE_VISION_KEY")
...
AIServicesVisionVectorizer(
vectorizer_name="myImageVectorizer",
kind="aiServicesVision",
ai_services_vision_parameters=AIServicesVisionParameters(
model_version="latest",
resource_uri=azure_vision_endpoint,
api_key=azure_vision_key
)
)
Generated index JSON definition:
"vectorizers": [
...,
{
"name": "myImageVectorizer",
"kind": "aiServicesVision",
"aiServicesVisionParameters": {
"modelVersion": "latest",
"apiKey": "<redacted>",
"resourceUri": "https://not-the-real-used-uri.cognitiveservices.azure.com"
}
}
]
Related documentation: https://learn.microsoft.com/en-us/azure/search/vector-search-vectorizer-ai-services-vision
The search client returns:
Response status: '502'
Response headers:
'Cache-Control': 'no-cache,no-store'
Response content:
{"error":{"code":"","message":"Could not complete vectorization action. The vectorization endpoint returned status code '400' (BadRequest)."}}
I tried different variations for the apiKey, modelVersion, resourceURI with no success, both from python code or directly editing the index's JSON definition.
Same error is received directly from the Portal, from the Search explorer.
Using the same apiKey, modelVersion, resourceURI I managed to obtain the vectors/embeddings with a direct HTTP POST call:
- https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/image-retrieval?tabs=python
- https://learn.microsoft.com/en-us/rest/api/computervision/image-retrieval/vectorize-image?view=rest-computervision-v4.0-preview%20(2023-04-01)&tabs=HTTP
Also, I managed to obtain an image analysis using the same apiKey, modelVersion, resourceURI with the help of: https://learn.microsoft.com/en-us/python/api/overview/azure/ai-vision-imageanalysis-readme?view=azure-python-preview
I also followed these samples for this test: