Unable to retrieve images using ImageSearchClient

ac 1 Reputation point
2020-11-07T15:44:54.53+00:00

My requirement is to get images from the web. What I tried is -

  1. I created a Bing search resource to get keys and endpoint. I now have two keys for the endpoint - https://api.bing.microsoft.com/
  2. Ran the below code in a python notebook. from azure.cognitiveservices.search.imagesearch import ImageSearchClient as api
    from msrest.authentication import CognitiveServicesCredentials as auth key = <value of my key> client = api('https://api.bing.microsoft.com/', auth(key))
    p = client.images.search(query='grizzly bear', count=1, min_height=128, min_width=128)
  3. Last line gives a ErrorResponseException: Operation returned an invalid status code 'Resource Not Found' error.

Please advise.

Bing Image Search
Bing Image Search
A Bing service that supports searching for images and gets comprehensive results.
44 questions
Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
707 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 22,401 Reputation points Microsoft Employee
    2020-11-09T12:00:36.84+00:00

    @ac , Apologies for the delay!

    For Azure cognitive search stand-point, create an instance of CognitiveServicesCredentials, and use it to instantiate the client, this way instead to isolate:

    client = ImageSearchClient(endpoint=subscription_endpoint, credentials=CognitiveServicesCredentials(subscription_key))  
    

    Kindly review for correctness, replace the values with this:
    SUBSCRIPTION_KEY with a valid subscription key.
    YOUR_ENDPOINT with your endpoint url in portal and remove the bing/v7.0 section from the endpoint.

    Also, the Python implementation adds automatically the Bing version, refer to a similar discussion.

    If you're using version 1.2.0 or below for the Bing Image Search client library, use ImageSearchAPI() instead of ImageSearchClient() to initialize your search client.

    We have tagged bing-image, for receiving insights from the right experts.

    0 comments No comments