问题描述
我正在通过 VS 发布窗口将更新部署到我的 Function 应用.我设置了一个启用了自动交换的部署槽.我通过 VS 进行的更新将进入插槽.问题是,在发布成功之后,当我测试我的 API 端点时,我会短暂收到 503 错误.我的印象是自动交换是无缝的,最终用户不会遇到这种中断.我错过了什么吗?如何使我的部署不被用户注意到?
I'm deploying updates to my Function app through the VS publish window. I set up a deployment slot with auto swap turned on. My updates through VS are going to the slot. The problem is, right after the publish is successful and when I test my API endpoints, I briefly receive 503 errors. I was under the impression that auto swap was seamless and end-users would not experience such interruptions. Am I missing something? How can I make my deployments unnoticeable to the users?
推荐答案
切换到 API 管理或流量管理器之类的东西显然是一种选择,但插槽的设计正是为了满足您的需求,它们应该strong> 以您期望的方式工作.
Switching to something like API Management or Traffic Manager is obviously an option, but slots are designed to do exactly what you want, and they should work the way you expect.
我对此进行了一些研究.不幸的是,我可以重现您的问题,这让我很吃惊.在使用带有插槽的 Azure Functions 时,有些事情感觉有点不对劲,所以可能有些奇怪.
I looked into this a bit. Unfortunately, I can reproduce your issue, which suprised me. A few things feel a bit off when using Azure Functions with slots, so maybe there is some weirdness under the covers.
官方文档不然而,提及这件事,恰恰相反:
The official documentation does not mention anything about this however, quite the opposite:
流量重定向是无缝的;没有请求因为交换而被丢弃.
如果函数在交换期间正在运行,则继续执行并将下一个触发器路由到交换的应用程序实例.
If a function is running during a swap, execution continues and the next triggers are routed to the swapped app instance.
您甚至不需要使用自动交换.只需发布到两个插槽并手动交换插槽.观察响应时,可以看到以下模式:
You don't even need to use Auto Swap. Just publish to both slots and swap the slots manually. When observing the responses, the following pattern can be seen:
- 旧代码的响应
- 新代码的响应
- 503 错误大约 10 秒
- 请求减速
- 新代码的响应
我试过了:
- AppService 计划 &消费计划
- AAR 关联打开/关闭
- Azure Function V2 和 V3 运行时
这对我来说似乎是一个错误.我建议您在 Github 上创建一个支持案例和一个问题.如果我在接下来的几天里找到时间,我可能会自己这样做.另请参阅此问题:
This seems like a bug to me. I would suggest you create a support case and maybe an issue at Github. I might do so myself if I find the time in the next few days. See also this Issue:
https://github.com/Azure/Azure-Functions/issues/862
链接的 GitHub 问题以及 medium article 指出您可以将 WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG
设置为 1
,这应该有助于解决 503 错误.这是 AppService 文档.为什么 Azure Functions 没有提到它.
edit: the linked GitHub issue and also the medium article mentioned by Ron point out that you can set WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG
to 1
and this should help with the 503 errors. It is a documented behavior very deep in the AppService docs. Why it is not mentioned for Azure Functions eludes me.
这篇关于即使打开了自动交换,Azure 函数部署也会导致短暂的 503 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!