title: How to use dependency injection in Azure Durable Functions?
body: <p>I want to create an Azure Durable Function that will download a CSV from the Internet and based on the data in this file, it will update my database using EntityFramework.</p>
  <p>I set up the simple startup function that is triggered with TimeTrigger. This function is responsible for starting the orchestrator. The orchestrator executes multiple activities in parallel. There are around 40000 work items to be processed, so that's the number of activities that are triggered by orchestrator. Some of these activities will need to update the database (insert/update/delete rows). For this I need a database connection. I can configure DI in the StartUp in the following way:</p>
  <pre><code>public override void Configure(IFunctionsHostBuilder builder)
          {
              var connectionString = Environment.GetEnvironmentVariable(&quot;DefaultConnection&quot;);
              builder.Services.AddDbContext&lt;SqlContext&gt;(options =&gt; options.UseSqlServer(connectionString));
              builder.Services.AddScoped&lt;IDbContext, SqlContext&gt;();
          }
      }
  </code></pre>
  <p>However all my functions (orchestrator, activity function, etc.) are static and reside in a static class. I haven't seen any example where durable functions were defined in a non-static class and I had all kinds of problems when I tried that myself, so I assumed they must be static without diving too much into it.</p>
  <p>I do not know how to pass my <code>DbContext</code> object to the Activity function, so it can update the data in the database when needed.</p>
  <p>How should I resolve it?</p>