skip to Main Content

I’m looking to setup auto scale rules in my Azure container apps, based on messages in an Azure Service Bus Topic by subscriptions.

I do see the documentation on how to setup autoscale based on messages in a topic (or queue), but I haven’t seen anything on how to scale by a specific subscription.

We have many subscribers to each topic, and most of the subscribers represent a separate container app.

I’ve followed the documentation here: https://learn.microsoft.com/en-us/azure/container-apps/scale-app?pivots=azure-cli, but there’s no mention about subscriptions.

2

Answers


  1. Chosen as BEST ANSWER

    It was a little tricky to find the right documentation, but I ended up finding KEDA scaling information here, that helped a lot: https://azure.github.io/aca-dotnet-workshop/aca/09-aca-autoscale-keda/


  2. After exploring on your issue, I found that, currently there is no direct support for Azure Container Apps autoscaling based on messages in a specific subscription of a Service Bus Topic.

    The reference MSDoc provided by you doesn’t have any information on scaling replicas based on multiple service bus subscriptions with their topics.

    In order to increase the replicas based on the messages count, you can use Azure queue storage by specifying rule type as --scale-rule-type azure-queue with the help of managed identity trigger authentication.

    az containerapp create --resource-group DefaultResourceGroup-EUS --name xxx --environment managedEnvironment-DefaultResource-9470 --user-assigned xxx --scale-rule-name azure-queue --scale-rule-type azure-queue --scale-rule-metadata "accountName=xxx" "queueName=newque" "queueLength=1" --scale-rule-identity "user_assigned_identity_ID"
    

    To just mention the subscription name in metadata, you can pass it along with the --scale-rule-metadata argument as shown in the below format.

    az containerapp create --name newcontsai --resource-group DefaultResourceGroup-EUS --environment managedEnvironment-DefaultResource-9470 --image xx --min-replicas 0 --max-replicas 5 --secrets "connection-string-secret=Endpoint=sb://buscon.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=5mINrxxxxxbJF3dzQ=" --scale-rule-name azure-servicebus--rule --scale-rule-type azure-servicebus 
    --scale-rule-metadata "queueName=newque" 
                           "namespace=buscon" 
                           "messageCount=5" 
                           "subscriptionName=queusub" --scale-rule-auth "connection=connection-string-secret"
    

    enter image description here

    enter image description here

    Reference:

    1. Blog for more relevant information on message count in service bus.

    2. Also check this MSDoc to use event sub scaler for subscription wise scaling with event hub functions..

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search