feat(kafka): add OidcManaged enum value to OAuthBearerMethod#3385
feat(kafka): add OidcManaged enum value to OAuthBearerMethod#3385aaaristo wants to merge 1 commit intoAzure:mainfrom
Conversation
Adds OAuthBearerMethod.OidcManaged for use with the Kafka trigger/
output binding attribute on isolated workers.
This is the worker-side companion to the host extension change in
Azure/azure-functions-kafka-extension. The host extension performs
OIDC client-credentials token acquisition in managed .NET code
(HttpClient + OAuthBearerSetToken) instead of librdkafka's libcurl-
based path, sidestepping a hardcoded CA-bundle path that does not
exist on some Linux images (notably Azure Functions Flex Consumption).
Existing values (Default, Oidc) are unchanged; this is purely an
additive enum value. Requires a host extension version that
recognises OidcManaged at runtime.
Usage:
[KafkaTrigger(
brokerList: "...", topic: "...",
AuthenticationMode = BrokerAuthenticationMode.OAuthBearer,
OAuthBearerMethod = OAuthBearerMethod.OidcManaged,
OAuthBearerClientId = "%...%",
OAuthBearerClientSecret = "%...%",
OAuthBearerTokenEndpointUrl = "...",
OAuthBearerScope = "...",
OAuthBearerExtensions = "k=v,...")]
There was a problem hiding this comment.
Pull request overview
Adds a new OAuthBearerMethod.OidcManaged enum value to the Kafka isolated-worker extension so [KafkaTrigger] / [KafkaOutput] metadata can carry the new mode through to the host Kafka extension (where the runtime behavior is implemented).
Changes:
- Add
OAuthBearerMethod.OidcManagedenum value. - Document the intent and host-extension requirement via XML doc comment on the enum member.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// mode; avoids the platform-specific CA-bundle issue that affects | ||
| /// librdkafka's OIDC path on some Linux images (e.g. Azure Functions Flex). | ||
| /// </summary> | ||
| OidcManaged |
There was a problem hiding this comment.
Consider assigning explicit numeric values to the enum members (e.g., Default = 0, Oidc = 1, OidcManaged = 2) to lock in the on-wire/serialized representation and prevent accidental renumbering if the enum is ever reordered or new values are inserted in the middle.
| /// <summary> | ||
| /// OIDC client-credentials flow performed in managed .NET code rather than | ||
| /// delegated to librdkafka's libcurl-based token fetch. Requires a host | ||
| /// extension (Microsoft.Azure.WebJobs.Extensions.Kafka) that supports this | ||
| /// mode; avoids the platform-specific CA-bundle issue that affects | ||
| /// librdkafka's OIDC path on some Linux images (e.g. Azure Functions Flex). | ||
| /// </summary> |
There was a problem hiding this comment.
This new enum value is expected to flow into generated functions.metadata via JsonStringEnumConverter. Please add/extend a generator test to assert that setting OAuthBearerMethod = OidcManaged on [KafkaTrigger]/[KafkaOutput] emits the correct string value, so regressions in metadata serialization are caught.
Summary
Adds
OAuthBearerMethod.OidcManagedto the Kafka extension'sOAuthBearerMethodenum so the isolated-worker[KafkaTrigger]/[Kafka]attributes can carry the new value through to the host extension. ExistingDefaultandOidcvalues are unchanged.This is the worker-side companion to the host extension change in Azure/azure-functions-kafka-extension#635. The host extension is where the runtime behavior lives.
Motivation
On some Linux images (notably Azure Functions Flex Consumption), librdkafka's built-in OIDC path uses libcurl with a hardcoded CA-bundle path (
/etc/pki/tls/certs/ca-bundle.crt) that doesn't exist, producing:The natural fix would be
https.ca.locationinProducerConfig/ConsumerConfig, but that property was only added in librdkafka 2.11.Confluent.Kafka 2.4.0(the host extension's pinned version) ships an older librdkafka that doesn't expose it. Bumping that dependency is a non-trivial cascade throughConfluent.SchemaRegistryand serializers.The host extension solves this without changing the librdkafka pin: it adds
OAuthBearerMethod.OidcManaged, which performs OIDC client-credentials token acquisition in managed .NET code (HttpClient) and pushes the token onto librdkafka viaSetOAuthBearerTokenRefreshHandlerplus a synchronousOAuthBearerSetTokencall right afterBuild().HttpClientuses the OS trust store on every supported platform, so the CA-bundle problem disappears.This PR is the worker-side part: it adds the new enum value to the attribute surface so users can write:
The trigger metadata serializes the enum value into
function.json, and the host extension picks it up at binding time. There is no runtime logic in this package — it is purely the attribute surface.Operational note for Flex Consumption
The host PR documents this in detail, but for cross-reference: end-to-end auto-scaling on Flex Consumption with
OidcManagedcurrently requiresalwaysReadyto be set on the Kafka function group(s).Per Architecture.md § Scale Controller Integration, Azure's Functions Scale Controller embeds a pinned reference to
Microsoft.Azure.WebJobs.Extensions.Kafkaand uses reflection-based delegation for scaling decisions. Until the Scale Controller's pinned version contains the host change that ships alongside this PR, it can't deserializeOAuthBearerMethod: "OidcManaged"from function metadata, so it can't compute lag for these triggers and won't scale them out from zero.The listener still works correctly with
alwaysReady=1. Once the Scale Controller's pinned reference is bumped, dynamic scale-from-zero will work withoutalwaysReady.Backwards compatibility
Default = 0,Oidc = 1,OidcManaged = 2. No reordering.DefaultorOidcis unaffected.OidcManagedwill silently fall back to library default behavior on the metadata cast, so this enum value is only meaningful when paired with the matching host extension release. Recommended: gate user-facing code on the host extension version that contains the corresponding host change.Test plan
Worker.Extensions.Sharedis pre-existing onmain)global.jsonCompanion PR
Host-side runtime behavior: Azure/azure-functions-kafka-extension#635 — adds the
OidcManagedruntime path,OidcTokenProvider, eagerPrimeToken, and Schema Registry auth-provider integration.Both PRs need to ship for users to opt in. Recommended merge order: host PR first, this one after.
Files