UNPKG

3.15 kBTypeScriptView Raw
1// Copyright (c) .NET Foundation. All rights reserved.
2// Licensed under the MIT License.
3
4import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
5import { InvocationContext } from './InvocationContext';
6
7export type ServiceBusQueueHandler = (messages: unknown, context: InvocationContext) => FunctionResult;
8
9export interface ServiceBusQueueFunctionOptions extends ServiceBusQueueTriggerOptions, Partial<FunctionOptions> {
10 handler: ServiceBusQueueHandler;
11
12 trigger?: ServiceBusQueueTrigger;
13}
14
15export interface ServiceBusQueueTriggerOptions {
16 /**
17 * An app setting (or environment variable) with the service bus connection string
18 */
19 connection: string;
20
21 /**
22 * The name of the queue to monitor
23 */
24 queueName: string;
25
26 /**
27 * `true` if connecting to a [session-aware](https://docs.microsoft.com/azure/service-bus-messaging/message-sessions) queue. Default is `false`
28 */
29 isSessionsEnabled?: boolean;
30
31 /**
32 * Set to `many` in order to enable batching. If omitted or set to `one`, a single message is passed to the function.
33 */
34 cardinality?: 'many' | 'one';
35}
36export type ServiceBusQueueTrigger = FunctionTrigger & ServiceBusQueueTriggerOptions;
37
38export interface ServiceBusQueueOutputOptions {
39 /**
40 * An app setting (or environment variable) with the service bus connection string
41 */
42 connection: string;
43
44 /**
45 * The name of the queue to monitor
46 */
47 queueName: string;
48}
49export type ServiceBusQueueOutput = FunctionOutput & ServiceBusQueueOutputOptions;
50
51export type ServiceBusTopicHandler = (message: unknown, context: InvocationContext) => FunctionResult;
52
53export interface ServiceBusTopicFunctionOptions extends ServiceBusTopicTriggerOptions, Partial<FunctionOptions> {
54 handler: ServiceBusTopicHandler;
55
56 trigger?: ServiceBusTopicTrigger;
57}
58
59export interface ServiceBusTopicTriggerOptions {
60 /**
61 * An app setting (or environment variable) with the service bus connection string
62 */
63 connection: string;
64
65 /**
66 * The name of the topic to monitor
67 */
68 topicName: string;
69
70 /**
71 * The name of the subscription to monitor
72 */
73 subscriptionName: string;
74
75 /**
76 * `true` if connecting to a [session-aware](https://docs.microsoft.com/azure/service-bus-messaging/message-sessions) subscription. Default is `false`
77 */
78 isSessionsEnabled?: boolean;
79
80 /**
81 * Set to `many` in order to enable batching. If omitted or set to `one`, a single message is passed to the function.
82 */
83 cardinality?: 'many' | 'one';
84}
85export type ServiceBusTopicTrigger = FunctionTrigger & ServiceBusTopicTriggerOptions;
86
87export interface ServiceBusTopicOutputOptions {
88 /**
89 * An app setting (or environment variable) with the service bus connection string
90 */
91 connection: string;
92
93 /**
94 * The name of the topic to monitor
95 */
96 topicName: string;
97}
98export type ServiceBusTopicOutput = FunctionOutput & ServiceBusTopicOutputOptions;