Reputation: 4728
In an HTTP triggered azure function we can get the url as follows
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";
}
But how do we do it in an event grid triggered function where we do not have the HTTPRequest object?
public static void Run([EventGridTrigger]EventGridEvent eventGridEvent, ILogger log)
{
}
The objective is to call an HTTP triggered function on the same functionapp from the event grid triggered function.
Upvotes: 2
Views: 341
Reputation: 14113
A simple example to get the url of the httptrigger:
string url = "https://" + Environment.GetEnvironmentVariable("WEBSITE_HOSTNAME") + "/api/AnotherFunctionOnTheApp";
(Azure will offer a secure domain by default. So we can use 'https'.)
Upvotes: 2