gpt4 book ai didi

azure - 在 Azure 中获取 CosmosDB 的连接字符串时出现问题

转载 作者:行者123 更新时间:2023-12-02 06:18:40 26 4
gpt4 key购买 nike

我正在遵循这个例子: https://github.com/Azure-Samples/java-functions-eventhub-cosmosdb

但是当我尝试使用 Azure CLI 获取连接字符串时,收到以下错误:

COSMOS_DB_CONNECTION_STRING=$( \
az cosmosdb keys list \
--resource-group $RESOURCE_GROUP \
--name $COSMOS_DB_ACCOUNT \
--type connection-strings \
--query connectionStrings[0].connectionString \
--output tsv)

来自 az 的错误消息:

no matches found: connectionStrings[0].connectionString

有什么帮助吗?

提前非常感谢

az --version
azure-cli 2.2.0

command-modules-nspkg 2.0.3
core 2.2.0
nspkg 3.0.4
telemetry 1.0.4

Extensions:
azure-cli-iot-ext 0.8.9
application-insights 0.1.4

Python location '/usr/local/Cellar/azure-cli/2.2.0_1/libexec/bin/python'
Extensions directory '/Users/juan.brena/.azure/cliextensions'

Python (Darwin) 3.8.2 (default, Mar 11 2020, 00:29:50)
[Clang 11.0.0 (clang-1100.0.33.17)]

Legal docs and information: aka.ms/AzureCliLegal



Your CLI is up-to-date.

显示当前连接字符串的示例:

az cosmosdb keys list \                              
--resource-group $RESOURCE_GROUP \
--name $COSMOS_DB_ACCOUNT \
--type connection-strings

输出:

{
"connectionStrings": [
{
"connectionString": "AccountEndpoint=xxx",
"description": "Primary SQL Connection String"
},
{
"connectionString": "AccountEndpoint=xxx",
"description": "Secondary SQL Connection String"
},
{
"connectionString": "AccountEndpoint=xxx",
"description": "Primary Read-Only SQL Connection String"
},
{
"connectionString": "AccountEndpoint=xxx",
"description": "Secondary Read-Only SQL Connection String"
}
]
}

这个想法是获取第一个连接字符串:

{
"connectionString": "AccountEndpoint=xxx",
"description": "Primary SQL Connection String"
}

最佳答案

试试这个。

RESOURCE_GROUP='myResourceGroup'
COSMOS_DB_ACCOUNT='my-cosmos-account'

COSMOS_DB_CONNECTION_STRING=$(az cosmosdb keys list \
-g $RESOURCE_GROUP \
-n $COSMOS_DB_ACCOUNT \
--type connection-strings \
--query connectionStrings[0].connectionString \
--output tsv)

echo $COSMOS_DB_CONNECTION_STRING

关于azure - 在 Azure 中获取 CosmosDB 的连接字符串时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60833940/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com