Example setup to trigger jobs on AKS to consume and process messages from Azure Queue Storage with KEDA.
The following example will add 100 messages to Queue Storage. KEDA will watch the queue and start Kubernetes Jobs to calculate the n-th Fibonacci number recursively (load simulation).
You can set up your AKS cluster's user nodepool with autoscaler to always scale to 0 node once the queue is processed. The autoscaler will increase the node count when KEDA creates new pods and the scheduler cannot schedule it on any node.
- az cli
- Python
- Create a Queue Storage
- Provision an AKS cluster
- Setup KEDA on your AKS
- Create an Azure Container Registry or use your own registry
In case you are using ACR you can build and push the python image to your repository:
az acr build --image pyjob --registry <your-acr-instance> --file Dockerfile .
In this example the connection method to the Queue Storage is with connection string. For that we need to create a secret in Kubernetes:
- Create namespace:
kubectl create namespace kedajob - Connection string:
--from-literal=AZURE_STORAGE_CONNECTION_STRING='your_connection_string' -n kedajob - Queue name:
kubectl create secret generic queue-name --from-literal=AZURE_STORAGE_QUEUE_NAME='your_queue_name' -n kedajob
There are several other authentication options, for example using managed identities.
The azurequeue_scaledobject_jobs.yaml contains the KEDA scaler configuration and the authentication details.
kubectl apply -f .\azurequeue_scaledobject_jobs.yaml
Set the following environment variables (PowerShell)
- Queue Storage connection string:
$env:AZURE_STORAGE_CONNECTION_STRING="your_connection_string" - Queue name:
$env:AZURE_STORAGE_QUEUE_NAME="your_queue_name"
Restart CLI after setting them.
The setup is complete, you can add messages to the queue and observe KEDA in action.
Use the python files in the queue_ops folder to work with the Queue Storage
ops-addmsg.pyto add new messages to the Queue Storageops-clearq.pyto clear the queueops-qlength.pyto observe the queue length
KEDA monitors the Queue Storage every 10 seconds. Once there are messages, the cluster autoscaler will add new nodes based on pending pod count and autoscaling settings. Once the nodes come online the scheduler will schedule the pending pods on them.

You can observe the KEDA logs by checking the operator logs.
kubectl logs <your-keda-operator-pod> -n kube-system