ExecutionContext
类有一个属性FunctionName
(docs)
你可以像这样注入类:
[FunctionName("HttpTriggered")]
public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
HttpRequest req,
ExecutionContext executionContext)
{
var name = executionContext.FunctionName;
...
}
输出将是
Http触发
更新11-2025
对于隔离的运行时函数,注入
FunctionContext
类并使用 FunctionDefinition.Name
。请参阅文档