Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native support for warmup trigger #180

Merged
merged 8 commits into from
Oct 31, 2023
Merged

Add native support for warmup trigger #180

merged 8 commits into from
Oct 31, 2023

Conversation

castrodd
Copy link
Member

This PR is a fix for issues #174 and #176.

Currently, users wanting to set up a warmup trigger need to use generics. For example, they could write:

const { app, output, trigger } = require('@azure/functions');

app.generic('warmup', {
    trigger: trigger.generic({
        type: "warmupTrigger",
        direction: "in",
        name: "warmupContext"
    })
    handler: async (warmupContext, context) => {
        context.log('Function App instance is warm.');
    }
});

This works, but with the changes in this PR, users can now call the warmup trigger directly on app:

import { app, InvocationContext } from "@azure/functions";

export async function warmupFunction(warmupContext: object, context: InvocationContext): Promise<void> {
    context.log('Function App instance is warm.');
}

app.warmup('warmup', {
    handler: warmupFunction,
});

@castrodd castrodd requested a review from ejizba October 31, 2023 16:46
@charlesgardyn
Copy link

Could you tell me what happens when you try to deploy that using the Consumption plan? It'd be nice if there were a nice error message

types/trigger.d.ts Outdated Show resolved Hide resolved
types/warmup.d.ts Outdated Show resolved Hide resolved
types/warmup.d.ts Outdated Show resolved Hide resolved
types/app.d.ts Show resolved Hide resolved
import { FunctionOptions, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export interface WarmupContextOptions {}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should be just WarmupContext without Options

types/warmup.d.ts Outdated Show resolved Hide resolved
types/app.d.ts Show resolved Hide resolved
@castrodd castrodd merged commit c3aa2c4 into v4.x Oct 31, 2023
9 checks passed
@castrodd castrodd deleted the dc/warmup branch October 31, 2023 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants