Keda: Azure ServiceBus Scaler with Azure Functions failes because of EntityPath in ConnectionString

Created on 13 Feb 2020  路  3Comments  路  Source: kedacore/keda

I have created a simple Azure Function that is triggered by messages being published to an Azure ServiceBus Queue.

The corresponding Scaler wants to have the ConnectionString including EntityPathotherwise, the keda-operator throws errors because connection-string is invalid.

However, if I keep EntityPath=queueName in my ConnectionString, Azure Function throws because it can't deal with EntityPath being specified in the ConnectionString.

Expected Behavior

I expect KEDA and Azure Functions (triggered by Service Bus Queue) to work :D

Actual Behavior

As mentioned in the introduction. When remove EntityPath from ConnectionString the keda-operator produces

{"level":"error","ts":1581580172.0928128,"logger":"azure_servicebus_scaler","msg":"error","error":"failed parsing connection string due to unmatched key value separated by '='","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\t/go/pkg/mod/github.com/go-logr/[email protected]/zapr.go:128\ngithub.com/kedacore/keda/pkg/scalers.(*azureServiceBusScaler).IsActive\n\tkeda/pkg/scalers/azure_servicebus_scaler.go:133\ngithub.com/kedacore/keda/pkg/handler.(*ScaleHandler).handleScaleDeployment\n\tkeda/pkg/handler/scale_loop.go:119\ngithub.com/kedacore/keda/pkg/handler.(*ScaleHandler).handleScale\n\tkeda/pkg/handler/scale_loop.go:45\ngithub.com/kedacore/keda/pkg/handler.(*ScaleHandler).HandleScaleLoop\n\tkeda/pkg/handler/scale_loop.go:28"}

Or if the connection string is correct - from KEDAs point of view - Azure Functions throws

System.ArgumentException: NamespaceConnectionString should not contain EntityPath. (Parameter 'namespaceConnectionString')
   at Microsoft.Azure.ServiceBus.ServiceBusConnection..ctor(String namespaceConnectionString, TimeSpan operationTimeout, RetryPolicy retryPolicy)
   at Microsoft.Azure.ServiceBus.Core.MessageReceiver..ctor(String connectionString, String entityPath, ReceiveMode receiveMode, RetryPolicy retryPolicy, Int32 prefetchCount)
   at Microsoft.Azure.WebJobs.ServiceBus.MessagingProvider.GetOrAddMessageReceiver(String entityPath, String connectionString) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.ServiceBus\MessagingProvider.cs:line 99

Steps to Reproduce the Problem

  1. Create an Azure Function with ServiceBus Queue Trigger
  2. Create Authorization Rule for Queue
  3. Specify ConnectionString in Kubernetes Secret
  4. Deploy Function to Kuberneretes

My Azure Function definition looks like this:

[FunctionName("DoSomething")]
[return: ServiceBus("outbound", Connection = "OutboundQueue")]
public static string Run([ServiceBusTrigger("inbound", Connection = "InboundQueue")]string message, ILogger log)
{

}

Specifications

  • KEDA Version: Installed via stable Helm chart
    NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
    keda keda 1 2020-02-12 16:09:45.906214 +0100 CET deployed keda-1.2.0 1.2.0

  • Kubernetes Version: (AKS)

Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2", GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89", GitTreeState:"clean", BuildDate:"2020-01-23T14:21:54Z", GoVersion:"go1.13.6", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.8", GitCommit:"c52f59bbba5fbf21fbb18e9a06f96e563fe4c20a", GitTreeState:"clean", BuildDate:"2020-01-31T20:00:26Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
  • FUNCTION CORE TOOLS: 3.0.2106
not-a-bug question

Most helpful comment

Relates to https://github.com/kedacore/keda/issues/215, but can be mitigated with TriggerAuthentication

All 3 comments

You can use TriggerAuthentication to use a different connection string than on the deployment, see https://github.com/kedacore/sample-dotnet-worker-servicebus-queue/blob/master/deploy/deploy-autoscaling.yaml#L2

I would recommend using TriggerAuthentication because:

  1. KEDA requires manage permissions, but your deployment probably only needs listen
  2. Use different keys for both components

Relates to https://github.com/kedacore/keda/issues/215, but can be mitigated with TriggerAuthentication

Thanks, works!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TAnas0 picture TAnas0  路  5Comments

jeffhollan picture jeffhollan  路  3Comments

aman-bansal picture aman-bansal  路  4Comments

alexakr picture alexakr  路  4Comments

jeffhollan picture jeffhollan  路  3Comments