title: Get root directory of Azure Function App v2
body: <p>I build an Azure Function App (v2). Configuration tasks necessary for all functions are done in a Setup class that is structured like the following:</p>
  
  <pre><code>[assembly: WebJobsStartup(typeof(Startup))]
  
  internal class Startup : IWebJobsStartup
  {
    public void Configure(IWebJobsBuilder builder)
    {
      Configuration = new ConfigurationBuilder()
                        .SetBasePath(&lt;functionAppDirectory&gt;)
                        .AddJsonFile("local.settings.json")
                        .Build();
      builder.AddDependencyInjection(ConfigureServices);  
    }
  
    public IConfiguration Configuration { get; set; }
  
    private void ConfigureServices(IServiceCollection services)
    {
      var connection = Configuration.GetConnectionString("&lt;myconnection-string&gt;");
      ...
    }
  }
  </code></pre>
  
  <p>In <code>ConfigureServices</code> I want to read a connection string from a configuration file. For that the function app base folder has be specified with <code>SetBasePath</code>. But I found no way to get access to this path. According to <a href="https://github.com/Azure/azure-functions-host/wiki/Retrieving-information-about-the-currently-running-function" rel="noreferrer">https://github.com/Azure/azure-functions-host/wiki/Retrieving-information-about-the-currently-running-function</a> an <code>ExecutionContext</code> can be injected in a function, which contains the path need. But how do I access <code>ExecutionContext</code> in my <code>Startup</code> class?</p>