$ npm install @azure/functions
| Branch | Status | Support level | Node.js Versions |
|---|---|---|---|
| v4.x (default) | GA | 24, 22 | |
| v3.x | GA | 24, 22 |
npm install @azure/functions
@azure/functions npm package, and is versioned independently of the runtime. Both the runtime and the programming model use "4" as their latest major version, but that is purely a coincidence.Version 4.17.0 adds explicitly typed polling and batching properties to ConnectorTriggerOptions and ConnectorTriggerFunctionOptions.
Previously, these properties were accepted through a Record<string, unknown> index signature.
This tightens the TypeScript contract and can cause existing code to fail compilation, even when the configuration values are valid at runtime.
Custom properties remain supported.
In particular, TypeScript widens properties in an unannotated configuration variable to string:
import { trigger } from '@azure/functions';
const options = { deliveryMode: 'Webhook' };
// No longer compiles: string is not assignable to 'Poll' | 'Webhook'.
trigger.connectorTrigger(options);
Annotate configuration variables with the exported options type:
import { trigger, type ConnectorTriggerOptions } from '@azure/functions';
const options: ConnectorTriggerOptions = { deliveryMode: 'Webhook' };
trigger.connectorTrigger(options);
For app.connectorTrigger, use ConnectorTriggerFunctionOptions<T> for a configuration variable that includes a handler.
Alternatively, preserve literal types using as const, or pass the options object directly to the API.
Use the exact values 'Poll' or 'Webhook' for deliveryMode, and 'one' or 'many' for cardinality.
The connection and trigger configuration names must be strings; batch size, concurrency, and scaling threshold overrides must be numbers.
Poll delivery also now checks at registration that both connection and triggerConfigName are supplied.
import { app, HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions";
export async function httpTrigger1(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
context.log(`Http function processed request for url "${request.url}"`);
const name = request.query.get('name') || await request.text() || 'world';
return { body: `Hello, ${name}!` };
};
app.http('httpTrigger1', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: httpTrigger1
});
const { app } = require('@azure/functions');
app.http('httpTrigger1', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
context.log(`Http function processed request for url "${request.url}"`);
const name = request.query.get('name') || await request.text() || 'world';
return { body: `Hello, ${name}!` };
}
});
© 2010 - cnpmjs.org x YWFE | Home | YWFE