Azure Function的ARM模板将忽略preWarmedInstanceCount设置

问题描述

我正在使用Azure powershell脚本将Azure功能部署到Premium Function Plan(Elastic)中:

New-AzResourceGroupDeployment -ResourceGroupName $RESOURCE_GROUP -TemplateFile "function-app.json" -TemplateParameterObject $params -Name $APP_SERVICE_NAME -Mode Incremental  > $null

并且部署会忽略我的 preWarmedInstanceCount 设置。新创建的功能具有始终就绪实例= 0 (请参见屏幕截图)

enter image description here

ARM功能模板:

{
  "apiVersion": "2020-06-01","name": "[parameters('siteName')]","type": "Microsoft.Web/sites","identity": {
    "type": "systemAssigned"
  },"kind": "functionapp","location": "[resourceGroup().location]","properties": {
    "name": "[parameters('siteName')]","serverFarmId": "[resourceId(parameters('appServicePlanRg'),'Microsoft.Web/serverfarms',parameters('appServicePlanName'))]","clientAffinityEnabled": false,"siteConfig": {
      "use32BitWorkerProcess": false,"preWarmedInstanceCount": 2,"appSettings": [
        {
          "name": "FUNCTIONS_EXTENSION_VERSION","value": "~3"
        },{
          "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING","value": "DefaultEndpointsProtocol=https;AccountName=xxx..."
        },{
          "name": "WEBSITE_CONTENTSHARE","value": "asggas"
        }
      ]
    }
  }
}

在我看来,几天前它确实工作正常,我设法通过arm模板设置了该值,现在我只能通过Azure门户对其进行更新。

这是我的托管计划的ARM模板:

{
  "type": "Microsoft.Web/serverfarms","apiVersion": "2018-02-01","name": "[parameters('appServicePlanName')]","properties": {
    "name": "[parameters('appServicePlanName')]","workerSize": "1","numberOfWorkers": "1","maximumElasticWorkerCount": 20
  },"sku": {
    "Tier": "ElasticPremium","Name": "EP2"
  }
}

解决方法

我试图复制该问题,并能够在此处找到问题。

尝试使用“ reservedInstanceCount”代替“ preWarmedInstanceCount”。

您可以从Azure门户本身进行检查。从门户网站更新保留实例数后,您可以导出模板:

enter image description here

然后将您以前的模板与导出的模板进行比较,您将能够看到不同之处。

,

经过一番调查,我来到了“活动日志”屏幕(在门户网站上进行手动更新之后),惊讶于我想要的属性被命名为“ minimumElasticInstanceCount”(在任何一个ARM API版本{{3中都没有记录}})

https://docs.microsoft.com/en-us/azure/templates/microsoft.web/sites

然后,我将此字段添加到我的ARM模板中,目前看来一切都很好。另外,“始终就绪的实例”(minimumElasticInstanceCount)和“预热的实例”(preWarmedInstanceCount)之间的一些解释和区别也发布在此处:Change Log

因此在Azure Portal中,不会显示预热实例设置。而且我正在寻找其他设置。