首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何通过Python使用Proxy IP连接Cosmos DB

如何通过Python使用Proxy IP连接Cosmos DB
EN

Stack Overflow用户
提问于 2021-02-27 08:02:07
回答 1查看 325关注 0票数 0

我正在尝试连接到Cosmos DB使用python使用以下代理主机和端口。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代码:

代码语言:javascript
运行
复制
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)

例外:

代码语言:javascript
运行
复制
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.
EN

回答 1

Stack Overflow用户

发布于 2021-03-01 14:38:58

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

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

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66394280

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档