在 Azure 认知服务上找不到资源

Resource not found on Azure Cognitive Services

我在 the tutorial 1

之后创建了一个 Azure 认知服务资源

然后我创建了环境和运行以下代码(来自tutorial 2):

# Import required modules.
from azure.cognitiveservices.search.websearch import WebSearchAPI
from azure.cognitiveservices.search.websearch.models import SafeSearch
from msrest.authentication import CognitiveServicesCredentials

# Replace with your subscription key.
subscription_key = "YOUR_SUBSCRIPTION_KEY"

# Instantiate the client and replace with your endpoint.
client = WebSearchAPI(CognitiveServicesCredentials(subscription_key), base_url = "YOUR_ENDPOINT")

# Make a request. Replace Yosemite if you'd like.
web_data = client.web.search(query="Yosemite")
print("\r\nSearched for Query# \" Yosemite \"")

但是,生成的 Subscription keyendpoint 似乎没有被脚本正确读取,因为我收到以下错误:

File "azu_scrapper.py", line 17, in web_data = client.web.search(query="Yosemite") File "/home/user/.local/share/virtualenvs/linkedin-CHSAGU1d/lib/python3.7/site-packages/azure/cognitiveservices/search/websearch/operations/web_operations.py", line 365, in search raise models.ErrorResponseException(self._deserialize, response) azure.cognitiveservices.search.websearch.models.error_response_py3.ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'

知道为什么它不起作用吗?

base_url 值应为:

https://<your endpoint>/bing/v7.0

我已经在我这边进行了测试,它对我有用: