Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Debug and troubleshoot Azure Container Apps and Function Apps using logs, KQL, and health checks.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
troubleshooting/messaging/azure-eventhubs-dotnet.md
1# Azure Event Hubs SDK — .NET (C#)23Package: `Azure.Messaging.EventHubs` | [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Azure.Messaging.EventHubs/) | [Full Troubleshooting Guide](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Azure.Messaging.EventHubs/TROUBLESHOOTING.md)45## Common Errors67| Exception | Reason | Fix |8|-----------|--------|-----|9| `EventHubsException` (ServiceTimeout) | Service didn't respond in time | Transient — retried automatically. Verify state if persists |10| `EventHubsException` (QuotaExceeded) | Too many active readers per consumer group | Reduce concurrent receivers or upgrade tier |11| `EventHubsException` (ConsumerDisconnected) | Higher priority consumer took ownership | Expected during load balancing; check if scaling |12| `EventHubsException` (MessageSizeExceeded) | Event too large | Reduce event payload; unlikely in practice since the client caps at the service link limit |13| `UnauthorizedAccessException` | Bad credentials | Verify connection string, SAS token, or RBAC roles |1415## Exception Filtering1617```csharp18try { /* receive events */ }19catch (EventHubsException ex) when (ex.Reason == EventHubsException.FailureReason.ConsumerDisconnected)20{21// Handle consumer disconnection22}23```2425## Retry Configuration2627Configure via `EventHubsRetryOptions` when creating the client. See [Configuring retry thresholds sample](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Azure.Messaging.EventHubs/samples).2829## Key Issues3031- **Socket exhaustion**: Treat clients as singletons. Share `EventHubConnection` across clients if needed. Always call `CloseAsync` or `DisposeAsync`.32- **HTTP 412/409 from storage**: Normal during checkpoint store operations — not an error.33- **Partitions closing frequently**: Expected when scaling. If persists >5 min without scaling, investigate. See [Troubleshooting Guide](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Azure.Messaging.EventHubs/TROUBLESHOOTING.md) for detailed diagnostics.34- **High CPU**: Limit to 1.5–3 partitions per CPU core and test at scale thoroughly if above that threshold.35- **Azure Functions**: After upgrading to v5.0+ extensions, update binding types. Reduce logging noise by filtering `Azure.Messaging.EventHubs` to Warning.36- **WebSockets**: Use `EventHubsTransportType.AmqpWebSockets` to connect over port 443 when AMQP ports (5761, 5762) are blocked.3738## Checkpointing (BlobCheckpointStore)3940Package: `Azure.Messaging.EventHubs.Processor` (includes `EventProcessorClient` + blob checkpoint store)4142> **Auth:** `DefaultAzureCredential` is for local development. See [auth-best-practices.md](auth-best-practices.md) for production patterns.4344```csharp45var credential = new DefaultAzureCredential();4647var storageClient = new BlobContainerClient(48new Uri("https://<storage-account>.blob.core.windows.net/<checkpoint-container>"),49credential);5051var processor = new EventProcessorClient(52storageClient,53"$Default",54"<your-namespace>.servicebus.windows.net",55"<your-eventhub>",56credential);5758processor.ProcessEventAsync += async (args) =>59{60// process event61await args.UpdateCheckpointAsync();62};63```6465**Common issues:**66- **Soft delete / blob versioning**: Disable both on the storage account — they cause delays during load balancing.67- **HTTP 412/409 from storage**: Normal during partition ownership negotiation; not an error.68- **Checkpoint frequency**: Call `UpdateCheckpointAsync()` per batch, not per event, to reduce storage calls.69