Frans Bstrom
Frans Bstrom

Reputation: 305

Activate azure function only after another function have executed?

I have a PostStartupSetup azure functions that will run on every startup

[FunctionName(nameof(PostStartupSetup))]
public async Task PostStartupSetup([TimerTrigger("0 0 0 29 2 6", RunOnStartup = true)]TimerInfo t)
{
    // do startup tasks
}

I then have some functions with ServiceBusTrigger's that relies on my PostStartupSetup to have completed. Is it possible to somehow only activate those functions AFTER my PostStartupSetup function have finished executed?

Upvotes: 3

Views: 1198

Answers (1)

Kashyap
Kashyap

Reputation: 17441

No straight forward way but here are few options:

  1. If you're dedicated plan you can use Durable Functions, set some shared variable to true/false to indicate if "startup" is complete or not and if it's not complete then all other functions would keep failing with appropriate Error code.
  2. If you're on consumption plan then you could use some cheap options like storage tables to share state across functions and do the same.
  3. You could truly disable (not tested) functions and enable them dynamically:

Upvotes: 2

Related Questions