Azure / Azure/azure-functions-host

Slot Swap Feature - Send signal to function extension on hostname/routing swap completes.

Open
#9,908 0 comments 1 reaction 0 assignees View on GitHub
area: azure-logic-apps enhancement needs-discussion
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

#### What problem would the feature you're requesting solve? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Azure Logic Apps is introducing zero downtime deployment by taking advantage of slot support in Azure Functions. Our workers depend on hostname and are initialized/registered during extension startup. During a swap, hostname/routing is updated after startup under the covers without recycling the app. The issue is once swap is complete, our workers reference the non-production hostname in a production slot.

At startup, we get the endpoint by calling `context.GetWebhookHandler()`, see code in Repo: [WorkflowExtensionProvider.cs](https://msazure.visualstudio.com/One/_git/AzureUX-BPM?path=/src/functionExtensions/Flow.WebJobs.Extensions/Startup/WorkflowExtensionProvider.cs&version=GBmaster&_a=contents)

`WorkflowExtensionProvider` initialize classes that are used to build URLs displayed in the portal but also in other components, such as webhook and HTTP triggers, callback URLs and inputs/outputs URLs

An example of the issue is that in the portal, the end-user will see the staging hostname in production slot. Below is one example.

![image](https://github.com/Azure/azure-functions-host/assets/10816194/c7f125be-a7ac-46f9-9c7b-c3b64059e412)

#### Describe the solution you'd like
A clear and concise description of what you want to happen.

The ideal solution is for Azure Logic Apps to subscribe or depend on a signal from host runtime when hostname/routing is updated during a swap. This ask will allow us to delay worker initialization/registration until hostname is updated. In addition, it would be helpful to know that the startup was triggered by a swap. This will help us to differentiate between, normal app recycle, and swap app recycle.

#### Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

We looked into synching the hostname after startup, however, there is no reliable path to perform the synch at the "right time". The solution/workaround implemented in [HostNameProvider.cs](https://github.com/Azure/azure-functions-host/blob/c64e6c4ec447fdc091426576ed60c4e8f2f0cd44/src/WebJobs.Script/HostNameProvider.cs) is not a viable solution/workaround for us.

#### Additional context
Add any other context or screenshots about the feature request here.

Below is a screenshot of environment variables available at swap restart.

![image](https://github.com/Azure/azure-functions-host/assets/10816194/3308c847-f4c7-40d0-aa0d-ac4b803bd8ce)

Contributor guide

Open the contributing guide

Research direction

Start by reading HostNameProvider.cs in the referenced azure-functions-host revision and WorkflowExtensionProvider.cs in the AzureUX-BPM repository to understand current hostname resolution and worker initialization. Define the runtime signal and its swap-specific context, then verify that consumers can delay registration until hostname/routing updates complete without affecting normal app recycling.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.