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

Request: Customized startup #10111

Closed
SRNissen opened this issue May 5, 2024 · 1 comment
Closed

Request: Customized startup #10111

SRNissen opened this issue May 5, 2024 · 1 comment

Comments

@SRNissen
Copy link

SRNissen commented May 5, 2024

What problem would the feature you're requesting solve? Please describe.

Various issues mainly related to logging:

And for myself, the exact same issue - I log with agentless Datadog which is not available until DI is available.

I'm sure there are people with other startup requirements than "log on startup" but that's what I need and so that's how the rest of this issue is written.

Describe the solution you'd like

You probably know your underlying platform better than me, but I'm thinking some combination of:

  • A build step on IFunctionHostBuilder that builds and activates the logger first so it's available for the rest of the build - in particular, available to the builder itself if it gets any errors during the rest of the build and during DI if required services cannot be found or some other issue occurs.
  • a virtual method on FunctionStartup, called on app startup immediately after build before any triggers are processed
  • a dedicated trigger that runs on startup without the scaling problems of using a TimerTrigger set to RunOnStartup. I cannot speak to the rest of Azure's users but I want to use my logger on app startup when
    • I've pushed a new image
    • the app has been stopped and I manually start the app e.g through azure portal

That is: I want to log, only once, when I have made a change, to see if it happened as expected.

Describe alternatives you've considered

It is possible to get logging on startup using a TimerTriggerAttribute set to RunOnStartup but the guidance for that is:

Caution

Don't set runOnStartup to true in production. Using this setting makes code execute at highly unpredictable times. In certain production settings, these extra executions can result in significantly higher costs for apps hosted in a Consumption plan. For example, with runOnStartup enabled the trigger is invoked whenever your function app is scaled. Make sure you fully understand the production behavior of your functions before enabling runOnStartup in production.

Alternatively, during startup I can log with Console.WriteLine - but then my logs don't get gathered by DataDog and I have to go find them elsewhere.

@SRNissen
Copy link
Author

SRNissen commented May 5, 2024

Never mind, just realized that the isolated worker model already does this.

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

No branches or pull requests

1 participant