1
votes

I am trying to use the bing image search SDK, but this tutorial doesn't work for me:

https://docs.microsoft.com/en-us/azure/cognitive-services/bing-image-search/quickstarts/client-libraries?pivots=programming-language-python

from azure.cognitiveservices.search.imagesearch import ImageSearchClient 
from msrest.authentication import CognitiveServicesCredentials

# This is my key generated by azure portal
subscription_key = "XXXXXXXXXXXXXXXXX"
# This is my endpoint generated by azure portal
subscription_endpoint = "https://vadmeggy-image-search.cognitiveservices.azure.com/bing/v7.0"
search_term = "bird"

client = ImageSearchClient(endpoint=subscription_endpoint, credentials=CognitiveServicesCredentials(subscription_key))
image_results = client.images.search(query=search_term)

Exception:

azure.cognitiveservices.search.imagesearch.models._models_py3.ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'

What am i missing? I called the REST API and that worked well with the given subscription key. I can fallback to the REST API if the SDK doesn't work, but maybe somebody can help me.

1

1 Answers

2
votes

The Python implementation adds automatically the Bing version, you need to use

subscription_endpoint = "https://vadmeggy-image-search.cognitiveservices.azure.com"

and all will be well. It seems the documentation and implementation are out of sync.