下面是我代码:
endpoint = os.environ["https://davidjohns.documents.azure.com/"]
DATABASE_NAME = "cosmicworks"
CONTAINER_NAME = "products"
credential = DefaultAzureCredential()
client = CosmosClient(url=endpoint, credential=credential)
下面是我收到的错误:
endpoint = os.environ["https://davidjohns.documents.azure.com/"]
File "/Users/davidjohns/opt/miniconda3/lib/python3.9/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'https://davidjohns.documents.azure.com/'
谢谢你的帮忙!
1条答案
按热度按时间wwwo4jvm1#
最初我尝试相同的代码,并得到相同的错误:
上述错误表明在环境变量中未找到**
COSMOS_ENDPOINT
**。要设置环境变量,可在终端中使用以下命令:
我使用示例代码创建了带有环境变量的容器。