azure-functions-extension
azure-functions-extension copied to clipboard
Function not triggered
Hi,
I am trying to build a POC with Azure Container Apps (abstraction on top of AKS, KEDA, Dapr) which is actually an Async Request-Reply pattern implementation involving:
- One REST API component, ASP.NET core 6 Web API using Dapr pub/sub (based on Azure Service Bus) and Dapr state store (based on ComosDB) components
- One message-based background processing component, Azure Function, .net 6 for the function app, using Dapr pub/sub (based on Azure Service Bus) with Dapr Azure Function Extensions and Dapr state store (based on ComosDB) components
The two components are correctly built, containerized, pushed to ACR and successfully deployed as two separate Azure Container Apps in the same Azure Container Apps environment. (Under the hood that results into two separate pods, each running the component's main container plus the Dapr sidecar, in the same AKS cluster)
However the function of the background processing component is never triggered:
-
I have configured
appPort:3001
in the Dapr configuration section of the ARM template for the background process Azure Container App as per documentation -
I can see the background process container successfully starting as I can see some technical logs from the container and daprd in the Log Analytics Workspace that is linked to the Azure Container App
-
The Azure Service Bus topic and subscription are correctly created after I deploy the Azure Container App for the background process with Dapr configuration
-
I can see the active messages on the topic subscription after publishing from the API component. However it appears the messages are never consumed by the Dapr sidecar and delivered to my function. Example (peek):
{"specversion":"1.0","source":"weather-forecast-api","pubsubname":"weather-forecast-api-pub-sub","topic":"weather-forecast-request","traceid":"00-00000000000000000000000000000000-0000000000000000-00","data":{"date":"2022-02-01T00:00:00"},"id":"3998d01e-3d70-4970-b2f3-a1903d32d2e6","datacontenttype":"application/json","type":"com.dapr.event.sent"}
-
My function signature and starting logs:
[FunctionName("ProcessWeatherForecastRequest")]
public async Task Run([DaprTopicTrigger("weather-forecast-pub-sub", Topic = "weather-forecast-request")] CloudEvent evt,ILogger log)
{
log.LogInformation($"{nameof(ProcessWeatherForecastRequest)} function triggered.");
log.LogInformation("Simulating 30 seconds latency for background processing...");
...
- I never see the starting logs and the messages are not being consumed from the topic subscription...
I was only exposing port 80 for the background process container while Dapr Azure Functions Extensions are listening on 3001. Started to work after exposing port 3001 from the container. Closing this.
Actually exposing 3001 was useless. My last attempt worked (function triggered) because apparently I already had one instance of the container running. My containerized function behind Azure Container Apps runs in serverless mode (replicas 0-3) so as soon as it scales back in to 0, will never be triggered again. Is this a compatibility issues between Azure Container Apps and Dapr Azure Functions Extensions?
The same scale settings (0-3) work just fine for my other component, the asp.net core 6 Web Api: The latency of the first request is larger when the number of replicas drops to 0 but it scales out automatically.
For functions to be triggered by Dapr in ACA, minReplica must be set to 1, so that Dapr side doesn't die. That seems to be causing this issue.
Closing this issue for now because setting minReplica to 1 in ACA should solve the issue. Please feel free to reopen issue, if issue still persist.