简体   繁体   English

无法从ARM模板中的存储资源获取Azure存储密钥

[英]Unable to get Azure storage key from storage resource in ARM template

I'm trying to build a connection string from a storage account used elsewhere in the template and I have 我正在尝试从模板中其他地方使用的存储帐户构建连接字符串,我有

"StorageConnectionString": {
               "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',
 variables('storageName'),';AccountKey=',
 listKeys(resourceId('Microsoft.Storage/storageAccounts',
 variables('storageName')), providers('Microsoft.Storage',
 'storageAccounts').apiVersions[0]).key1)]",
              "type": "Custom"
             },

Which I found from ARM - How can I get the access key from a storage account to use in AppSettings later in the template? ARM找到的内容-如何从存储帐户中获取访问密钥,以便稍后在模板的AppSettings中使用? however the syntax in that question no longer appears to work. 但是,该问题中的语法似乎不再起作用。 I get an error that key1 is not a property which is known. 我收到一个错误消息,即key1不是已知的属性。 Apparently there is a property called keys but that is, as one might expect, a structure of some sort. 显然有一个称为keys的属性,但正如人们所期望的那样,它是某种结构。 I have been unable to figure out what the property of the primary key is from that structure. 我无法从该结构中找出主键的属性。 I've tried 我试过了

  • key1 -> Template language expression property 'key1' doesn't exist, available properties are 'keys key1->模板语言表达式属性'key1'不存在,可用属性为'keys
  • keys -> The provided parameters for template language function 'concat' are invalid. 键->模板语言功能“ concat”提供的参数无效。 Either all or none of the parameters must be an array. 所有参数或全部参数都不能为数组。
  • keys.key1 keys.key1
  • keys.primaryKey keys.primaryKey
  • keys[0] 键[0]

All of which have failed. 所有这些都失败了。 I tried putting an output at the end of the file but outputting keys just seems to output no value. 我尝试将output放在文件末尾,但输出键似乎没有任何输出。

As it turns out the structure of the object returned from listKeys is an array of keys which looks like 事实证明,从listKeys返回的对象的结构是一个键数组,看起来像

[
  { "keyName":"key1", "permissions":"Full", "value":"keyvalue1"},
  { "keyName":"key2", "permissions":"Full", "value":"keyvalue2"}
]

So the correct solution to getting the value out was to do keys[0].value . 因此,获取值的正确解决方案是执行keys[0].value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure ARM模板访问存储密钥 - Azure ARM template accessing storage key 如何从Azure存储中部署Arm模板? - How to deploy an arm template from Azure storage? 在ARM模板中动态检索Azure存储帐户密钥 - Dynamically retrieving azure storage account key in ARM template 是否可以从ARM模板创建azure函数,并使其从存储在azure存储器中的zip文件中获取代码? - is it possible to create azure function from ARM template and let it get the code from zip file stored in azure storage? ARM 模板:如何从不同的资源组创建到存储的连接? - ARM Template: How to create connection to storage from different resource group? 无法使用Azure Fluent获取存储帐户密钥 - Unable to get storage account key with Azure Fluent 使用 ARM 模板创建 Azure 存储队列 - Create Azure Storage Queue using ARM template 在 ARM 模板中获取 Azure 存储 dacpac 文件 - Fetch Azure storage dacpac file in ARM Template 使用Azure资源管理器模板从存储中复制文件? - Copy a file from storage using Azure Resource Manager Template? 从Azure本地存储资源将私钥文件添加到Pageant - Add private key file to Pageant from Azure local storage resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM