0

Requirements:

  • A time triggered background process to insert a record to a database table.
  • Runs over 10,000 requests every 00:00 (midnight)
  • Individual requests wouldn't last 1-2 seconds

We are planning to use two azure functions for this, steps below:

  1. The 1st Azure Function (time triggered), runs a query then insert records to an azure storage queue.
  2. New queue items will be picked up the 2nd Azure Function (queue trigger)

QUESTION: Is it okay to use Azure Function purely for API calls? for functions mentioned in 1. and 2. they would call an api, which contains the domain layer for select and insert operations.

Architecture looks like this:

Azure Function -> (http call) -> Api -> Application Service -> Domain Layer -> Data Layer

My thoughts are, functions won't be able to scale since the load will just be transferred to the api, not unless the api also scales with some sort of load balancing

Yorro
  • 11,445
  • 4
  • 37
  • 47
  • The queue trigger will call the api? – sa-es-ir Jun 19 '22 at 05:55
  • @SaeedEsmaeelinejad Yes. Eventually – Yorro Jun 19 '22 at 09:51
  • I think it's a backend-to-backend scenario and it's not needed to call api. So if you want to use azure function you can use the application service directly or even you don't need azure function and just use something like Hangfire and schedule tasks. – sa-es-ir Jun 19 '22 at 19:02
  • @Yorro when people ask you to explain a question and mention the actual problem, don't delete it. The solution may not be what you think. If an expression is expensive, don't map that column. If it's only needed in certain scenarios, you're free to use different DbContexts with different configs for each scenario. Or map a different type to a view. Or, when possible, make the column *persisted* or even indexed. It's common eg with Serilog Logging tables to have a persisted computed column that extracts eg the Category or specific tags from the JSON payload. – Panagiotis Kanavos Oct 05 '22 at 07:21

1 Answers1

1

Yes, you can build and customize an API on Azure Functions.

If you are using the C# language function app, you can create the HttpClient object to make HTTP calls from Azure function.

You can use any of the supported triggers to trigger your function app, and your function app will make the HTTP calls or the api calls.

As per Microsoft-Documentation it says,

Azure Functions integrates with Azure API Management in the portal to let you expose your HTTP trigger function endpoints as REST APIs. These APIs are described using an OpenAPI definition.
Azure Functions integrates with Azure API Management in the portal to let you expose your HTTP trigger function endpoints as REST APIs.

Scale an Azure Function to handle 10,000+ requests per second. Here are some blogs which might give an overview of handling 10000+ requests.
Scaling Azure Functions to make more requests

https://learn.microsoft.com/en-au/azure/load-testing/overview-what-is-azure-load-testing?WT.mc_id=DT-MVP-5001664

For further refer SO_thread and MSDN-Example for more details.

RajkumarPalnati
  • 541
  • 2
  • 6