How to enable multi-instances of duralbe function app run in parallel
Hi,
I have an Azure durable function app in a container. When I create it using az CLI with argument "--plan", it works as I expect (multiple instances can run in parallel if I concurrently call my function mutliple times), but when I create it using az CLI with argument "--environment" and "--workload-profile-name", only ONE instance can run even if I call the function multiple times concurrently. I want to know how to enable multiple instances to run in paraellel when I create the durable function app with argument "--environment" and "--workload-profile-name".
(Due to the high workload, multiple instances are required to run concurrently. If i create my function app with argument "--plan", I need to pay for ONE instance even if I don't call my function. That is the reason I want to create my function app with argument "--environment" and "--workload-profile-name")
Thank you very much!
Azure Functions
-
Shireesha Eeraboina (Quadrant Resource LLC) 575 Reputation points • Microsoft Vendor
2025-01-02T05:51:23.3533333+00:00 Hi @Juntang Dai (Centific Technologies Inc) ,
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
To address your issue where only a single instance of your Azure Durable Function is running concurrently when using the --environment and --workload-profile-name arguments with the Azure CLI, you are encountering a difference in how the function app is being provisioned and scaled.
- First you need to make sure that the app is configured to allow scaling beyond one instance. You can set the scaling rules using the Azure CLI, ARM templates, or the Azure portal.
- Then ensure that your function app is on a Premium plan or Elastic Premium plan, which supports auto-scaling and running multiple instances. When using a Premium or Isolated environment, this configuration allows multiple instances to scale up once the function app plan is set to a Premium or Isolated plan, enable autoscaling based on demand and you can do this through the Azure portal by navigating to your function app, then to the Scale-out (App Service Plan) section. There you can set the scale to allow the app to scale based on request load.
- After confirming your scaling settings are correct, ensure that your Azure Durable Function is deployed correctly. The app should now be able to scale out to multiple instances based on load once your app is set up, you can monitor scaling and performance using Azure Application Insights or through the Azure portal to verify that multiple instances are indeed running in parallel and scaling as needed.
Also refer the below attached document regarding the concurrency
Concurrency in Azure Functions | Microsoft Learn
If you have any further queries, please feel free to reach out to us.
Thank you, Have a great day.
-
Juntang Dai (Centific Technologies Inc) 0 Reputation points • Microsoft Vendor
2025-01-02T07:19:58.3566667+00:00 Hi Shireesha,
Thank a lot for your detail answer. I did what you wrote before I ask this question here.Unfortuanately, your answer did not focus on my question.
Just as what I have said in my question, I don't want to pay for ONE instance when I do not call my function. If I use a plan (Premium plan or Elastic Premium plan) to run my durable function app, I need to pay ONE instance during the period I do not call my function. I want my function is scaled up to ZERO instance and can automatically be scaled up to "n" instance based on workload.
Thank you very much, have a great day!
-
Juntang Dai (Centific Technologies Inc) 0 Reputation points • Microsoft Vendor
2025-01-02T07:35:32.14+00:00 Hi Shireesha,
Thanks a lot for your detail answer. Unfortunately, it seems like you did not focus on my question. I did what you said your answering before I ask my question here.
If I use plan (Premium plan or Elastic Premium plan) to run my function, then I need to pay for ONE instance during the period I do not call my function.
Thank you very much!
-
Shireesha Eeraboina (Quadrant Resource LLC) 575 Reputation points • Microsoft Vendor
2025-01-02T09:43:32.6866667+00:00 Hi @Juntang Dai (Centific Technologies Inc) ,
Sorry for the inconvenience happened now we got it that you're aiming to avoid paying for an instance when your function app is idle (i.e., when it's not being called), and you'd prefer it to scale to zero instances when idle, while still scaling up automatically to multiple instances based on the workload when calls are made.
If you want to avoid paying for idle capacity, the Consumption Plan will be best option because it scales down to zero instances when idle. However, make sure that there are limitations with Durable Functions on the Consumption Plan (e.g., execution duration limits and other constraints) also if your use case for Durable Functions doesn't need the advanced features of the Premium or Isolated plans (e.g., long-running workflows, custom scale settings, etc.), the Consumption Plan will meet your needs for cost efficiency.
Thankyou.
-
Juntang Dai (Centific Technologies Inc) 0 Reputation points • Microsoft Vendor
2025-01-03T06:57:36.67+00:00 Hi Shireesha,
Thank you very much for your advice to use Consumption Plan.
In order to use Consumption Plan, I tried following az CLI to create my function app:
az functionapp create --name func-couponchecker --storage-account couponchecker --consumption-plan-location westus2 --resource-group CouponIntelligence --functions-version 4 --runtime python --os-type Linux --image couponchecker.azurecr.io/edgeimage:v1.0.0 --assign-identity
But the function app can not be visited. From Azure portal, I can not see the function list even if clicked the refresh button. I am not sure if the cmd above is correct.
I have used following az CLI to create my function app using Premium Plan:
az functionapp create --name func-couponchecker --storage-account couponchecker --resource-group CouponIntelligence --functions-version 4 --runtime python --image couponchecker.azurecr.io/edgeimage:v1.0.0 --assign-identity --plan couponchecker-premium-planThe function app created by above cmd works. Following is the what I have seen from portal:
Could you please see my command to create function app using Consumption Plan and tell me if there are any errors in the command?
Thank you very much!
-
Shireesha Eeraboina (Quadrant Resource LLC) 575 Reputation points • Microsoft Vendor
2025-01-03T09:47:00.9933333+00:00 Hi @Juntang Dai (Centific Technologies Inc) ,
It looks like the main issue here is that the Consumption Plan has some limitations and restrictions compared to the Premium Plan, and it might not fully support all the features you're trying to use in the Azure CLI command.
You are trying to use a custom Docker image (couponchecker.azurecr.io/edgeimage:v1.0.0) with the Consumption Plan, but this is not supported on Consumption Plan because it requires a Premium Plan or Dedicated Plan for running custom containers. Whereas the Premium Plan supports both custom images and more advanced features, which is why your second command works when you use the --plan couponchecker-premium-plan
Updated Command for Consumption Plan (without custom Docker image)
az functionapp create \ --name func-couponchecker \ --storage-account couponchecker \ --consumption-plan-location westus2 \ --resource-group CouponIntelligence \ --functions-version 4 \ --runtime python \ --os-type Linux \ --assign-identity
The above command removes the --image option and uses the default Python runtime on the Consumption Plan. The function app should now be created and be accessible.
I hope the above provided information might help you, if you have any further queries, please feel free to reach out to us.
Thank you, Have a great day.
-
Juntang Dai (Centific Technologies Inc) 0 Reputation points • Microsoft Vendor
2025-01-06T02:51:25.76+00:00 Hi Shireesha,
I can not remove --image when creating my Function App. My function needs to run Microsoft Edge and the driver of Microsoft Edge. And Windows operation system can not provide suitable Edge and driver, so we need to install them in docker image.
I am not sure if we can install the sutable version of Edge's driver exe file in windows.
Thanks a lot!
-
Juntang Dai (Centific Technologies Inc) 0 Reputation points • Microsoft Vendor
2025-01-06T09:09:14.55+00:00 Hi Shireesha,
If we can not install the sutable version of Edge's driver exe file in windows host of Azure Durable Function App, we need to build our Durable Function App in docker image.
From above document of Function App, we can see only Premimum plan, Dedicated plan(App service) and Container App are in the range of our options.
From above document, we can see both Premimum plan and App Service(Dedicated plan) have the feature "Minimum of 1 instance required", this is not cost efficient when our function app is idle, so we can only choice the plan "Container App".
In my orignal question I mentioned that we have created our function app with argument "--environment" and "--workload-profile-name" (this is the same as selecting "Container Apps Environment to create the function app"), but the problem is that only ONE instance can run even if I call the function multiple times concurrently.
Hope my explanation above has clarified my question to you.
Thank you very much!
-
Shireesha Eeraboina (Quadrant Resource LLC) 575 Reputation points • Microsoft Vendor
2025-01-06T10:23:02.1266667+00:00 Hi @Juntang Dai (Centific Technologies Inc) ,
From the details that you have shared Microsoft Edge and its driver to be installed in a Docker container, and you need to run the function with a custom Docker image, let's focus on the Premium Plan or Dedicated Plan as these are the only two plans that support custom Docker images, including running Microsoft Edge with the appropriate driver.
In Azure Container Apps, scaling is managed by CPU and memory settings. If you only have one container instance running, even though you're calling the function multiple times, Azure may not automatically scale out to multiple instances to handle concurrent requests to enable scaling and allow multiple instances of your container to run in parallel, you'll need to:
- Set up autoscaling for the Container App and adjust the scaling configuration to allow scaling based on requests or resource utilization.
Also let me provide you with some specific guidance, both for the Premium Plan and addressing your concerns about the Windows environment and the Edge driver.
As from the details I can understand that you are using a custom Docker image with the Microsoft Edge browser and Edge WebDriver, you'll need to use the Premium Plan as the Consumption Plan cannot support custom images. Here’s the correct approach for creating the Function App with the Premium Plan.
Since you're using Linux for your function app and need to install Microsoft Edge and its WebDriver, you'll need to ensure that your Docker image is correctly set up for this.
Also, you mentioned concerns about installing the Edge driver on Windows. However, since you're running this in a Linux-based container, the Windows OS issue doesn’t apply here. The Linux environment in your container can fully support Microsoft Edge (for Linux) and its corresponding driver for Linux.
However, if you must use Windows-based containers, you will need to move to a Windows-based App Service Plan. But for most use cases, running a Linux-based container with Microsoft Edge should be sufficient.
I hope the above provided information is helpful to understand better and resolve your issue.
Thankyou.
Sign in to comment