ExecutionContext is null to non-function methods via IoC, alternative to ExecutionContext.FunctionAppDirectory

前端 未结 1 1280
[愿得一人]
[愿得一人] 2021-01-26 06:23

ExecutionContext is available to functon parameters.

However, it is not available to other methods via dependency inject, including Functions\' constructor, like below:

相关标签:
1条回答
  • 2021-01-26 06:58

    Based on current documentation, ExecutionContext is only available in the scope of a request when the function method is being invoked.

    [FunctionName("Car")]
    public async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]
        HttpRequest req, 
        ExecutionContext context //<--
    ) {
    
        var path = context.FunctionAppDirectory;
    
        //...
    }
    

    It wont be available as yet in the constructor for injection when the function class is initialized.

    0 讨论(0)
提交回复
热议问题