我正在尝试获取cosmos db的连接字符串。在powershell中,当我做
Invoke-AzureRmResourceAction -Action listKeys -ResourceType "Microsoft.DocumentDb/databaseAccounts" -ApiVersion "2015-04-08" -ResourceGroupName $ResourceGroupName -Name $dbName | fl
我得到一个显示键的结果。
D:\> Invoke-AzureRmResourceAction -Action listKeys ` >> -ResourceType "Microsoft.DocumentDb/databaseAccounts" ` >> -ApiVersion "2015-04-08" ` >> -ResourceGroupName $ResourceGroupName -Name $dbName | fl Confirm Are 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"): y primaryMasterKey : (snip) secondaryMasterKey : (snip) primaryReadonlyMasterKey : (snip) secondaryReadonlyMasterKey : (snip) D:\>
但是,如果我尝试列出连接字符串like the example in the documentation shows,则无法获得结果
D:\> Invoke-AzureRmResourceAction -Action listConnectionStrings ` >> -ResourceType "Microsoft.DocumentDb/databaseAccounts" ` >> -ApiVersion "2015-04-08" ` >> -ResourceGroupName $ResourceGroupName -Name $dbName | fl Confirm Are 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"): y D:\>
使用资源管理器模板,如果我部署以下资源管理器模板
{
"$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)"
}
}
我做错了什么阻止连接字符串显示?
答案 0 :(得分:2)
Azure Cosmo DB是一种多模型数据库服务。 连接字符串仅适用于使用 MongoDB API的数据库帐户。
对于 MongoDB帐户,连接字符串为 可以检索将您的MongoDB应用程序连接到数据库帐户 使用以下命令。