Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
HttpHandler,
HttpMethod,
HttpMethodFunctionOptions,
KafkaFunctionOptions,
McpToolFunctionOptions,
MySqlFunctionOptions,
ServiceBusQueueFunctionOptions,
Expand Down Expand Up @@ -146,6 +147,10 @@ export function webPubSub(name: string, options: WebPubSubFunctionOptions): void
generic(name, convertToGenericOptions(options, trigger.webPubSub));
}

export function kafka(name: string, options: KafkaFunctionOptions): void {
generic(name, convertToGenericOptions(options, trigger.kafka));
}

/**
* Registers an MCP Tool function in your app.
* This function is triggered by MCP Tool events and allows you to define the behavior of the function.
Expand Down
9 changes: 9 additions & 0 deletions src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
GenericOutputOptions,
HttpOutput,
HttpOutputOptions,
KafkaOutput,
KafkaOutputOptions,
MySqlOutput,
MySqlOutputOptions,
ServiceBusQueueOutput,
Expand Down Expand Up @@ -115,6 +117,13 @@ export function webPubSub(options: WebPubSubOutputOptions): WebPubSubOutput {
});
}

export function kafka(options: KafkaOutputOptions): KafkaOutput {
return addOutputBindingName({
...options,
type: 'kafka',
});
}
Comment on lines +120 to +125
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add unit coverage for the new output.kafka(...) helper to validate the generated output binding metadata (e.g., type: 'kafka', direction 'out', and deterministic auto-generated binding name). This behavior is covered for other outputs in test/converters/toCoreFunctionMetadata.test.ts, but Kafka output isn’t included.

Copilot uses AI. Check for mistakes.

export function generic(options: GenericOutputOptions): FunctionOutput {
return addOutputBindingName(options);
}
Expand Down
9 changes: 9 additions & 0 deletions src/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
GenericTriggerOptions,
HttpTrigger,
HttpTriggerOptions,
KafkaTrigger,
KafkaTriggerOptions,
McpToolTrigger,
McpToolTriggerOptions,
MySqlTrigger,
Expand Down Expand Up @@ -129,6 +131,13 @@ export function webPubSub(options: WebPubSubTriggerOptions): WebPubSubTrigger {
});
}

export function kafka(options: KafkaTriggerOptions): KafkaTrigger {
return addTriggerBindingName({
...options,
type: 'kafkaTrigger',
});
}
Comment on lines +134 to +139
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add unit coverage for the new trigger.kafka(...) helper (similar to existing http/storage tests) to verify the generated binding metadata includes the expected type: 'kafkaTrigger', direction 'in', and deterministic auto-generated binding name. test/converters/toCoreFunctionMetadata.test.ts already validates other trigger/output helpers, but Kafka isn’t covered yet.

Copilot uses AI. Check for mistakes.

/**
* Creates an MCP Tool trigger configuration.
* This function is used to define an MCP Tool trigger for an Azure Function.
Expand Down
8 changes: 8 additions & 0 deletions types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CosmosDBFunctionOptions } from './cosmosDB';
import { EventGridEvent, EventGridFunctionOptions } from './eventGrid';
import { EventHubFunctionOptions } from './eventHub';
import { GenericFunctionOptions } from './generic';
import { KafkaFunctionOptions } from './kafka';
import { HttpFunctionOptions, HttpHandler, HttpMethodFunctionOptions } from './http';
import { McpToolFunctionOptions } from './mcpTool';
import { MySqlFunctionOptions } from './mySql';
Expand Down Expand Up @@ -182,6 +183,13 @@ export function sql<T = unknown>(name: string, options: SqlFunctionOptions<T>):
*/
export function mySql<T = unknown>(name: string, options: MySqlFunctionOptions<T>): void;

/**
* Registers a function in your app that will be triggered whenever a message is added to a Kafka topic
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function kafka<T = unknown>(name: string, options: KafkaFunctionOptions<T>): void;

/**
* Registers a generic function in your app that will be triggered based on the type specified in `options.trigger.type`
* Use this method if your desired trigger type does not already have its own method
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './cosmosDB.v4';
export * from './eventGrid';
export * from './eventHub';
export * from './generic';
export * from './kafka';
export * from './hooks/appHooks';
export * from './hooks/HookContext';
export * from './hooks/invocationHooks';
Expand Down
Loading
Loading