Build an order workflow with Logic Apps, Functions and Service Bus

This article was reworked in November 2026. The 2018 version used the in-process Azure Functions model, whose support ended on 10 November 2026, connector actions that have since been replaced by V2 versions, and screenshots of a portal that no longer looks like that.

This is a small but realistic example of wiring several Azure services together with Logic Apps. An online shop receives an order over HTTP, an Azure Function checks it, Service Bus queues it, and a second workflow stores the order in Table Storage and sends the customer a confirmation email. Everything can be built in the Azure Portal; the only code is the Function.

The design: two workflows and a queue between them

A trigger in Logic Apps can only stand at the beginning of a workflow, never after other steps. So “receive the order” and “process the order” are two workflows, and the Service Bus queue is what connects them:

Workflow 1: receive-order
  When an HTTP request is received
    -> Choose an Azure function (ValidateOrder)
    -> Send message (Service Bus queue "orders")

Workflow 2: process-order
  When a message is received in a queue (auto-complete)
    -> Insert or Merge Entity (V2)   } in parallel
    -> Send an email (V2)            }

The queue is not there for decoration. The first workflow is done as soon as the order is queued, and if Table Storage or Outlook has a bad minute, the order waits in the queue instead of getting lost.

Step 1: the Azure Function

The Function receives the order, rejects it when the id is missing and returns it otherwise. In a real shop this is where you would check stock or prices; here it stands for any logic you don’t want to express in the workflow designer.

Create a Function App with the .NET runtime and the isolated worker model; the in-process model is out of support since November 2026. The function uses the ASP.NET Core integration, which needs the Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore package and this Program.cs:

using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
    .ConfigureFunctionsWebApplication()
    .Build();

host.Run();

And the function itself:

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;

public class ValidateOrder
{
    [Function("ValidateOrder")]
    public async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req)
    {
        var order = await req.ReadFromJsonAsync<Order>();

        if (string.IsNullOrEmpty(order?.Id))
        {
            return new BadRequestObjectResult("Please pass a valid order id");
        }

        return new OkObjectResult(order);
    }
}

public record Order(string Id, string ItemId, int Size, string Email);

Compared to the 2018 version, there is no #r "Newtonsoft.Json", no TraceWriter and no manual serialization: ReadFromJsonAsync reads the body and OkObjectResult writes the order back as JSON.

Logic Apps can call a function only when it uses the HTTP trigger, and the function app must run .NET or Node.js. Both are true here.

Step 2: the Service Bus queue

Create a Service Bus namespace and a queue named orders in it. The Basic tier is enough for queues and is the cheapest. I lower the message time to live to a few hours, because an order that waited that long needs a human anyway.

Step 3: the receive-order workflow

Create a Logic App on the Consumption plan, open the designer and build three steps:

  1. When an HTTP request is received. Paste a sample order into Use sample payload to generate schema, and the designer creates the JSON schema for you, so later steps can pick Id, ItemId and the other fields from a list.
  2. Choose an Azure function, pick the function app and ValidateOrder, and pass the trigger’s body as the request body.
  3. Send message from the Service Bus connector, to the orders queue, with the Body of the function as the message content.

The HTTP trigger makes the workflow callable from the internet. Its URL contains a signature, and anyone who has the URL can start the workflow. Restrict who can call it: Logic Apps supports OAuth with Microsoft Entra ID, limiting the allowed caller IP addresses, or putting Azure API Management in front of it.

The function step is optional. If you don’t need any logic, send the trigger body straight to the queue.

Step 4: the process-order workflow

Create a second Logic App and start it with the Service Bus trigger When a message is received in a queue (auto-complete) on the orders queue. Auto-complete means Service Bus removes the message as soon as the workflow has received it.

The trigger delivers the message body base64-encoded in the ContentData property. Decode it once in a Compose action, named Order here:

json(base64ToString(triggerBody()?['ContentData']))

Every later step can then read the order with outputs('Order'). After the Compose action, add two actions as parallel branches, because neither depends on the other:

Trying it out

Copy the URL of the HTTP trigger from the first workflow and send it an order:

curl -X POST "<your-trigger-url>" \
  -H "Content-Type: application/json" \
  -d '{"Id":"1001","ItemId":"shoe-42","Size":42,"Email":"[email protected]"}'

The run history of the first workflow shows the function’s answer and the queued message. A few seconds later, the second workflow has a run of its own, the order is in the table, and the email is in your inbox. Send an order without an Id, and the first workflow stops at the function with a 400 Bad Request, before anything reaches the queue.

comments powered by Disqus