ExecutionContext in Azure Function IWebJobsStartup implementation

后端 未结 2 1902
一生所求
一生所求 2021-02-08 04:54

How to get access to the ExecutionContext.FunctionAppDirectory in Functions Startup class so I can setup my Configuration correct. Please see the following Startup code:

2条回答
  •  执笔经年
    2021-02-08 05:18

    Use below code ,It worked for me.

    var executioncontextoptions = builder.Services.BuildServiceProvider()
             .GetService>().Value;
    
    var currentDirectory = executioncontextoptions.AppDirectory;
    
    configuration = configurationBuilder.SetBasePath(currentDirectory)
              .AddJsonFile(ConfigFile, optional: false, reloadOnChange: true)    
              .Build();
    

提交回复
热议问题