【发布时间】:2021-06-24 10:21:17
【问题描述】:
我需要在 Azure Function 中访问 FunctionAppDirectory
这里是函数的简化版
[Function("Test")]
public static HttpResponseData Test([HttpTrigger(AuthorizationLevel.Function, "post", Route = "Test")] HttpRequestData req,
ExecutionContext context, FunctionContext fContext)
{
var log = fContext.GetLogger(nameof(TestOperations));
log.LogInformation(context?.FunctionAppDirectory?.ToString());
return req.CreateResponse(HttpStatusCode.OK);
}
ExecutionContext 这里为空。
我的 Program.cs 文件
class Program
{
static Task Main(string[] args)
{
var host = new HostBuilder()
.ConfigureAppConfiguration(configurationBuilder =>
{
configurationBuilder.AddCommandLine(args);
})
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
// Add Logging
services.AddLogging();
})
.Build();
return host.RunAsync();
}
}
在 .NET 5 中运行的 Azure 函数
如何为 ExecutionContext 配置绑定或以其他方式获取 FunctionAppDirectory?
【问题讨论】:
-
在 .NET 5(隔离)中,您不能再使用执行上下文 - 请参阅 docs.microsoft.com/en-us/azure/azure-functions/…。这些东西对你有用吗? stackoverflow.com/questions/55616798/…
标签: azure azure-functions .net-5