非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

huangapple go评论61阅读模式
英文:

Very slow to deploy after updating WEBSITE_RUN_FROM_PACKAGE

问题

To deploy my Azure Function, I follow what seems to be the best practice right now from Microsoft. I upload a zip file to blob storage with the code and then I update the WEBSITE_RUN_FROM_PACKAGE setting on the Azure Function (on a deployment slot, to be specific).

Then, after some time, the latest version is deployed. I can confirm this by querying a version number on the API.

This all works!

However, sometimes it takes a long time. In my most recent try, it took more than 7 minutes. This is not a very large package (7 MB) with about 100 Function endpoints. Much of the time it takes about 2 minutes, but sometimes it takes much longer.

It is my feeling that it takes a LONG time about 1 out of 3 times. And then a short time (2 minutes) about 2 of 3 times.

Does anyone know why it doesn't work well much of the time? And/or has any idea how I can troubleshoot this? I don't know where or if I can access any log about how the function discovers the new package file and what it is waiting for.

--

Edit: I found this in the deployment log through CLI.

{
"active": true,
"author": "N/A",
"author_email": "N/A",
"complete": true,
"deployer": "Push-Deployer",
"end_time": "2023-05-20T13:51:52.9356458Z",
"id": "89feddbf-c575-4d32-b795-d3d6111ecee5",
"is_readonly": true,
"is_temp": false,
"last_success_end_time": "2023-05-20T13:51:52.9356458Z",
"log_url": "https://appname-slotname.scm.azurewebsites.net/api/deployments/8feddbf-c575-4d32-b795-d3d6111ecee5/log",
"message": "Created via a push deployment",
"progress": "",
"received_time": "2023-05-20T13:51:31.0878136Z",
"site_name": "appname",
"start_time": "2023-05-20T13:51:32.9850841Z",
"status": 4,
"status_text": "",
"url": "https://appname-slotname.scm.azurewebsites.net/api/deployments/8feddbf-c575-4d32-b795-d3d6111ecee5"
}

I am guessing that "active" means this deployment is currently the one running on the deployment slot. And that fits because my new deployments, which are taking a long time, do not show up here until maybe shortly before they are actually completed.

I have tried manually restarting the deployment slot and manually saving the app settings with no difference.

英文:

To deploy my Azure Function I follow what seems to be the best practice right now from Microsoft. I upload a zip file to blob storage with the code and then I update the WEBSITE_RUN_FROM_PACKAGE setting on the Azure Function (on a deployment slot, to be specific)

Then, after some time, the latest version is deployed. I can confirm this by querying a version number on the API.

This all works!

However, some times it takes a long time. In my most recent try, it took more than 7 minutes. This is not a very large package (7 MB) with about 100 Function endpoints. Much of the time it takes about 2 minutes but some times it takes much longer.

It is my feeling that it takes LONG time about 1 out of 3 times. And then short time (2 minutes) about 2 of 3 times.

Does anyone know why it doesn't work well much of the time? And/or has any idea how I can troubleshoot this. I don't know where or if I can access any log about how the function discovers the new package file and what it is waiting for.

--

Edit: I found this in the deployment log through CLI.

  {
    "active": true,
    "author": "N/A",
    "author_email": "N/A",
    "complete": true,
    "deployer": "Push-Deployer",
    "end_time": "2023-05-20T13:51:52.9356458Z",
    "id": "89feddbf-c575-4d32-b795-d3d6111ecee5",
    "is_readonly": true,
    "is_temp": false,
    "last_success_end_time": "2023-05-20T13:51:52.9356458Z",
    "log_url": "https://appname-slotname.scm.azurewebsites.net/api/deployments/8feddbf-c575-4d32-b795-d3d6111ecee5/log",
    "message": "Created via a push deployment",
    "progress": "",
    "received_time": "2023-05-20T13:51:31.0878136Z",
    "site_name": "appname",
    "start_time": "2023-05-20T13:51:32.9850841Z",
    "status": 4,
    "status_text": "",
    "url": "https://appname-slotname.scm.azurewebsites.net/api/deployments/8feddbf-c575-4d32-b795-d3d6111ecee5"
  }

I am guessing that "active" means this deployment is currently the one running on the deployment slot. And that fits because my new deployments, which are taking a long time, do not show up here until maybe shortly before they are actually completed.

I have tried manually restarting the deployment slot and manually saving the app settings with no difference.

答案1

得分: 1

你说得对,通过包部署函数应用可以加快部署速度。但还有其他几个因素需要考虑。当你将 Zip 文件从 Blob 存储传输到 Azure Functions 时,可能会在 Azure 存储账户和 Azure Functions 资源之间出现一些延迟。

如果你的函数应用有依赖项或一些包,部署这些包可能会有一些延迟,因此确保你的函数依赖包得到了正确管理。

你可以考虑将函数应用升级到高级计划或专用应用服务计划,因为高级函数计划减少了冷启动时间,并始终保持准备就绪的实例,从而使部署和函数运行速度比基于消耗的计划更快。参考下面的信息:

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

除了设置 WEBSITE_RUN_FROM_PACKAGE 为 1,为了提高部署速度,添加以下设置作为最佳实践:

参考:MS Q & A 论坛的 答案 由 MayankBargali-MSFT 提供

SCM_DO_BUILD_DURING_DEPLOYMENT : TRUE

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

我通过以下命令部署了一个函数:

命令 参考

az functionapp deployment source config-zip -g siliconrg54 -n siliconfunc65 --src "<PATH>\repos\FunctionApp7.zip"

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

要查看 Zip 部署的部署日志,请参考以下信息:

访问开发工具 > 高级工具 > 进入 > Kudu 环境将如下所示打开:

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

你可以点击下面的 REST API 部分的链接来获取有关你的部署的见解。

要获取部署日志 > 点击工具 > 诊断转储将下载所有诊断日志,包括部署日志,到本地,参考下面:

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

你可以选择下载的转储 > LogFiles > Monaco > 并获取你的函数的部署时间戳日志,如下所示:

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

在你的 Kudu 工具中,你可以点击工具 > Zip push Deploy 来查看你的 Zip 部署日志,如下所示:

Zip Push 部署 参考

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

你可以参考这个 答案 由 MayankBargali-MSFT 提供的以及这个 Azure Functions 最佳实践

英文:

You're right, Running the Function app deployment from package makes the deployment faster. But there are several other factors, That you should consider. As you are transferring the Zip from your blob storage to Azure Functions, There might be some delay during the transfer, Between Azure storage account and Azure Functions resource.

If your Function app has dependency or some packages there might be some delay in deployment of these packages, Thus make sure you have your function dependent packages managed properly.

You can consider upgrading your Function app to Premium plan or dedicated App service plan as Premium Function plan reduces Cold start and has always ready instances which makes your deployment and Functions running faster than Consumption based plan. Refer below:-

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

Along with WEBSITE_RUN_FROM_PACKAGE setting set to 1, Add the below setting to make your deployment faster as a best practice:-

Reference:- MS Q & A forum answer by MayankBargali-MSFT

> txt
&gt; SCM_DO_BUILD_DURING_DEPLOYMENT : TRUE
&gt;

>
> 非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

I deployed one Function via zip deployment by using the command below:-

Command reference

> bash
&gt; az functionapp deployment source config-zip -g siliconrg54 -n
&gt; siliconfunc65 --src &quot;&lt;PATH&gt;\repos\FunctionApp7.zip&quot;
&gt;

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

In order to view the Deployment logs of your zip deployment Refer below:-

Visit Development tools > Advanced Tools > Go > Kudu environment will open like below:-

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

You can click on the links below REST API sections to get insights on your deployment.

To get the Deployment logs > Click on Tools > Diagnostic dump all the diagnostic logs including Deployment logs will be downloaded locally, Refer below:-

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

You can select the downloaded dump > LogFiles > Monaco > And get the deployment timestamp logs of your Function like below:-

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

In your Kudu tool, You can click on tools > Zip push Deploy to check your zip deployment logs like below:-

> Zip Push Deployment reference

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

非常慢在更新 WEBSITE_RUN_FROM_PACKAGE 后部署

> You can refer this answer by MayankBargali-MSFT and this Azure Functions Best Practices

huangapple
  • 本文由 发表于 2023年5月20日 23:47:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76296061.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定