Azure / Azure/azure-functions-dotnet-worker
Support for accessing PartitionId in .NET 8 Isolated Worker Azure Function with EventHubTrigger
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
### Description
In the .NET 6 in-process Azure Functions model, we could access the PartitionId of the Event Hub partition using the PartitionContext parameter in the function signature:
`public async Task Run([EventHubTrigger(...)] EventData[] events, ILogger log, PartitionContext partitionContext)`
This was useful for logging, diagnostics, and partition-aware processing.
However, after migrating to the .NET 8 isolated worker model, there is no documented or supported way to access the PartitionId. Attempting to retrieve it from FunctionContext.BindingContext.BindingData returns null, and EventData only exposes PartitionKey, which is not the same.
`var partitionContext = context.BindingContext.BindingData["PartitionContext"] as PartitionContext;//To convert to PartitionContext`
Please provide a way to access the PartitionId in the isolated worker model, either:
By exposing it in BindingData under a known key, or
By extending EventData or providing a new context object similar to PartitionContext.
Describe alternatives you've considered
Logging from the host (not accessible in code)
Embedding partition info in the event payload (not always feasible)
This is a common use case for Event Hub consumers who need partition-level visibility. It would help maintain parity with the in-process model and improve observability in production systems.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the isolated worker EventHubTrigger entry point and how FunctionContext.BindingContext.BindingData is populated, comparing it with the PartitionContext and EventData objects named in the issue. Done means application code can reliably access the Event Hub PartitionId in .NET 8 isolated worker functions through a documented supported API.
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