我们如何使用ARM模板在Function App中添加新的主机密钥

时间:2019-08-21 08:57:55

标签: arm-template azure-automation

需要添加什么应用程序设置属性,以便使用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]"
            }
   ]

1 个答案:

答案 0 :(得分:0)

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

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

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

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

更多文档-Github