如何使用从链接的 ARM 模板返回的 securestring
或 secureObject
的值?
例如,一个名为 CreateStorage
的子链接模板
- 创建 Azure 存储帐户
- 在该帐户上创建 Blob 容器
- 为容器创建 SAS key
- 返回模板
outputs
部分中的SAS key 。
例如在模板输出中返回 SAS:
"outputs": {
"createdContainerSas": {
"type": "string",
"value": "[concat('https://', variables('storageAccountName'), '.blob.core.windows.net/', variables('containerName'), '?', listServiceSas(variables('storageAccountName'), '2018-07-01', variables('importSasInputs')).serviceSasToken)]"
}
}
然后,主模板会将 SAS key 添加到 KeyVault,以便应用程序的其余部分可以使用它。主模板获取值如下:
"value": "[reference('CreateStorage').outputs.createdContainerSas.value]"
问题在于,目前 SAS key 以字符串
形式返回,这意味着它在 Azure 部署 UI 中以纯文本形式显示。
但是,当我将返回对象的类型更改为 securestring
或 secureObject
时,当调用 createdContainerSas.value
时,会出现以下情况遇到错误:
{\r\n \"code\": \"InvalidTemplate\",\r\n \"message\": \"Unable to process template language expressions for resource '/subscriptions/<my-subscription-id>/resourceGroups/<my-resource-group>/providers/Microsoft.Resources/deployments/CreateKeyVault' at line '310' and column '9'. 'The language expression property 'value' doesn't exist, available properties are 'type'.'\"\r\n }
因此,当从子链接的 ARM 模板返回 securestring
或 secureObject
时,.value
属性似乎不存在。
Microsoft 文档位于 https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-templates-outputs说
Output values support the same types as template input parameters.
并且 securestring
和 secureObject
作为模板输入参数都工作正常,所以我一定做错了什么。
如何使用从链接的 ARM 模板返回的 securestring
或 secureObject
的值?
最佳答案
输入\输出中省略 secureString\secureObject 类型。你无法“得到”它们。他们只是被传递了,仅此而已。这就是为什么它们被称为安全
。它们没有被记录在任何地方。没有真正的解决方法。
在您的情况下,您只需在需要的地方拉出键,不必将它们拉入嵌套模板并将它们传递给父模板。
关于azure - 如何使用从链接的 ARM 模板返回的 secureObject 或 securestring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54435900/