使用ARM模板创建密钥保管库证书

时间:2018-04-12 06:22:06

标签: azure azure-resource-manager arm-template

我想创建一个Key Vault,并使用ARM模板为其添加机密和证书。我已经找到了创建密钥保管库以及向其添加秘密的方法,但是找不到任何相关的解决方案,仅使用ARM模板将新的自签名证书添加到密钥保管库。

ARM模板目前是否支持此功能?

4 个答案:

答案 0 :(得分:2)

不,目前不支持此功能。您只能使用ARM模板创建机密。

答案 1 :(得分:1)

我所做的是:

设置一个端点,为每个请求创建一个随机证书: https://management.dotnetdevops.org/providers/DotNetDevOps.AzureTemplates/templates/KeyVault/certificates/demo/parameters?secretName=test&keyVaultName=test

它输出以下内容:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "keyVaultName": {
      "value": "test"
    },
    "secretName": {
      "value": "test"
    },
    "secretValue": {
      "value": "MIIJqgIBAzCCCWYGCSqGSIb3DQEHAaCCCVcEgglTMIIJTzCCBggGCSqGSIb3DQEHAaCCBfkEggX1MIIF8TCCBe0GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAiiGhNFSYqNpQICB9AEggTY7pJkDRCcQeMeS3+fB9Trh+jZ+/f0xdmgc1hzIJUfB6nYZlRV5tkf9kn/lhEiUpunZBRd+vZbWCDUjyVD9tK1tYkTjxfSMrGxTiT+QkP2R3Mx35b02A8ztcCM/KOmZ6HBuDBjsToijp5a9sySf4oCfUvo1bUkvGVYD27s7+X7vanimxad5eqLuXsA7DDPTp2Yfu/bTwf+YK0STk6nPax6jceLq1svoj5SUNxSELjABQ2MIL5ONhcnvVAS9QJiVWl0fSIZoLuUtJz9LOYu1joqxQtRdUNVV4Uzg49ctSdqo0SUyS8g6rsauTTK/70ab+xVkLLUwsFNKfRJEv3M25Y+v7YSzpzXHnEm3W3kxdLdNWnaqhOBpKHR18anqvW5D7wsFNpxBQzMaGiHARoUUSp5vPsu6PUiVO0210HAQnpYDi54HeRj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H6+YiGjKDN/NaGPRK8IbvA2G4JT/pYUV02cpLNZWO2PfvuxWr1QyI2aC+B3Vj2hEaN1GjlwEFMR6dEeLqK+hCfsdrrBsqmxi/xGWIN3HJrUv5F6qg7NguvSmxn+ZGTHepKDIJsxYrHK4ScwFmkEfeUwsPsztmoCWe8VdVehy4uPNDaS0hG5jdkacI3H1dteghVO3Ht8RstEg3VCJtfRfquPKWuYmTcBkTxiI7UC9W088IVwgK4N03umFpPRXlDO4dlEpiMpHN+QUAmZMYQqPMLvUWJr4yxV7i3TQF6ZrzJhdhS/J02qIB/iwTPY1mN4fxlS+075Zj/PIT5o4tKEeE0JFgG7Of1I+anYkIRdqS0Q3Kqy/QwhoI5QQJPZkF0aGN8i//R6xbzB4IfosDTJVY5rLX7qUP9h9y3zX4ZSdrWu7Nf5EP1IGJxO0g60dmV3t6POskIvdaMfQwOzAfMAcGBSsOAwIaBBSzZWE3QMjgdqf16Tqp2in3nqYkKwQUE74Jk2p96H2Uiw8jneKwAwDgzrACAgfQ"
    },
    "certificateThumbprint": {
      "value": "AD99382EECC21A3456FFDD0B10FDB0399C53BF10"
    }
  }
}

这是使用嵌套模板部署的

    {
        "type": "Microsoft.Resources/deployments",
        "name": "CreateCertificate",
        "apiVersion": "2016-09-01",
        "properties": {
            "mode": "Incremental",
            "templateLink": {
                "uri": "[concat('https://management.dotnetdevops.org/providers/DotNetDevOps.AzureTemplates/templates/KeyVault/certificates/demo?secretName=test&keyVaultName=',reference('DeployKeyvault').outputs.keyVaultName.value)]",
                "contentVersion": "1.0.0.0"
            },
            "parametersLink": {
                "uri": "[concat('https://management.dotnetdevops.org/providers/DotNetDevOps.AzureTemplates/templates/KeyVault/certificates/demo/parameters?secretName=test&keyVaultName=',reference('DeployKeyvault').outputs.keyVaultName.value)]",
                "contentVersion": "1.0.0.0"
            }
        }
    },

这在此用例中很好用。

答案 2 :(得分:0)

如前所述,当前不支持此功能。

您可以做的是创建用于导入证书的Powershell脚本。 Import-AzureKeyVaultCertificate一定会帮助您。 只需在Key Vault本身的部署完成后运行脚本,即可导入证书。

希望对您有帮助。

答案 3 :(得分:0)

当前不支持该证书。您只能使用ARM模板创建机密。

您可以在ARM模板中使用自定义PowerShell脚本,从而可以实现正在尝试的一切

https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/deployment-script-template?tabs=CLI