0
votes

I developed a couple of microservice using Azure functions, every service has independent use case and different programming language.

Micro Services

Now I have a use case to use all service in below order, So I developed one more Azure function to use all service in given order. below code running well.

Aggregate Service

public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)]HttpRequestMessage req, TraceWriter log)
    {
        string returnValue = string.Empty;
        dynamic data = await req.Content.ReadAsStringAsync();
        if (data == null)
        {
            return req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a value in the request body");
        }
        else
        {
            string body = data.ToString();
            var transformResult = await HttpRestHelper.CreateRequestAsync(AppConfiguration.TransformServiceEndPoint, body, HttpMethod.POST);

            var validationResult = await HttpRestHelper.CreateRequestAsync(AppConfiguration.ValidationServiceEndPoint, transformResult.Result.ToString(), HttpMethod.POST);

            if (validationResult.Result != null && Convert.ToBoolean(validationResult.Result))
            {
                var encryptionResult = await HttpRestHelper.CreateRequestAsync(AppConfiguration.EncryptionServiceEndPoint, transformResult.Result.ToString(), HttpMethod.POST);

                var storageResult = await HttpRestHelper.CreateRequestAsync(AppConfiguration.StorageServiceEndPoint, encryptionResult.Result.ToString(), HttpMethod.POST);
                returnValue = storageResult.Result.ToString();
            }
            else
            {
                returnValue = "Validation Failed";
            }

            return req.CreateResponse(HttpStatusCode.OK, returnValue, "text/plain");
        }
    }

Question

If every microservice takes 1 min to execution, I have to wait ~4min in my Super Service and billed for 4+ min. (We don't need to pay for waiting time :) https://www.youtube.com/watch?v=lVwWlZ-4Nfs)

I want to use Azure Durable functions here but didn't get any method to call external url.

Please help me or suggest a better solution.

Thanks In Advance

1

1 Answers

1
votes

Durable Orchestration Functions don't work with arbitrary HTTP endpoints. Instead, you need to create individual functions as Activity-triggered.

Orchestration will use message queues behind the scenes rather than HTTP. HTTP is request-response in nature, so you have to keep the connection and thus pay for it.

Queue-based orchestrator can also give you some extra resilience in face of intermittent failures.