Azure function with service bus binding to AKS

9/26/2019

I need to deploy my azure function to AKS using new KEDA event-driven autoscaler. Function binds to service bus queue and waiting for some messages to come. When I apply function deployment script to K8s, new deployment and scaled object are created, but 0 pods are scheduled to perform action (there are some messages in the queue).

I created simple function just to illustrate the same behavior. Deployment script

data:
  AzureWebJobsStorage: <value>
  FUNCTIONS_WORKER_RUNTIME: ZG90bmV0
  ServiceBusConnection: <value>
apiVersion: v1
kind: Secret
metadata:
  name: myqueuefunction
  namespace: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myqueuefunction
  namespace: default
  labels:
    app: myqueuefunction
spec:
  selector:
    matchLabels:
      app: myqueuefunction
  template:
    metadata:
      labels:
        app: myqueuefunction
    spec:
      containers:
      - name: myqueuefunction
        image: <container>
        env:
        - name: AzureFunctionsJobHost__functions__0
          value: MyQueueFunction
        envFrom:
        - secretRef:
            name: myqueuefunction
---
apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: myqueuefunction
  namespace: default
  labels:
    deploymentName: myqueuefunction
spec:
  scaleTargetRef:
    deploymentName: myqueuefunction
  triggers:
  - type: azure-servicebus
    metadata:
      type: serviceBusTrigger
      connection: ServiceBusConnection
      queueName: importedqueue
      name: myQueueItem
---

Function code:

[FunctionName("MyQueueFunction")]
public static void Run(
    [ServiceBusTrigger("importedqueue", Connection = "ServiceBusConnection")]
    Message myQueueItem, 
    ILogger log)
{
    log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}

K8S

Overview K8s overview

Deployment information K8s deployment

Replica information K8s replica

Autoscaler information K8s autoscaler

Can any one suggest how to debug it at least? Or what am I doing wrong?

-- Jevgenij Nekrasov
.net
azure
azure-functions
c#
kubernetes

1 Answer

9/28/2019

The best place to start debugging is looking at the logs of the KEDA pod. Something like kubectl logs -n keda keda-keda-<someGuid> which should tell you what it sees, if anything.

I ran into an issue before I need to try to repro where I needed to use a queue connection string directly rather than a namespace level connection string. Not sure if that resolves for you as well

https://github.com/kedacore/keda/issues/215

-- jeffhollan
Source: StackOverflow