Azure / Azure/azure-functions-host
Slot Swap Feature - Send signal to function extension on hostname/routing swap completes.
- 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.

#### 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.

Contributor 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