I have written 3 functions as follows
In [3] function, I will call [2] functi
You can do it directly by calling the 2nd function as a normal C# static method.
But in this case you lose benefits of Azure Functions scaling and distributing (for example, based on server load your 2nd function may be called from different part of the world).
As for the 1st option in C# you can do it like so:
static HttpClient client = new HttpClient();
[FunctionName("RequestImageProcessing")]
public static async Task RequestImageProcessing([HttpTrigger(WebHookType = "genericJson")]
HttpRequestMessage req)
{
string anotherFunctionSecret = ConfigurationManager.AppSettings
["AnotherFunction_secret"];
// anotherFunctionUri is another Azure Function's
// public URL, which should provide the secret code stored in app settings
// with key 'AnotherFunction_secret'
Uri anotherFunctionUri = new Uri(req.RequestUri.AbsoluteUri.Replace(
req.RequestUri.PathAndQuery,
$"/api/AnotherFunction?code={anotherFunctionSecret}"));
var responseFromAnotherFunction = await client.GetAsync(anotherFunctionUri);
// process the response
}
[FunctionName("AnotherFunction")]
public static async Task AnotherFunction([HttpTrigger(WebHookType = "genericJson")]
HttpRequestMessage req)
{
await Worker.DoWorkAsync();
}
Also sometimes you need your first Azure Function to return HTTP response first, and then do something in the background, so this solution won't work. In this case options 2 and 3 are suitable.