Azure function Startup class execution

Amar-Azure-Practice 656 Reputation points
2021-07-24T00:58:06.587+00:00

Hi

We have created a Azure function with Startup.cs class.

in the startup class we want to load few configuration parameters from DB and static files and load to some variables.

in the Azure function we are going to use these variables.

I would like to understand th behavior of the Startup.cs class execution.

when app is instantiating startup class is executing and configuration values are being pulled.

Every time when we call Azure function this startup code will execute or it will execute only at the time of Azure app is instantiated?

and when the app is scaled out to new app service plans (we setup the scale out on CPU utilization) the startup class will execute again in the new app??

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,249 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pramod Valavala 20,516 Reputation points Microsoft Employee
    2021-07-28T07:30:41.737+00:00

    @Amar-Azure-Practice The startup class is executed at the host level when it first starts up. This is just run once per instance and as your function app is scaled out, its run on each instance while it starts up.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Jakub Krupka 1 Reputation point
    2022-08-31T05:30:27.487+00:00

    Which mechanism should I use to have a unique business logic per instance (scaling up to 5 instances on App Service Plan)?

    For example, I want each instance by unique machine name to subscribe to individual service bus topic (also by this machine name)

    0 comments No comments