我正在尝试获取波斯菊数据库的连接字符串。在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:\>

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 | 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:\>

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的数据库帐户。

以下是使用MongoDB数据库帐户的CosmoDB的“列表连接字符串”操作的输出。
powershell - 列出cosmos db的连接字符串不返回任何结果,但列出 key-LMLPHP

关于powershell - 列出cosmos db的连接字符串不返回任何结果,但列出 key ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46105546/

10-15 22:11