0

I'm attempting to lock down internal documentation for best-practices when a function that is triggered by a queue needs to call a 3rd party API where throttling may be a concern. I've followed all the documentation I can find, whether MS official, stackoverflow or from the appropriate github repo.

I have used the CLI to set functionAppScaleLimit=1

 az resource update --resource-type Microsoft.Web/sites -g resourceGroupName -n functionAppName/config/web --set properties.functionAppScaleLimit=1

I manually set WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT to 1 in app settings.

I verified in Azure portal that under scale out settings the function app shows manual scale out and instance count of 1.

I have the following in host.json (I am not using FunctionsStartup attribute)

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingExcludedTypes": "Request",
      "samplingSettings": {
        "isEnabled": true
      }
    },
    "extensions": {
      "serviceBus": {
        "prefetchCount": 1,
        "messageHandlerOptions": {
          "autoComplete": true,
          "maxConcurrentCalls": 1,
          "maxAutoRenewDuration": "00:05:00"
        },
        "sessionHandlerOptions": {
          "autoComplete": true,
          "messageWaitTimeout": "00:00:30",
          "maxAutoRenewDuration": "00:55:00",
          "maxConcurrentSessions": 1
        }
      }
    }
  }
}

My service bus queue is session enabled. Messages process successfully in the function app (artificial delay added to test concurrency. However, when I test and send 100 messages to the queue (one at a time, not batched and my function is not setup to receive batched messages), 10 per session, I see all 10 sessions processing at the same time. I would expect to see one message from one session processing at any given time.

Any suggestions? Am I missing something obvious?

On a side note, during function execution, if I'm not using FunctionsStartup execution, what's the easiest way to log all settings including those from host.json that are actually used by the function?

Fred
  • 381
  • 2
  • 13

1 Answers1

1

Currently the extensions section structure defined in your host.json is under logging section which is incorrect. It should be outside of logging section.

Use the below one which defines the extensions section correctly.

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingExcludedTypes": "Request",
            "samplingSettings": {
                "isEnabled": true
            }
        }
    },
    "extensions": {
        "serviceBus": {
            "prefetchCount": 1,
            "messageHandlerOptions": {
                "autoComplete": true,
                "maxConcurrentCalls": 1,
                "maxAutoRenewDuration": "00:05:00"
            },
            "sessionHandlerOptions": {
                "autoComplete": true,
                "messageWaitTimeout": "00:00:30",
                "maxAutoRenewDuration": "00:55:00",
                "maxConcurrentSessions": 1
            }
        }
    }
}

Refer to this to read about host.json references.

user1672994
  • 10,509
  • 1
  • 19
  • 32
  • 1
    This is the part of the story where the question asker feels foolish after another set of eyes looks at his stupid simple issue and says, "hey git gud!" :D lol. Thanks. It felt like it had to be simple but I just wasn't seeing it. – Fred Jan 27 '21 at 17:00
  • It happens sometime with everyone :) – user1672994 Jan 27 '21 at 17:33