How to define multiple Azure TaskHub in host.json

115 Views Asked by At

I want to have 2 Durable Functions, that would use separated TaskHub's (different configurations, storage, etc). It's possible to use TaskHubName in the Function declaration, so it must be possible to define them in host.json. Just can't find any example how?

"extensions": {
    "http": { "routePrefix": "" },
    "durableTask": {
      "hubName": "TaskHub1",
   ..
      "hubName": "TaskHub2",

I tried to pass array in durableTask, but it's expecting an object.

1

There are 1 best solutions below

0
On

You can define multiple task hubs in your host.json file by using the durableTask extension. refer this link. Each task hub can have its own configuration, storage, and other settings.

host.json:

{
  "version": "2.0",
  "extensions": {
    "durableTask": [
      {
        "hubName": "TaskHub1",
        "storageProvider": "AzureStorage",
        "partitionCount": 16,
        "maxConcurrentActivityFunctions": 10,
        "maxConcurrentOrchestratorFunctions": 10
      },
      {
        "hubName": "TaskHub2",
        "storageProvider": "AzureStorage",
        "partitionCount": 16,
        "maxConcurrentActivityFunctions": 10,
        "maxConcurrentOrchestratorFunctions": 10
      }
    ]
  }
}

local.settings.json:

enter image description here

  • Configured task hubs names as TaskHub1 and TaskHub2. Each task hub uses the AzureStorage storage provider and has a partition count of 16. The maxConcurrentActivityFunctions and maxConcurrentOrchestratorFunctions settings specify the maximum number of activity and orchestrator functions that can run parallel.

enter image description here

I can see that the function triggering both the storage accounts with different tasks assigned.

store2azoct10: enter image description here

azoct10: enter image description here