How can I stop my function that uses ServiceBus from scaling up or having concurrency?

46 Views Asked by At

I have an AzureFunction that keeps on scaling and having concurrency. I have ServiceBus 7.x (so bigger than 5.x).
My function process messages in Batch and I´m using service bus topic.

My host.json is limiting the concurrency calls, with the following configurations:

{
  "version": "2.0",
  "extensions": {
    "http": {
      "routePrefix": "api",
      "maxOutstandingRequests": 200,
      "maxConcurrentRequests": 1,
      "dynamicThrottlesEnabled": true
    },
    "queues": {
      "batchSize": 1
    },
    "serviceBus": {
      "clientRetryOptions": {
        "mode": "exponential",
        "tryTimeout": "00:05:00",
        "delay": "00:00:00.80",
        "maxDelay": "00:01:00",
        "maxRetries": 3
      },
      "autoCompleteMessages": false,
      "maxConcurrentCalls": 1,
      "maxConcurrentSessions": 1,
      "": 100
    }
  },
  "concurrency": {
    "dynamicConcurrencyEnabled": false,
    "maximumFunctionConcurrency": 1,
    "cpuThreshold": 0.8,
    "snapshotPersistenceEnabled": false
  },
  "scale": {
    "scaleMetricsMaxAge": "00:02:00",
    "scaleMetricsSampleInterval": "00:00:10",
    "metricsPurgeEnabled": true,
    "isTargetScalingEnabled": false,
    "isRuntimeScalingEnabled": false
  },
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      },
      "loglevel": {
        "Azure.Core": "Error"
      }
    },
    "console": {
      "isEnabled": false,
      "DisableColors": true
    }
  }

Also, I have add functionAppScaleLimit=1 in the function configuration.

But all of this had not worked because I still have concurrent Operation_Id in my logs in applicationInsights.

enter image description here

What can I do to stop the concurrent operations in my function? I just need to them to process sequencially.

I've tried configuring ServiceBus.maxMessageBatchSize =1. I've added more configurations in host.json, that controled the concurrency. I shoud not have to configure anything special given that I use batch processing for the ServiceBus messages, and in the documentation from azure, they say that with batch you don't have concurreny.

0

There are 0 best solutions below