如何从计时器触发器获取运行azure函数的主机名? [英] How to get the hostname for where the azure function run from timer trigger?

查看:47
本文介绍了如何从计时器触发器获取运行azure函数的主机名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个计时器触发

    [FunctionName("HeathChecker")]
    public static void Run([TimerTrigger("*/10 * * * * *")]TimerInfo myTimer, ILogger log)
    {
        log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");


    }

还有一个HTTP触发器

And an HTTP trigger

    [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对其进行调用.这可能吗?

I would like to be able to get the hostname of where the HTTP trigger is running, so I can call it with HTTP from the timer trigger. Is this possible?

推荐答案

我刚刚检查了一下,发现环境变量名称已更改.现在正在做什么:

I just checked this and found out that the environment variable name has changed. What's working now is this:

Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME")

这篇关于如何从计时器触发器获取运行azure函数的主机名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆