azure - 在ARM模板中动态检索azure存储帐户 key

标签 azure azure-storage azure-management-api azure-rm-template

我正在尝试使用资源管理器模板自动为 Azure 中的存储帐户创建 API 连接。

我正在使用 ARM 中的 listKeys 方法来检索存储帐户的访问 key 。我经历过这个question它对我不起作用。 当我使用模板的 outputs 部分中的方法时,它工作正常并成功检索和显示访问 key 。

“输出”:{ “列表键输出”:{ “类型”:“字符串”, “值”:“[listKeys(resourceId('Microsoft.Storage/storageAccounts',参数('storagename')),提供者('Microsoft.Storage','storageAccounts').apiVersions [0]).keys [0]。值(value)]” } }

但是,当我尝试在连接资源中使用相同的函数(如下所示)时,模板执行时没有任何错误。但从 Azure 门户访问 API 连接时,它显示“参数丢失”。

“参数值”:{ “accesskey”:“[listKeys(resourceId('Microsoft.Storage/storageAccounts',参数('storagename')),提供者('Microsoft.Storage','storageAccounts').apiVersions [0]).keys [0]。值(value)]”, "accountName": "[参数('存储名称')]" }

enter image description here

enter image description here

我在这里遗漏了什么吗?或者“accesskey”属性不接受 listKeys 的输出?

最佳答案

几个月前我有过类似的经历,并通过直接在代码中使用连接字符串,然后将连接字符串传递到连接中来解决它。该值如下所示:

[concat('DefaultEndpointsProtocol=https;AccountName=',  variables('storageConfigs')[0].name,';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts/',  variables('storageConfigs')[0].name), variables('defaultStorageApiVersion')).key1)]

我使用存储配置对象作为输入,因此这就是为什么它看起来像上面一样,您可以将 variables('storageConfigs')[0].name 替换为您在其中使用的任何名称或变量函数你的代码。看起来像上面它可能是 storagename

关于azure - 在ARM模板中动态检索azure存储帐户 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39161680/

相关文章:

azure - 二头肌模板,用户管理身份未添加到应用程序服务槽,没有错误

azure - 使用 Azure API 管理服务,如何在发送到后端 API 之前解析请求属性?

azure - 模糊的 azure 存储帐户名称

azure - 尝试通过 Azure Function 中的 Azure Management Fluent Api 创建 KeyVault 时出现 ArgumentNullException

azure - 如何以编程方式访问 Azure 管理服务 "operations log"?

azure - 我只希望众多消息使用者中的一个能够根据 ID 处理消息,这可以通过 Azure 服务总线实现吗?

Azure 在线 SQL 数据库管理不可用

安卓 | Fresco/FrescoLib + Azure

c# - 确保为特定队列扩展不超过 N 个实例

python - 适用于 Python 的 Azure 网站管理客户端 : how to get web app by ID?