【问题标题】:How to connect to Cosmos DB using Proxy IP using Python如何使用 Python 使用代理 IP 连接到 Cosmos DB
【发布时间】:2021-02-27 00:02:07
【问题描述】:

我正在尝试使用以下代理主机和端口使用 python 连接到 Cosmos DB。 Cosmos DB 配置为接受 ip = 100.100.10.0/25

但是,好像连不上。

例外说-azure.cosmos.exceptions.CosmosHttpResponseError: (Forbidden) Request originated from client IP 198.110.10.10 through public internet. This is blocked by your Cosmos DB account firewall settings.

Python 代码:

from azure.cosmos import CosmosClient, exceptions, ProxyConfiguration

url = 'XXXX'
key = 'XXXX'

d = ProxyConfiguration()
d.Host = '100.100.10.0'
d.Port = 25
client = CosmosClient(url, credential=key, proxy_config=d)

database_name = 'testDatabase'
try:
    database = client.create_database(database_name)
except exceptions.CosmosResourceExistsError:
    database = client.get_database_client(database_name)

例外:

File "C:\Users\AppData\Roaming\Python\Python37\site-packages\azure\cosmos\_synchronized_request.py", line 158, in _Request
raise exceptions.CosmosHttpResponseError(message=data, response=response)
    azure.cosmos.exceptions.CosmosHttpResponseError: (Forbidden) Request originated from client IP 198.110.10.10 through public internet. This is blocked by your Cosmos DB account firewall settings.

【问题讨论】:

    标签: python authentication proxy azure-cosmosdb


    【解决方案1】:

    您的代码是正确的,但您需要将代理主机添加到 Cosmos DB 中的防火墙。

    顺便说一句,防火墙更改最多可能需要 15 分钟。

    参考:https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-configure-firewall

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-21
      • 2019-03-30
      • 2021-10-03
      • 2019-11-25
      • 2019-04-30
      • 2020-03-16
      • 2021-11-27
      • 1970-01-01
      相关资源
      最近更新 更多