Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

host.json Settings Ignored For Service Bus Queue Triggered Function App Function

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?

question from:https://stackoverflow.com/questions/65910399/host-json-settings-ignored-for-service-bus-queue-triggered-function-app-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...