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

标签 azure http azure-functions azure-eventgrid

在 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/

相关文章:

http - 如何处理 "100 continue"HTTP 消息?

c# - Azure Functions无法将队列绑定(bind)到CloudQueue类型

iphone - 如何监控 HTTP POST 请求?

azure - 将数据导出到 Azure 数据资源管理器

Azure SignalR 服务实现 .NET 6 Azure Function 隔离进程

azure - 在构建管道中部署到 Azure 时出错

azure - 是否可以为 Azure 应用服务中同一 IP 地址的多个请求创建警报?

azure - APIM 是否将相同的不记名 token 转发到后端 API? | OAuth 2.0 和 Azure AAD

azure - Azure 网站上的 SQLite

http - 错误: Could not find main or io in tokio,无效的返回类型 `impl Future`