【发布时间】:2020-03-24 15:18:23
【问题描述】:
我正在按照示例进行操作: https://github.com/Azure-Samples/java-functions-eventhub-cosmosdb
但是当我尝试使用 Azure CLI 获取 connectionString 时,我收到以下错误:
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:
{
"connectionString": "AccountEndpoint=xxx",
"description": "Primary SQL Connection String"
}
【问题讨论】:
-
我能够毫无问题地执行命令。您可以尝试在没有
--query参数的情况下运行您的命令,看看您是否得到任何输出?尝试运行以下命令:az cosmosdb keys list \ --resource-group $RESOURCE_GROUP \ --name $COSMOS_DB_ACCOUNT \ --type connection-strings -
它对我不起作用。您的命令运行良好,但问题出在查询上。
-
你能编辑你的问题并包含输出吗?显然混淆了帐户名称/密钥:)。另外,您使用的是什么版本的 CLI?
-
感谢您分享详细信息。这太奇怪了。我得到了相同的输出,并且查询对我来说很好。
-
我完全同意你的看法,但我在 Azure CLI 安装中没有做任何不同的事情,但我的查询处理器返回了该错误。我明天会尝试重新安装 Azure CLI。
标签: azure azure-cosmosdb azure-cli