简体   繁体   English

是否可以访问 Startup.cs 中的任何 Azure Function 触发器详细信息/上下文?

[英]Is it possible to access any Azure Function trigger details/context in Startup.cs?

I have a few azure functions, they're in a .net core project which has a startup.cs class in which I register all of the dependencies.我有一些 azure 函数,它们位于一个 .net 核心项目中,该项目有一个 startup.cs 类,我在其中注册了所有依赖项。

This is all works fine, but I'd like some way of calling a common method regardless of which trigger was invoked.这一切正常,但无论调用哪个触发器,我都想要某种调用通用方法的方法。 But within that method I'd like to access details from some sort of context (?) to know which azure function's being called.但是在该方法中,我想从某种上下文 (?) 访问详细信息,以了解正在调用哪个 azure 函数。

This is based on the assumption that Startup.cs is called every time a function is.这是基于每次调用函数时都会调用 Startup.cs 的假设。

What I've Tried我试过的

I'm aware of the FunctionInvocationFilterAttribute but this is currently only in preview mode so I'm not permitted to use this.我知道FunctionInvocationFilterAttribute但这目前仅处于预览模式,所以我不允许使用它。

Is it possible to access any Azure Function trigger details/context in Startup.cs?是否可以访问 Startup.cs 中的任何 Azure Function 触发器详细信息/上下文?

In short, it's impossible .简而言之,这是不可能的

You will not be able to get the ExecutionContext in startup.您将无法在启动时获得ExecutionContext Because the ExecutionContext enables interaction with the Azure Functions execution environment when a function call is made.因为ExecutionContext在进行函数调用时启用与 Azure Functions 执行环境的交互。

However, in your function startup, your Azure Function is not yet processing an actual function call.但是,在函数启动时,Azure 函数尚未处理实际的函数调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Startup.cs:调用控制器的上下文 - Startup.cs: calling a context of controller how to read azure app config values in C# startup.cs class in azure function - how to read azure app config values in C# startup.cs class in azure function 在 Azure Function 中引用类库 .dll 文件,是否需要在 Startup.cs 中设置服务? - Referencing class library .dll file in Azure Function, do I need to setup the services in Startup.cs? 连接到 .NET 3.1 中的 Entity Framework Core - Connect to Entity Framework Core in .NET 3.1 Azure Function Project Startup.cs 通过 Azure 门户中的“身份验证”刀片与 Startup.cs 中的手动保护 Function 应用程序 - Securing Function App via 'Authentication' blade in Azure Portal vs. manually in Startup.cs 为什么启动我的Azure Function时没有使用startup.cs文件? - Why is the startup.cs file not being used when I start my Azure Function? 为什么我的 Azure Function 无法在 startup.cs 中正确加载我的环境变量? - Why would my Azure Function not load my environment variables correctly in startup.cs? 尝试将上下文添加到 Startup.cs 时出现服务问题 - Issue with Services when attempting to add Context to Startup.cs 在startup.cs上的IIS 8.5配置(Azure webrole) - IIS 8.5 configuration on startup.cs (Azure webrole) 在Startup.cs中添加大量存储库是否会引起任何问题? - Does adding a lot of repositories to the Startup.cs cause any issues?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM