Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Function deployments cause brief 503 errors even when auto swap is turned on

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?

like image 831
user246392 Avatar asked Jul 07 '20 02:07

user246392


1 Answers

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.

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:

Traffic redirection is seamless; no requests are dropped because of a swap.

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:

  1. Responses of old code
  2. Responses of new code
  3. 503 errors for ~10 seconds
  4. Request slowdown
  5. Responses of new code

I tried:

  • AppService Plan & Consumption Plan
  • AAR Affinity On/Off
  • Azure Function V2 and V3 runtime

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

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.

like image 90
Alex AIT Avatar answered Sep 22 '22 15:09

Alex AIT