gpt4 book ai didi

powershell - 列出 cosmos 数据库的连接字符串不会返回结果,但列出键可以工作

转载 作者:行者123 更新时间:2023-12-03 01:07:20 24 4
gpt4 key购买 nike

我正在尝试获取 Cosmos 数据库的连接字符串。当我这样做时在 powershell 中

Invoke-AzureRmResourceAction -Action listKeys -ResourceType "Microsoft.DocumentDb/databaseAccounts" -ApiVersion "2015-04-08" -ResourceGroupName $ResourceGroupName -Name $dbName | fl

我得到显示 key 的结果。

D:\> Invoke-AzureRmResourceAction -Action listKeys `>>                                -ResourceType "Microsoft.DocumentDb/databaseAccounts" `>>                                -ApiVersion "2015-04-08" `>>                                -ResourceGroupName $ResourceGroupName -Name $dbName | flConfirmAre you sure you want to invoke the 'listKeys' action on the following resource:/subscriptions/(snip)/resourceGroups/example/providers/Microsoft.DocumentDb/databaseAccounts/myExampleDb[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): yprimaryMasterKey           : (snip)secondaryMasterKey         : (snip)primaryReadonlyMasterKey   : (snip)secondaryReadonlyMasterKey : (snip)D:\>

However if I try to list the connection strings, like the example in the documentation shows, I get no results

D:\> Invoke-AzureRmResourceAction -Action listConnectionStrings `>>                                -ResourceType "Microsoft.DocumentDb/databaseAccounts" `>>                                -ApiVersion "2015-04-08" `>>                                -ResourceGroupName $ResourceGroupName -Name $dbName | flConfirmAre you sure you want to invoke the 'listConnectionStrings' action on the following resource:/subscriptions/(snip)/resourceGroups/example/providers/Microsoft.DocumentDb/databaseAccounts/myExampleDb[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): yD:\>

With a resource manager template, if I deploy the following resource manager template

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dbName": {
"type": "string"
}
},
"resources": [
],
"outputs": {
"listConnectionStrings": {
"type": "object",
"value": "[listConnectionStrings(resourceid('Microsoft.DocumentDB/databaseAccounts', parameters('dbName')), '2016-03-19')]"
},
"listkeys": {
"type": "object",
"value": "[listKeys(resourceid('Microsoft.DocumentDB/databaseAccounts', parameters('dbName')), '2016-03-19')]"
}
}
}

我从输出中回来

{
"listConnectionStrings": {
},
"listkeys": {
"primaryMasterKey": "(snip)",
"secondaryMasterKey": "(snip)",
"primaryReadonlyMasterKey": "(snip)",
"secondaryReadonlyMasterKey": "(snip)"
}
}

我做错了什么导致连接字符串无法显示?

最佳答案

Azure Cosmo DB 是一种多模型数据库服务。连接字符串仅适用于使用 MongoDB API 的数据库帐户。

List Connection Strings

For MongoDB accounts, the connection string toconnect your MongoDB app to the database account can be retrievedusing the following command.

下面是使用 MongoDB 数据库帐户对 CosmoDB 执行“列出连接字符串”操作的输出。 enter image description here

关于powershell - 列出 cosmos 数据库的连接字符串不会返回结果,但列出键可以工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46105546/

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