[英]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
我试过了
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
。
You should use the listKeys() function 您应该使用listKeys()函数
https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-functions/#listkeys https://azure.microsoft.com/zh-CN/documentation/articles/resource-group-template-functions/#listkeys
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.