gpt4 book ai didi

azure - 以编程方式从事件网格触发的函数中获取函数应用程序 url

转载 作者:行者123 更新时间:2023-12-04 08:37:03 25 4
gpt4 key购买 nike

在 HTTP 触发的 azure 函数中,我们可以获取如下 url

public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, Microsoft.Azure.WebJobs.ExecutionContext executionContext, ILogger log)
{
string url = req.Scheme + "://" + req.Host + $"/api/AnotherFunctionOnTheApp";
}

但是我们如何在没有 HTTPRequest 对象的事件网格触发函数中做到这一点?

public static void Run([EventGridTrigger]EventGridEvent eventGridEvent, ILogger log)
{

}

目标是从事件网格触发函数调用同一函数应用上的 HTTP 触发函数。

最佳答案

获取httptrigger url的简单示例:

string url = "https://" + Environment.GetEnvironmentVariable("WEBSITE_HOSTNAME") + "/api/AnotherFunctionOnTheApp";

(Azure 默认会提供安全域。因此我们可以使用“https”。)

关于azure - 以编程方式从事件网格触发的函数中获取函数应用程序 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64755124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com