首页 > 解决方案 > Azure Bing 图像搜索客户端抛出未找到资源

问题描述

我正在尝试使用 bing 图片搜索 SDK,但本教程不适用于我:

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)

例外:

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

我错过了什么?我调用了 REST API,它与给定的订阅密钥配合得很好。如果 SDK 不起作用,我可以回退到 REST API,但也许有人可以帮助我。

标签: pythonazurebing-api

解决方案


Python实现自动添加必应版本,需要使用

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

一切都会好起来的。似乎文档和实现不同步。


推荐阅读