2

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.

1
  • Any update? Can my answer answered your question? Commented Nov 11, 2020 at 1:46

1 Answer 1

2

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'.)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this works. Only difference is I am using #if DEBUG string httpScheme = "http://"; #else string httpScheme = "https://"; #endif So that postman call the function locally for debugging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.