How to chain independent httpTrigger Azure Functions?

770 Views Asked by At

I come from the IBM Cloud background. In IBM Cloud, there is a service called Functions (soon to be deprecated and replaced by Code Engine). IBM Cloud Functions made it very easy to chain functions (called actions) together using sequences. I need an equivalent of this in Azure, not necessarily a 1:1 match.

My exact use case

In Azure, I have a JavaScript httpTrigger Function that I want to call in another httpTrigger Function. Both are in the same resource group.

To my limited knowledge, neither Durable Functions nor Queue Storage would require a compromise in this scenario because:

  1. I'd have to change the Function to activityTrigger to use Durable Functions, meaning that I wouldn't be able to use it separately to handle HTTP requests.
  2. If I used the Function in Queue Storage, it would trigger the other Function every time it's called, limiting its reusability in other scenarios.

What is the most common, straightforward or optimal solution to this problem in the Azure infrastructure?


I’m familiar with these solutions (not necessarily experienced in their implementation):

  • Durable Functions
  • Logic App
  • BizTalk Server
  • HTTP request
2

There are 2 best solutions below

1
On

You can use a http module to call another function

var http = require('http');

module.exports= function (context) {
  context.log('JavaScript HTTP trigger function processed a request.');

  var options = {
      host: '<Another Function URL>',
      port: '80',
      path: '/test',
      method: 'POST'
  };

0
On

I decided to go with Durable Functions, perhaps not the best solution, but very flexible and allowing for more complex workflows.

Durable Functions require setting up a storage service for the Function App, in which you'll then need to add a few application settings (remember to back up your current functions first).

  • WEBSITE_CONTENTSHARE — to get the value, navigate to your storage and go to File shares
  • WEBSITE_CONTENTAZUREFILECONNECTIONSTRING — use either of the Access keys from your storage account
  • AzureWebJobsStorage — use the storage account's name, which you can also get in Access keys