【问题标题】:How can we add new host key in Function App using ARM-template我们如何使用 ARM 模板在 Function App 中添加新的主机密钥
【发布时间】:2019-12-26 12:24:40
【问题描述】:

需要添加什么应用设置属性,以便使用 ARM 模板生成新的主机密钥

"appSettings": [
            {
              "name": "AzureWebJobsDashboard",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            {
              "name": "AzureWebJobsStorage",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            {
              "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            {
              "name": "WEBSITE_CONTENTSHARE",
              "value": "[toLower(variables('functionAppName'))]"
            },
            {
              "name": "FUNCTIONS_EXTENSION_VERSION",
              "value": "~1"
            },
            {
              "name": "WEBSITE_NODE_DEFAULT_VERSION",
              "value": "6.5.0"
            },
            {
              "name": "ConfigurationStorageAccount",
              "value": "[variables('storageAccountName')]"
            },
            {
              "name": "ConfigurationStorageAccountKey",
              "value": "[listKeys(variables('storageAccountid'),'2015-05-01-preview').key2]"
            }
   ]

【问题讨论】:

  • 我不认为你可以使用 arm 模板旋转键?
  • Akshay 无法从模板中执行此操作。但是我猜模板是通过powershell部署的?它可能来自powershell。如果您需要答案,我可以提供帮助
  • @HariHaran 是的,模板是通过 Powershell 部署的。能否请您告诉我如何使用 PowerShell 进行操作?

标签: arm-template azure-automation


【解决方案1】:

目前无法直接从模板创建密钥。但是您可以使用 Powershell / .NET 创建密钥,无论您使用哪种方式来部署模板。因为KEY MANAGEMENT API 只是 REST。

您可以在 Powershell 脚本中调用以下 API 来添加新密钥:

PUT api/sites/{name}[/slots/{slot}]/host/default/{functionkeys|systemkeys}/{keyName}

{
  "properties": {
    "name":"<keyName>",
    "value":<keyValue>"
   }
}

更多文档 - Github

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 2021-03-17
    • 1970-01-01
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    相关资源
    最近更新 更多