azure - 如何使用从链接的 ARM 模板返回的 secureObject 或 securestring

标签 azure azure-rm-template securestring

如何使用从链接的 ARM 模板返回的 securestringsecureObject 的值?

例如,一个名为 CreateStorage 的子链接模板

  1. 创建 Azure 存储帐户
  2. 在该帐户上创建 Blob 容器
  3. 为容器创建 SAS key
  4. 返回模板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 中以纯文本形式显示。

但是,当我将返回对象的类型更改为 securestringsecureObject 时,当调用 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 模板返回 securestringsecureObject 时,.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.

并且 securestringsecureObject 作为模板输入参数都工作正常,所以我一定做错了什么。

如何使用从链接的 ARM 模板返回的 securestringsecureObject 的值?

最佳答案

输入\输出中省略 secureString\secureObject 类型。你无法“得到”它们。他们只是被传递了,仅此而已。这就是为什么它们被称为安全。它们没有被记录在任何地方。没有真正的解决方法。

在您的情况下,您只需在需要的地方拉出键,不必将它们拉入嵌套模板并将它们传递给父模板。

关于azure - 如何使用从链接的 ARM 模板返回的 secureObject 或 securestring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54435900/

相关文章:

c# - Azure 移动应用程序参与 Xamarin 身份验证

在同一区域具有多个 Web 应用程序的 Azure 流量管理器

azure - 是否应将 Azure ServiceConfiguration.Cloud.cscfg checkin 源代码管理?

azure - API管理ARM模板创建

.net - 如何使用DPAPI加密SecureString以保存到磁盘,而无需先转换为不安全的字符串?

Powershell - 使 SecureString 可供其他用户使用

azure - 如何强制对 Azure 服务总线队列或主题中的消息进行排序?

azure - 由于部署槽类型,ARM 模板验证失败

azure - 将 ARM 模板部署到 Azure 时出错