在 Databricks 中创建认知搜索索引:connection.HTTPSConnection 无法建立新连接:[Errno -2] 名称或服务未知

Creating Cognitive Search index in Databricks: connection.HTTPSConnection Failed to establish a new connection: [Errno -2] Name or service not known

我正在尝试在 Databricks 中创建认知搜索索引。我使用以下内容作为指导:

https://docs.microsoft.com/en-us/azure/search/search-get-started-python

当我执行以下代码时出现错误:

<urllib3.connection.HTTPSConnection object at 0x7fb54030e1c0>: Failed to establish a new connection: [Errno -2] Name or service not known

我觉得这是一个常见的错误,但是我在 Google 搜索时找不到任何解决方案。

Databricks 运行时:9.1 LTS(包括 Apache Spark 3.1.2、Scala 2.12)

我的连接如下:

service_name = "https://myazuredemo.search.windows.net"
admin_key = "xxxxxxxxxxxxxx"

index_name = "hotels-quickstart"

# Create an SDK client
endpoint = "https://{}.search.windows.net/".format(service_name)
admin_client = SearchIndexClient(endpoint=endpoint,
                     index_name=index_name,
                     credential=AzureKeyCredential(admin_key))

search_client = SearchClient(endpoint=endpoint,
                     index_name=index_name,
                     credential=AzureKeyCredential(admin_key))

有什么想法吗?

问题出在这里:

service_name = "https://myazuredemo.search.windows.net"
endpoint = "https://{}.search.windows.net/".format(service_name)

它会给你以下内容 URL:

https://https://myazuredemo.search.windows.net.search.windows.net/

所以要么将 service_name 设置为 myazuredemo,要么只将 endpoint 设置为 https://myazuredemo.search.windows.net