首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否有方法在host.json文件中为天青函数的"extensionBundle“设置批处理大小?

是否有方法在host.json文件中为天青函数的"extensionBundle“设置批处理大小?
EN

Stack Overflow用户
提问于 2022-03-17 19:18:40
回答 1查看 433关注 0票数 0

有办法让我用“host.json”键在我的extensionBundle文件中设置批处理大小吗?如下所示:

代码语言:javascript
运行
复制
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}

我见过其他人通过这样做来设置它:

代码语言:javascript
运行
复制
{
"extensions": {
  "queues": {
    "batchSize": 1,...

虽然我不确定如果我替换了扩展包,事情会不会破裂.有人知道我如何访问包并更改我想要更改的内容吗?或者我应该完全替换extensionBundle

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-20 07:44:04

In Azure函数, 示例host.json文件 由所有可能的选项组成:

代码语言:javascript
运行
复制
{
    "version": "2.0",
    "aggregator": {
        "batchSize": 1000,
        "flushTimeout": "00:00:30"
    },
    "extensions": {
        "blobs": {},
        "cosmosDb": {},
        "durableTask": {},
        "eventHubs": {},
        "http": {},
        "queues": {},
        "sendGrid": {},
        "serviceBus": {}
    },
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[1.*, 2.0.0)"
    },
    "functions": [ "QueueProcessor", "GitHubWebHook" ],
    "functionTimeout": "00:05:00",
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    },
    "logging": {
        "fileLoggingMode": "debugOnly",
        "logLevel": {
          "Function.MyFunction": "Information",
          "default": "None"
        },
        "applicationInsights": {
            "samplingSettings": {
              "isEnabled": true,
              "maxTelemetryItemsPerSecond" : 20,
              "evaluationInterval": "01:00:00",
              "initialSamplingPercentage": 100.0, 
              "samplingPercentageIncreaseTimeout" : "00:00:01",
              "samplingPercentageDecreaseTimeout" : "00:00:01",
              "minSamplingPercentage": 0.1,
              "maxSamplingPercentage": 100.0,
              "movingAverageRatio": 1.0,
              "excludedTypes" : "Dependency;Event",
              "includedTypes" : "PageView;Trace"
            },
            "enableLiveMetrics": true,
            "enableDependencyTracking": true,
            "enablePerformanceCountersCollection": true,            
            "httpAutoCollectionOptions": {
                "enableHttpTriggerExtendedInfoCollection": true,
                "enableW3CDistributedTracing": true,
                "enableResponseHeaderInjection": true
            },
            "snapshotConfiguration": {
                "agentEndpoint": null,
                "captureSnapshotMemoryWeight": 0.5,
                "failedRequestLimit": 3,
                "handleUntrackedExceptions": true,
                "isEnabled": true,
                "isEnabledInDeveloperMode": false,
                "isEnabledWhenProfiling": true,
                "isExceptionSnappointsEnabled": false,
                "isLowPrioritySnapshotUploader": true,
                "maximumCollectionPlanSize": 50,
                "maximumSnapshotsRequired": 3,
                "problemCounterResetInterval": "24:00:00",
                "provideAnonymousTelemetry": true,
                "reconnectInterval": "00:15:00",
                "shadowCopyFolder": null,
                "shareUploaderProcess": true,
                "snapshotInLowPriorityThread": true,
                "snapshotsPerDayLimit": 30,
                "snapshotsPerTenMinutesLimit": 1,
                "tempFolder": null,
                "thresholdForSnapshotting": 1,
                "uploaderProxy": null
            }
        }
    },
    "managedDependency": {
        "enabled": true
    },
    "retry": {
      "strategy": "fixedDelay",
      "maxRetryCount": 5,
      "delayInterval": "00:00:05"
    },
    "singleton": {
      "lockPeriod": "00:00:15",
      "listenerLockPeriod": "00:01:00",
      "listenerLockRecoveryPollingInterval": "00:01:00",
      "lockAcquisitionTimeout": "00:01:00",
      "lockAcquisitionPollingInterval": "00:00:03"
    },
    "watchDirectories": [ "Shared", "Test" ],
    "watchFiles": [ "myFile.txt" ]
}

host.json中设置batch size扩展示例格式是:

代码语言:javascript
运行
复制
{
    "version": "2.0",
    "extensions": {
        "queues": {
            "maxPollingInterval": "00:00:02",
            "visibilityTimeout" : "00:00:30",
            "batchSize": 16,
            "maxDequeueCount": 5,
            "newBatchThreshold": 8,
            "messageEncoding": "base64"
        }
    }
}

下面是我在Azure函数的batchSize文件中设置host.json的示例代码:

代码语言:javascript
运行
复制
```json

{

版本:"2.0",

“伐木”:{

代码语言:javascript
运行
复制
"applicationInsights": {
代码语言:javascript
运行
复制
  "samplingSettings": {
代码语言:javascript
运行
复制
    "isEnabled": true,
代码语言:javascript
运行
复制
    "excludedTypes": "Request"
代码语言:javascript
运行
复制
  }
代码语言:javascript
运行
复制
}

},

"extensionBundle":{

代码语言:javascript
运行
复制
"id": "Microsoft.Azure.Functions.ExtensionBundle",
代码语言:javascript
运行
复制
"version": "[2.*, 3.0.0)"

},

“扩展”:{

代码语言:javascript
运行
复制
"queues": {
代码语言:javascript
运行
复制
  "batchSize": 1
代码语言:javascript
运行
复制
},
代码语言:javascript
运行
复制
"http": {
代码语言:javascript
运行
复制
"routePrefix": "api",
代码语言:javascript
运行
复制
"maxOutstandingRequests": 200,
代码语言:javascript
运行
复制
"maxConcurrentRequests": 1
代码语言:javascript
运行
复制
}

}}

代码语言:javascript
运行
复制
No need to replace the **`extensionBundle`**, we need to set the required attributes in **`extensions`** block.

Another sample code example is like for storage queue trigger, to change frequency of the retry - `maxDequeueCount` value must be changed in **`host.json`** file and restart the function.

```javascript

{

版本:"2.0",

"extensionBundle":{

代码语言:javascript
运行
复制
"id": "Microsoft.Azure.Functions.ExtensionBundle",
代码语言:javascript
运行
复制
"version": "[2.*, 3.0.0)"

},

“扩展”:{

代码语言:javascript
运行
复制
"queues": {
代码语言:javascript
运行
复制
  "maxDequeueCount": 1
代码语言:javascript
运行
复制
}

}

}

代码语言:javascript
运行
复制
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71517906

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档