Skip to content

Detect host id from function runtime environment#82

Merged
danielmarbach merged 11 commits intomainfrom
host-id
May 5, 2026
Merged

Detect host id from function runtime environment#82
danielmarbach merged 11 commits intomainfrom
host-id

Conversation

@andreasohlund
Copy link
Copy Markdown
Member

@andreasohlund andreasohlund commented Apr 29, 2026

This PR makes sure that the endpoint instances are uniquely identified as functions are scaled up or down.

The logic falls back to CONTAINER_NAME when running in Azure container apps and Environment.MachineName for local development.

NOTE: This is different from the existing worker package, which uses ENDPOINT_NAME. The reason for this was likely that ServicePulse at that time didn't have the "Do not track instances" feature yet, and we wanted a way to not continuously add instances in ServicePulse. This will be pointed out in the migration guide.

Design decisions

Align with endpoint instance concept

In order to align with the definition of endpoint instance, which states

Each endpoint has at least one endpoint instance. Additional endpoint instances may be added to scale-out the endpoint.

and also the documentation for heartbeats in ServicePulse, which states

Do Not Track Instances is the best setting for endpoints that are hosted in infrastructure with autoscalers. For example, Kubernetes, Azure Container Apps and AWS Elastic Container Service. Historical instances are not tracked, and only currently alive instances will be shown. The endpoint will be marked as unhealthy if there are no alive instances, and will be automatically removed after 6 hours of inactivity.

Each scaled-out function instance should be uniquely identified.

@andreasohlund andreasohlund changed the title Spike host and instance id Detect host id from function runtime environment Apr 29, 2026
Comment thread src/NServiceBus.AzureFunctions.Common/FunctionEndpointConfigurationBuilder.cs Outdated
@andreasohlund andreasohlund marked this pull request as ready for review May 2, 2026 05:37
@andreasohlund andreasohlund requested a review from DavidBoike May 2, 2026 05:38
@andreasohlund andreasohlund requested a review from mattmercurio May 2, 2026 05:38
@danielmarbach
Copy link
Copy Markdown
Contributor

Discussed it with @andreasohlund and after talking it through with @bording too we think going with calling AppContext directly

@andreasohlund andreasohlund marked this pull request as draft May 5, 2026 06:31
@andreasohlund andreasohlund marked this pull request as ready for review May 5, 2026 07:12
@andreasohlund
Copy link
Copy Markdown
Member Author

@danielmarbach app switch now set in code, ready for review

@danielmarbach danielmarbach merged commit 1140893 into main May 5, 2026
5 of 6 checks passed
@danielmarbach danielmarbach deleted the host-id branch May 5, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants