Azure Schema 注册表客户端库 python 不工作 - 无法建立新连接:[Errno 11001] getaddrinfo 失败

Azure Schema Registry client library python not working - Failed to establish a new connection: [Errno 11001] getaddrinfo failed

我正在尝试将 Schema Registry 与 Azure EventHubs 结合使用 guide。我无法使本指南发挥作用,也不清楚我应该使用哪个架构注册表端点。有人可以帮我解决这个问题吗?

信息:

脚本

import os
import sys
import logging
from azure.eventhub import EventHubProducerClient, EventData
from azure.schemaregistry import SchemaRegistryClient
from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer
from azure.identity import DefaultAzureCredential

# Create a logger for the SDK
logger = logging.getLogger('azure.schemaregistry')
logger.setLevel(logging.DEBUG)

# Configure a console output
handler = logging.StreamHandler(stream=sys.stdout)
logger.addHandler(handler)


os.environ['AZURE_TENANT_ID'] = "xxx"
os.environ['AZURE_CLIENT_ID'] = "xxx"
os.environ['AZURE_CLIENT_SECRET'] = "xxx"

credential = DefaultAzureCredential()

endpoint= "Endpoint=sb://xxx.servicebus.windows.net/"

schema_registry_client = SchemaRegistryClient(endpoint, credential, logging_enable=True, logger=logger)



schema_string = """
{"namespace": "example.avro",
 "type": "record",
 "name": "User",
 "fields": [
     {"name": "name", "type": "string"},
     {"name": "favorite_number",  "type": ["int", "null"]},
     {"name": "favorite_color", "type": ["string", "null"]}
 ]
}"""


schema_registry_client.register_schema("schema-test-group","schema-test-test","avro",schema_string)

错误

azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPSConnection object at 0x000001CAE9D1CF70>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

日志

Request URL: 'https://Endpoint=sb://xxx.servicebus.windows.net/$schemagroups/schema-test-group/schemas/schema-test?api-version=REDACTED'
Request method: 'PUT'
Request headers:
    'X-Schema-Type': 'REDACTED'
    'Content-Type': 'application/json'
    'Accept': 'application/json'
    'Content-Length': '298'
    'x-ms-client-request-id': 'xxx'
    'User-Agent': 'azsdk-python-azureschemaregistry/1.0.0b1 Python/3.9.2 (Windows-10-10.0.19041-SP0)'
    'Authorization': 'REDACTED'
A body is sent with the request

连接字符串的格式应为xxx.servicebus.windows.net

架构应如下所示

"""{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}"""

(无\n等字符)

检查这个 github 问题: https://github.com/Azure/azure-sdk-for-python/issues/18219