gpt4 book ai didi

Azure Function 在部署后偶尔仍运行旧代码

转载 作者:行者123 更新时间:2023-12-03 02:39:01 25 4
gpt4 key购买 nike

有时,在将最新位部署到 azure 函数后,它仍然运行该函数的旧版本。以下是 .NET core azure 函数和部署代码的构建。关于造成这种情况的原因的想法。部署过程中没有出现任何故障,只是偶尔发生。我尝试为 azure 功能添加重新启动步骤,但无济于事。作为临时解决方案,我完全删除了 azure 函数并在构建过程中重新创建它,但这不太理想。

//ARM 函数

    {
"apiVersion": "2015-08-01",
"type": "Microsoft.Web/sites",
"name": "[variables('functionAppName')]",
"location": "[parameters('location')]",
"kind": "functionapp",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_calculationartifacts_name'))]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "AzureWebJobsDashboard",
"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": "~3"
},
{
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "~10"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components/', variables('applicationInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "[variables('functionWorkerRuntime')]"
},
{
"name": "WEBSITE_ENABLE_SYNC_UPDATE_SITE",
"value": "true",
"slotSetting": false
}
]
}
}
}

//yaml 构建步骤

- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: 'build'
projects: |
**/$(myProject).csproj
arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release

//yaml 部署步骤

      - task: AzureFunctionApp@1
displayName: 'Azure functions app deploy'
inputs:
azureSubscription: '$(azureSubscription)'
appType: functionApp
appName: $(myAppName)
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

最佳答案

可能是您的函数长时间运行。对该函数的调用将运行调用该函数时可用的代码版本。

场景1:

  • T0:有电话进来,函数的 V1 开始运行
  • T1:功能 V2 已部署
  • T2:使用函数的 V1 完成调用

场景 2:

  • T0:函数的 V1 正在运行
  • T1:开始部署 V2
  • T2:调用进来,因为 V2 部署尚未完成,V1 响应

如果该函数在部署几分钟后仍然以 V1 响应,则说明存在其他问题。

关于Azure Function 在部署后偶尔仍运行旧代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62104578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com