我有一个定时器触发器
[FunctionName("HeathChecker")]
public static void Run([TimerTrigger("*/10 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
还有一个 HTTP 触发器
[FunctionName("AspNetCoreHost")]
public Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, Route = "{*all}")]HttpRequest req,
[AspNetCoreRunner(Startup = typeof(Startup))] IAspNetCoreRunner aspNetCoreRunner,
ExecutionContext executionContext)
{
return aspNetCoreRunner.RunAsync(executionContext);
}
我希望能够获取运行 HTTP 触发器的主机名,这样我就可以从定时器触发器中使用 HTTP 调用它。这可能吗?
最佳答案
您还可以从 HttpRequest req
对象中获取主机名:
HostString hostString = req.Host;
string host = hostString.Host;
int? port = hostString.Port;
string fullHost = hostString.Value;
关于c# - 如何从计时器触发器获取 azure 函数运行位置的主机名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56586433/