0

您好我想在 ARM 模板中添加应用程序配置只读连接字符串

"appSettingsShared": {
            "value": [
              {
                "name": "RedisCache:ConnectionString",
                "value": "[concat(variables('RedisCacheName'),'.redis.cache.windows.net:6380,abortConnect=false,ssl=true,password=', listKeys(resourceId('Microsoft.Cache/Redis', variables('RedisCacheName')), '2015-08-01').primaryKey)]"
              },
               {
                "name": "AppConfig:ConnectionString",
                "value": "???"
              }
            ]

我知道如何使用 Azure CLI:

az appconfig credential list -g $resourceGroup   -n $appConfigName --query "([?name=='Primary Read Only'].connectionString)[0]" --output tsv

非常感谢任何帮助。

4

1 回答 1

0

您可以使用listkeys模板函数来检索您的 configStore 键和连接字符串。该实现类似于Configuration Stores - List Keys API,它返回类似于以下内容的响应:

{
  "value": [
    {
      "id": "439AD01B4BE67DB1",
      "name": "Primary",
      "value": "000000000000000000000000000000000000000000000000000000",
      "connectionString": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "lastModified": "2018-04-24T16:30:54+00:00",
      "readOnly": false
    },
    {
      "id": "CB45E100456857B9",
      "name": "Secondary",
      "value": "000000000000000000000000000000000000000000000000000000",
      "connectionString": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "lastModified": "2018-04-24T16:30:54+00:00",
      "readOnly": false
    },
    {
      "id": "B3AC55B7E71431A9",
      "name": "Primary Read Only",
      "value": "000000000000000000000000000000000000000000000000000000",
      "connectionString": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "lastModified": "2018-04-24T16:30:54+00:00",
      "readOnly": true
    },
    {
      "id": "E2AF6A9A89DCC177",
      "name": "Secondary Read Only",
      "value": "000000000000000000000000000000000000000000000000000000",
      "connectionString": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "lastModified": "2018-04-24T16:30:54+00:00",
      "readOnly": true
    }
  ]
}

由于您要访问只读连接字符串,您可以在 ARM 模板中访问它,如下所示:

"value": "[listKeys(resourceId('Microsoft.AppConfiguration/configurationStores', variables('configurationStore_name')), '2019-11-01-preview').value[2].connectionString]"

这将为您提供主只读连接字符串。同样,value[3].connectionString将检索辅助只读连接字符串。

于 2021-02-25T14:14:04.627 回答