Azure Functions 2.x 和更新版本的 host.json 參考 (機器翻譯)host.json reference for Azure Functions 2.x and later

host.json 中繼資料檔案所包含的全域設定選項會影響函式應用程式的所有函式。The host.json metadata file contains global configuration options that affect all functions for a function app. 本文列出從2.x 版的 Azure Functions 執行時間開始可用的設定。This article lists the settings that are available starting with version 2.x of the Azure Functions runtime.

注意

本文適用于 Azure Functions 2.x 和更新版本。This article is for Azure Functions 2.x and later versions. 有關 Functions 1.x 中 host.json 的參考,請參閱適用於 Azure Functions 1.x 的 host.json 參考For a reference of host.json in Functions 1.x, see host.json reference for Azure Functions 1.x.

其他函式應用程式設定選項會在您的 應用程式設定 中管理 (適用于已部署的應用程式) 或您在檔案 (進行本機開發) 的 local.settings.jsOther function app configuration options are managed in your app settings (for deployed apps) or your local.settings.json file (for local development).

與系結相關 host.js中的設定會同樣套用至函數應用程式中的每個函式。Configurations in host.json related to bindings are applied equally to each function in the function app.

您也可以使用應用程式設定來覆 寫或套用每個環境的設定You can also override or apply settings per environment using application settings.

範例 host.json 檔案Sample host.json file

下列範例 host.json 2.x 版的檔案,已指定所有可能的選項 (不包括僅供內部使用) 的任何選項。The following sample host.json file for version 2.x+ has all possible options specified (excluding any that are for internal use only).

{
    "version": "2.0",
    "aggregator": {
        "batchSize": 1000,
        "flushTimeout": "00:00:30"
    },
    "extensions": {
        "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
    },
    "singleton": {
      "lockPeriod": "00:00:15",
      "listenerLockPeriod": "00:01:00",
      "listenerLockRecoveryPollingInterval": "00:01:00",
      "lockAcquisitionTimeout": "00:01:00",
      "lockAcquisitionPollingInterval": "00:00:03"
    },
    "watchDirectories": [ "Shared", "Test" ]
}

本文的下列各節說明每個最上層屬性。The following sections of this article explain each top-level property. 除非另有說明,否則全部都是選擇項目。All are optional unless otherwise indicated.

aggregatoraggregator

指定計算 Application Insights 的計量時彙總多少函式引動過程。Specifies how many function invocations are aggregated when calculating metrics for Application Insights.

{
    "aggregator": {
        "batchSize": 1000,
        "flushTimeout": "00:00:30"
    }
}
屬性Property 預設Default 描述Description
batchSizebatchSize 10001000 要彙總的要求數目上限。Maximum number of requests to aggregate.
flushTimeoutflushTimeout 00:00:3000:00:30 要彙總的最長期間。Maximum time period to aggregate.

達到兩個限制的第一個限制時,會彙總函式引動過程。Function invocations are aggregated when the first of the two limits are reached.

applicationInsightsapplicationInsights

此設定是 logging 的子系。This setting is a child of logging.

控制 Application Insights 的選項,包括 取樣選項Controls options for Application Insights, including sampling options.

如需完整的 JSON 結構,請參閱先前的 範例 host.json fileFor the complete JSON structure, see the earlier example host.json file.

注意

記錄取樣可能會造成一些執行不會顯示在 Application Insights 監視器刀鋒視窗。Log sampling may cause some executions to not show up in the Application Insights monitor blade. 若要避免記錄取樣,請新增 excludedTypes: "Request"samplingSettings 值。To avoid log sampling, add excludedTypes: "Request" to the samplingSettings value.

屬性Property 預設Default 描述Description
samplingSettingssamplingSettings n/an/a 請參閱 applicationInsights. samplingSettingsSee applicationInsights.samplingSettings.
enableLiveMetricsenableLiveMetrics truetrue 啟用即時計量收集。Enables live metrics collection.
enableDependencyTrackingenableDependencyTracking truetrue 啟用相依性追蹤。Enables dependency tracking.
enablePerformanceCountersCollectionenablePerformanceCountersCollection truetrue 啟用 Kudu 效能計數器集合。Enables Kudu performance counters collection.
liveMetricsInitializationDelayliveMetricsInitializationDelay 00:00:1500:00:15 僅供內部使用。For internal use only.
HTTPAutoCollectionOptionshttpAutoCollectionOptions n/an/a 請參閱 applicationInsights. HTTPAutoCollectionOptionsSee applicationInsights.httpAutoCollectionOptions.
snapshotConfigurationsnapshotConfiguration n/an/a 請參閱 applicationInsights. snapshotConfigurationSee applicationInsights.snapshotConfiguration.

applicationInsights. samplingSettingsapplicationInsights.samplingSettings

屬性Property 預設Default 描述Description
isEnabledisEnabled truetrue 啟用或停用取樣。Enables or disables sampling.
maxTelemetryItemsPerSecondmaxTelemetryItemsPerSecond 2020 每部伺服器主機上每秒記錄的遙測專案的目標數目。The target number of telemetry items logged per second on each server host. 如果您的應用程式在多部主機上執行,請減少此值以維持在整體的流量速率內。If your app runs on many hosts, reduce this value to remain within your overall target rate of traffic.
evaluationIntervalevaluationInterval 01:00:0001:00:00 重新評估目前的遙測速率的間隔。The interval at which the current rate of telemetry is reevaluated. 評估是以移動平均來執行。Evaluation is performed as a moving average. 如果您的遙測會突然暴增,您可能想要縮短此間隔。You might want to shorten this interval if your telemetry is liable to sudden bursts.
initialSamplingPercentageinitialSamplingPercentage 100.0100.0 取樣程式開始時套用的初始取樣百分比,以動態方式改變百分比。The initial sampling percentage applied at the start of the sampling process to dynamically vary the percentage. 當您正在進行調試時,請勿減少值。Don't reduce value while you're debugging.
samplingPercentageIncreaseTimeoutsamplingPercentageIncreaseTimeout 00:00:0100:00:01 當取樣百分比值變更時,這個屬性會決定之後 Application Insights 可以再次引發取樣百分比來捕捉更多資料。When the sampling percentage value changes, this property determines how soon afterwards Application Insights is allowed to raise sampling percentage again to capture more data.
samplingPercentageDecreaseTimeoutsamplingPercentageDecreaseTimeout 00:00:0100:00:01 當取樣百分比值變更時,這個屬性會決定允許的 Application Insights 再次減少取樣百分比,以抓取較少的資料。When the sampling percentage value changes, this property determines how soon afterwards Application Insights is allowed to lower sampling percentage again to capture less data.
minSamplingPercentageminSamplingPercentage 0.10.1 當取樣百分比改變時,這個屬性會決定允許的最小取樣百分比。As sampling percentage varies, this property determines the minimum allowed sampling percentage.
maxSamplingPercentagemaxSamplingPercentage 100.0100.0 當取樣百分比改變時,這個屬性會決定允許的取樣百分比上限。As sampling percentage varies, this property determines the maximum allowed sampling percentage.
movingAverageRatiomovingAverageRatio 1.01.0 在計算移動平均時,指派給最新的值的權數。In the calculation of the moving average, the weight assigned to the most recent value. 使用等於或小於 1 的值。Use a value equal to or less than 1. 較小的值會讓演算法不易受突然的變更影響。Smaller values make the algorithm less reactive to sudden changes.
excludedTypesexcludedTypes nullnull 您不想要取樣的類型清單(以分號分隔)。A semi-colon delimited list of types that you don't want to be sampled. 可辨識的類型為: DependencyEventExceptionPageViewRequestTraceRecognized types are: Dependency, Event, Exception, PageView, Request, and Trace. 系統會傳送指定類型的所有實例;系統會取樣未指定的類型。All instances of the specified types are transmitted; the types that aren't specified are sampled.
includedTypesincludedTypes nullnull 要取樣的類型清單(以分號分隔);空白清單表示所有類型。A semi-colon delimited list of types that you want to be sampled; an empty list implies all types. 此處所列的覆寫類型中所列的類型 excludedTypesType listed in excludedTypes override types listed here. 可辨識的類型為: DependencyEventExceptionPageViewRequestTraceRecognized types are: Dependency, Event, Exception, PageView, Request, and Trace. 取樣指定類型的實例;未指定或隱含的型別會在沒有取樣的情況下傳輸。Instances of the specified types are sampled; the types that aren't specified or implied are transmitted without sampling.

applicationInsights. HTTPAutoCollectionOptionsapplicationInsights.httpAutoCollectionOptions

屬性Property 預設Default 描述Description
enableHttpTriggerExtendedInfoCollectionenableHttpTriggerExtendedInfoCollection truetrue 啟用或停用 HTTP 觸發程式的延伸 HTTP 要求資訊:連入要求相互關聯標頭、多重檢測金鑰支援、HTTP 方法、路徑和回應。Enables or disables extended HTTP request information for HTTP triggers: incoming request correlation headers, multi-instrumentation keys support, HTTP method, path, and response.
enableW3CDistributedTracingenableW3CDistributedTracing truetrue 啟用或停用 W3C 分散式追蹤通訊協定 (的支援,並開啟舊版的相互關聯架構) 。Enables or disables support of W3C distributed tracing protocol (and turns on legacy correlation schema). 若為 true,則預設 enableHttpTriggerExtendedInfoCollection 為啟用。Enabled by default if enableHttpTriggerExtendedInfoCollection is true. 如果 enableHttpTriggerExtendedInfoCollection 為 false,此旗標只會套用至連出要求,而不會套用至連入要求。If enableHttpTriggerExtendedInfoCollection is false, this flag applies to outgoing requests only, not incoming requests.
enableResponseHeaderInjectionenableResponseHeaderInjection truetrue 啟用或停用將多元件相互關聯標頭插入回應中的功能。Enables or disables injection of multi-component correlation headers into responses. 啟用插入可讓 Application Insights 在使用多個檢測金鑰時,建立應用程式對應。Enabling injection allows Application Insights to construct an Application Map to when several instrumentation keys are used. 若為 true,則預設 enableHttpTriggerExtendedInfoCollection 為啟用。Enabled by default if enableHttpTriggerExtendedInfoCollection is true. 如果為 false,則不適用此設定 enableHttpTriggerExtendedInfoCollectionThis setting doesn't apply if enableHttpTriggerExtendedInfoCollection is false.

applicationInsights. snapshotConfigurationapplicationInsights.snapshotConfiguration

如需快照集的詳細資訊,請參閱 .net 應用程式例外狀況的偵錯工具 ,以及 疑難排解啟用 Application Insights 快照偵錯工具或查看快照集的問題。For more information on snapshots, see Debug snapshots on exceptions in .NET apps and Troubleshoot problems enabling Application Insights Snapshot Debugger or viewing snapshots.

屬性Property 預設Default 描述Description
agentEndpointagentEndpoint nullnull 用來連接到 Application Insights 快照偵錯工具服務的端點。The endpoint used to connect to the Application Insights Snapshot Debugger service. 如果是 null,則會使用預設端點。If null, a default endpoint is used.
captureSnapshotMemoryWeightcaptureSnapshotMemoryWeight 0.50.5 檢查是否有足夠的記憶體可建立快照集時,提供給目前進程記憶體大小的加權。The weight given to the current process memory size when checking if there's enough memory to take a snapshot. 預期的值是大於0的適當小數 (0 < CaptureSnapshotMemoryWeight < 1) 。The expected value is a greater than 0 proper fraction (0 < CaptureSnapshotMemoryWeight < 1).
failedRequestLimitfailedRequestLimit 33 在停用遙測處理器之前,要求快照集失敗要求數目的限制。The limit on the number of failed requests to request snapshots before the telemetry processor is disabled.
handleUntrackedExceptionshandleUntrackedExceptions truetrue 啟用或停用追蹤未受 Application Insights 遙測追蹤的例外狀況。Enables or disables tracking of exceptions that aren't tracked by Application Insights telemetry.
isEnabledisEnabled truetrue 啟用或停用快照集集合Enables or disables snapshot collection
isEnabledInDeveloperModeisEnabledInDeveloperMode falsefalse 啟用或停用開發人員模式中的快照集集合。Enables or disables snapshot collection is enabled in developer mode.
isEnabledWhenProfilingisEnabledWhenProfiling truetrue 即使 Application Insights Profiler 正在收集詳細的分析會話,也會啟用或停用快照集建立。Enables or disables snapshot creation even if the Application Insights Profiler is collecting a detailed profiling session.
isExceptionSnappointsEnabledisExceptionSnappointsEnabled falsefalse 啟用或停用例外狀況的篩選。Enables or disables filtering of exceptions.
isLowPrioritySnapshotUploaderisLowPrioritySnapshotUploader truetrue 決定是否要在低於一般優先權的情況下執行 Snapshotuploader.exe 進程。Determines whether to run the SnapshotUploader process at below normal priority.
maximumCollectionPlanSizemaximumCollectionPlanSize 5050 可在一段時間內從1到9999的最大問題數目。The maximum number of problems that we can track at any time in a range from one to 9999.
maximumSnapshotsRequiredmaximumSnapshotsRequired 33 針對單一問題所收集的快照集數目上限,範圍從1到999。The maximum number of snapshots collected for a single problem, in a range from one to 999. 在您的應用程式中,可能會將問題視為個別的 throw 語句。A problem may be thought of as an individual throw statement in your application. 一旦針對問題收集的快照集數目達到此值,就不會針對該問題收集更多快照集,除非重設問題計數器 (查看 problemCounterResetInterval) ,然後 thresholdForSnapshotting 再重新達到限制。Once the number of snapshots collected for a problem reaches this value, no more snapshots will be collected for that problem until problem counters are reset (see problemCounterResetInterval) and the thresholdForSnapshotting limit is reached again.
problemCounterResetIntervalproblemCounterResetInterval 24:00:0024:00:00 從一分鐘到七天的範圍中,將問題計數器重設的頻率。How often to reset the problem counters in a range from one minute to seven days. 達到此間隔時,所有問題計數都會重設為零。When this interval is reached, all problem counts are reset to zero. 現有的問題已經達到執行快照集的臨界值,但尚未產生中的快照集數目 maximumSnapshotsRequired ,仍會保持作用中狀態。Existing problems that have already reached the threshold for doing snapshots, but haven't yet generated the number of snapshots in maximumSnapshotsRequired, remain active.
provideAnonymousTelemetryprovideAnonymousTelemetry truetrue 決定是否要將匿名的使用方式和錯誤遙測傳送給 Microsoft。Determines whether to send anonymous usage and error telemetry to Microsoft. 如果您與 Microsoft 聯繫,以協助疑難排解快照偵錯工具的問題,則可以使用此遙測。This telemetry may be used if you contact Microsoft to help troubleshoot problems with the Snapshot Debugger. 它也可用來監視使用模式。It is also used to monitor usage patterns.
reconnectIntervalreconnectInterval 00:15:0000:15:00 重新連線至快照偵錯工具端點的頻率。How often we reconnect to the Snapshot Debugger endpoint. 允許的範圍是一分鐘到一天。Allowable range is one minute to one day.
shadowCopyFoldershadowCopyFolder nullnull 指定用於陰影複製二進位檔的資料夾。Specifies the folder to use for shadow copying binaries. 如果未設定,則會依序嘗試下列環境變數所指定的資料夾: Fabric_Folder_App_Temp、LOCALAPPDATA、APPDATA、TEMP。If not set, the folders specified by the following environment variables are tried in order: Fabric_Folder_App_Temp, LOCALAPPDATA, APPDATA, TEMP.
shareUploaderProcessshareUploaderProcess truetrue 若為 true,則只有一個 Snapshotuploader.exe 實例會針對共用 InstrumentationKey 的多個應用程式收集和上傳快照集。If true, only one instance of SnapshotUploader will collect and upload snapshots for multiple apps that share the InstrumentationKey. 如果設定為 false,則 Snapshotuploader.exe 對每個 (ProcessName、InstrumentationKey) 元組都是唯一的。If set to false, the SnapshotUploader will be unique for each (ProcessName, InstrumentationKey) tuple.
snapshotInLowPriorityThreadsnapshotInLowPriorityThread truetrue 決定是否要在低 IO 優先權執行緒中處理快照集。Determines whether or not to process snapshots in a low IO priority thread. 建立快照集是快速的作業,但為了將快照集上傳至快照偵錯工具服務,必須先將它寫入磁片做為小型傾印。Creating a snapshot is a fast operation but, in order to upload a snapshot to the Snapshot Debugger service, it must first be written to disk as a minidump. 這會發生在 Snapshotuploader.exe 過程中。That happens in the SnapshotUploader process. 將此值設定為 true 會使用低優先順序 IO 來寫入小型傾印,而不會與您的應用程式競爭資源。Setting this value to true uses low-priority IO to write the minidump, which won't compete with your application for resources. 將此值設定為 false 可加速建立小型傾印,但會降低應用程式的速度。Setting this value to false speeds up minidump creation at the expense of slowing down your application.
snapshotsPerDayLimitsnapshotsPerDayLimit 3030 一天內允許的快照集數目上限 (24 小時) 。The maximum number of snapshots allowed in one day (24 hours). 這項限制也會在 Application Insights 服務端強制執行。This limit is also enforced on the Application Insights service side. 每個應用程式每日上傳的速率限制為 50 (也就是每個檢測金鑰) 。Uploads are rate limited to 50 per day per application (that is, per instrumentation key). 此值有助於防止建立將在上傳期間被拒絕的其他快照集。This value helps prevent creating additional snapshots that will eventually be rejected during upload. 值為零會完全移除限制,這不是建議的做法。A value of zero removes the limit entirely, which isn't recommended.
snapshotsPerTenMinutesLimitsnapshotsPerTenMinutesLimit 11 10分鐘內允許的快照集數目上限。The maximum number of snapshots allowed in 10 minutes. 雖然此值沒有上限,但請小心增加生產工作負載的效能,因為這可能會影響應用程式的效能。Although there is no upper bound on this value, exercise caution increasing it on production workloads because it could impact the performance of your application. 建立快照集是快速的,但建立快照集的小型傾印,並將其上傳至快照偵錯工具服務是一項速度較慢的作業,它會與您的應用程式競爭 (CPU 和 i/o) 的資源。Creating a snapshot is fast, but creating a minidump of the snapshot and uploading it to the Snapshot Debugger service is a much slower operation that will compete with your application for resources (both CPU and I/O).
tempFoldertempFolder nullnull 指定要寫入小型傾印和上載者記錄檔的資料夾。Specifies the folder to write minidumps and uploader log files. 如果未設定,則會使用 %TEMP%\DumpsIf not set, then %TEMP%\Dumps is used.
>thresholdforsnapshottingthresholdForSnapshotting 11 Application Insights 在要求快照集之前,需要查看例外狀況的次數。How many times Application Insights needs to see an exception before it asks for snapshots.
uploaderProxyuploaderProxy nullnull 覆寫快照集上載程式中使用的 proxy 伺服器。Overrides the proxy server used in the Snapshot Uploader process. 如果您的應用程式透過 proxy 伺服器連接到網際網路,您可能需要使用此設定。You may need to use this setting if your application connects to the internet via a proxy server. Snapshot Collector 會在應用程式的進程內執行,並且會使用相同的 proxy 設定。The Snapshot Collector runs within your application's process and will use the same proxy settings. 不過,快照集上傳程式會以個別的進程執行,您可能需要手動設定 proxy 伺服器。However, the Snapshot Uploader runs as a separate process and you may need to configure the proxy server manually. 如果這個值為 null,則 Snapshot Collector 會嘗試透過檢查 WebRequest DefaultWebProxy,並將值傳遞至快照集上傳者,來自動偵測 proxy 的位址。If this value is null, then Snapshot Collector will attempt to autodetect the proxy's address by examining System.Net.WebRequest.DefaultWebProxy and passing on the value to the Snapshot Uploader. 如果這個值不是 null,則不會使用自動偵測,而在此指定的 proxy 伺服器將用於快照集上載中。If this value isn't null, then autodetection isn't used and the proxy server specified here will be used in the Snapshot Uploader.

cosmosDbcosmosDb

可在 Cosmos DB 觸發程序和繫結中找到組態設定。Configuration setting can be found in Cosmos DB triggers and bindings.

durableTaskdurableTask

可在 Durable Functions 的繫結中找到組態設定。Configuration setting can be found in bindings for Durable Functions.

eventHubeventHub

可在事件中樞觸發程序和繫結中找到組態設定。Configuration settings can be found in Event Hub triggers and bindings.

擴充功能extensions

傳回包含所有繫結特定設定 (例如 httpeventHub) 之物件的屬性。Property that returns an object that contains all of the binding-specific settings, such as http and eventHub.

extensionBundleextensionBundle

延伸模組套件組合可讓您將一組相容的函式系結延伸模組新增至函式應用程式。Extension bundles let you add a compatible set of Functions binding extensions to your function app. 若要深入瞭解,請參閱 本機開發的延伸模組組合。To learn more, see Extension bundles for local development.

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[1.*, 2.0.0)"
    }
}

extensionBundle 中有下列屬性可供使用:The following properties are available in extensionBundle:

屬性Property 描述Description
idid Microsoft Azure 函式擴充功能套件組合的命名空間。The namespace for Microsoft Azure Functions extension bundles.
versionversion 要安裝的套件組合版本。The version of the bundle to install. 函式執行階段一律會挑選版本範圍或間隔所定義的最大允許版本。The Functions runtime always picks the maximum permissible version defined by the version range or interval. 上述版本值允許所有 1.0.0 版本以上的所有套件組合版本,但不包括 2.0.0。The version value above allows all bundle versions from 1.0.0 up to but not including 2.0.0. 如需詳細資訊,請參閱指定版本範圍的間隔標記法For more information, see the interval notation for specifying version ranges.

functionsfunctions

工作主機所執行的函式清單。A list of functions that the job host runs. 空陣列表示已執行所有函式。An empty array means run all functions. 預定只能在本機執行時使用。Intended for use only when running locally. 在 Azure 的函數應用程式中,您應該改為依照如何停用 Azure Functions 中的函式中的步驟來停用特定函式,而不是使用此設定。In function apps in Azure, you should instead follow the steps in How to disable functions in Azure Functions to disable specific functions rather than using this setting.

{
    "functions": [ "QueueProcessor", "GitHubWebHook" ]
}

functionTimeoutfunctionTimeout

指出所有函式的逾時持續期間。Indicates the timeout duration for all functions. 它會遵循 timespan 字串格式。It follows the timespan string format.

方案類型Plan type 預設 (最小) Default (min) 最大 (最小值) Maximum (min)
耗用量Consumption 55 1010
Premium1Premium1 3030 -1 (未系結的) 2-1 (unbounded)2
專用 (App Service) Dedicated (App Service) 3030 -1 (未系結的) 2-1 (unbounded)2

1 個 Premium 方案執行只保證60分鐘,但技術上沒有限制。1 Premium plan execution is only guaranteed for 60 minutes, but technically unbounded.
2 :值表示未系結的 -1 執行,但建議保持固定上限。2 A value of -1 indicates unbounded execution, but keeping a fixed upper bound is recommended.

{
    "functionTimeout": "00:05:00"
}

healthMonitorhealthMonitor

主機健康情況監視器的組態設定。Configuration settings for Host health monitor.

{
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    }
}
屬性Property 預設Default 描述Description
已啟用enabled truetrue 指定是否已啟用此功能。Specifies whether the feature is enabled.
healthCheckIntervalhealthCheckInterval 10 秒10 seconds 定期背景健康情況檢查之間的時間間隔。The time interval between the periodic background health checks.
healthCheckWindowhealthCheckWindow 2 分鐘2 minutes healthCheckThreshold 設定搭配使用的滑動時間範圍。A sliding time window used in conjunction with the healthCheckThreshold setting.
healthCheckThresholdhealthCheckThreshold 66 在主機回收起始之前,健康情況檢查可以失敗的最大次數。Maximum number of times the health check can fail before a host recycle is initiated.
counterThresholdcounterThreshold 0.800.80 系統會將效能計數器視為狀況不良的閾值。The threshold at which a performance counter will be considered unhealthy.

httphttp

可在 HTTP 觸發程序和繫結中找到組態設定。Configuration settings can be found in http triggers and bindings.

logginglogging

控制函數應用程式 (包括 Application Insights) 的記錄行為。Controls the logging behaviors of the function app, including Application Insights.

"logging": {
    "fileLoggingMode": "debugOnly",
    "logLevel": {
      "Function.MyFunction": "Information",
      "default": "None"
    },
    "console": {
        ...
    },
    "applicationInsights": {
        ...
    }
}
屬性Property 預設Default 描述Description
fileLoggingModefileLoggingMode debugOnlydebugOnly 定義已啟用何種檔案記錄層級。Defines what level of file logging is enabled. 選項為 neveralwaysdebugOnlyOptions are never, always, debugOnly.
logLevellogLevel n/an/a 為應用程式中的函式定義記錄類別篩選的物件。Object that defines the log category filtering for functions in the app. 2.x 版和更新版本會依照記錄類別篩選的 ASP.NET Core 配置。Versions 2.x and later follow the ASP.NET Core layout for log category filtering. 此設定可讓您篩選特定功能的記錄。This setting lets you filter logging for specific functions. 如需詳細資訊,請參閱 ASP.NET Core 文件中的記錄篩選For more information, see Log filtering in the ASP.NET Core documentation.
consoleconsole n/an/a 主控台記錄設定。The console logging setting.
applicationInsightsapplicationInsights n/an/a applicationInsights 設定。The applicationInsights setting.

consoleconsole

此設定是 logging 的子系。This setting is a child of logging. 它會在非處於偵錯模式時控制主控台記錄。It controls the console logging when not in debugging mode.

{
    "logging": {
    ...
        "console": {
          "isEnabled": "false"
        },
    ...
    }
}
屬性Property 預設Default 描述Description
isEnabledisEnabled falsefalse 啟用或停用主控台記錄。Enables or disables console logging.

managedDependencymanagedDependency

受控相依性是目前只有以 PowerShell 為基礎的函式支援的功能。Managed dependency is a feature that is currently only supported with PowerShell based functions. 它可讓服務自動管理相依性。It enables dependencies to be automatically managed by the service. enabled 屬性設定為時 truerequirements.psd1 就會處理檔案。When the enabled property is set to true, the requirements.psd1 file is processed. 釋放任何次要版本時,會更新相依性。Dependencies are updated when any minor versions are released. 如需詳細資訊,請參閱 PowerShell 文章中的 受控 相依性。For more information, see Managed dependency in the PowerShell article.

{
    "managedDependency": {
        "enabled": true
    }
}

queuesqueues

可在儲存體佇列觸發程序和繫結中找到組態設定。Configuration settings can be found in Storage queue triggers and bindings.

sendGridsendGrid

可在 SendGrid 觸發程序和繫結中找到組態設定。Configuration setting can be found in SendGrid triggers and bindings.

serviceBusserviceBus

可在服務匯流排觸發程序和繫結中找到組態設定。Configuration setting can be found in Service Bus triggers and bindings.

singletonsingleton

Singleton 鎖定行為的組態設定。Configuration settings for Singleton lock behavior. 如需詳細資訊,請參閱單一支援的 GitHub 問題For more information, see GitHub issue about singleton support.

{
    "singleton": {
      "lockPeriod": "00:00:15",
      "listenerLockPeriod": "00:01:00",
      "listenerLockRecoveryPollingInterval": "00:01:00",
      "lockAcquisitionTimeout": "00:01:00",
      "lockAcquisitionPollingInterval": "00:00:03"
    }
}
屬性Property 預設Default 描述Description
lockPeriodlockPeriod 00:00:1500:00:15 取得函式層級鎖定的期間。The period that function level locks are taken for. 鎖定會自動更新。The locks auto-renew.
listenerLockPeriodlistenerLockPeriod 00:01:0000:01:00 接聽程式鎖定所需的期間。The period that listener locks are taken for.
listenerLockRecoveryPollingIntervallistenerLockRecoveryPollingInterval 00:01:0000:01:00 啟動時無法取得接聽程式鎖定時,用於接聽程式鎖定復原的時間間隔。The time interval used for listener lock recovery if a listener lock couldn't be acquired on startup.
lockAcquisitionTimeoutlockAcquisitionTimeout 00:01:0000:01:00 執行階段將嘗試取得鎖定的時間量上限。The maximum amount of time the runtime will try to acquire a lock.
lockAcquisitionPollingIntervallockAcquisitionPollingInterval n/an/a 鎖定取得嘗試之間的間隔。The interval between lock acquisition attempts.

versionversion

此值指出 host.js的架構版本。This value indicates the schema version of host.json. "version": "2.0"目標為 v2 執行時間(或更新版本)的函式應用程式需要版本字串。The version string "version": "2.0" is required for a function app that targets the v2 runtime, or a later version. V2 和 v3 之間的架構變更沒有 host.js。There are no host.json schema changes between v2 and v3.

watchDirectorieswatchDirectories

應該監視其變更的一組共用程式碼目錄A set of shared code directories that should be monitored for changes. 請確定,這些目錄中的程式碼變更時,函式會反映變更。Ensures that when code in these directories is changed, the changes are picked up by your functions.

{
    "watchDirectories": [ "Shared" ]
}

覆寫值上的 host.jsOverride host.json values

在某些情況下,您可能會想要在特定環境的檔案 host.js中設定或修改特定設定,而不需要變更檔案本身的 host.js。There may be instances where you wish to configure or modify specific settings in a host.json file for a specific environment, without changing the host.json file itself. 您可以覆寫值的特定 host.js,以將相等的值建立為應用程式設定。You can override specific host.json values be creating an equivalent value as an application setting. 當執行時間以格式尋找應用程式設定時 AzureFunctionsJobHost__path__to__setting ,它會覆寫位於 JSON 中之設定的對等 host.jspath.to.settingWhen the runtime finds an application setting in the format AzureFunctionsJobHost__path__to__setting, it overrides the equivalent host.json setting located at path.to.setting in the JSON. 當表示為應用程式設定時, . 用來表示 JSON 階層的點 () 會以雙底線 (__) 取代。When expressed as an application setting, the dot (.) used to indicate JSON hierarchy is replaced by a double underscore (__).

例如,假設您想要在本機執行時停用應用程式深入解析取樣。For example, say that you wanted to disable Application Insight sampling when running locally. 如果您變更本機 host.js檔案以停用 Application Insights,則在部署期間可能會將這種變更推送至您的生產應用程式。If you changed the local host.json file to disable Application Insights, this change might get pushed to your production app during deployment. 更安全的做法是改為在檔案中建立應用程式設定 "AzureFunctionsJobHost__logging__applicationInsights__samplingSettings__isEnabled":"false" local.settings.jsonThe safer way to do this is to instead create an application setting as "AzureFunctionsJobHost__logging__applicationInsights__samplingSettings__isEnabled":"false" in the local.settings.json file. 您可以在下列檔案中看到 local.settings.json 未發行的內容:You can see this in the following local.settings.json file, which doesn't get published:

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "{storage-account-connection-string}",
        "FUNCTIONS_WORKER_RUNTIME": "{language-runtime}",
        "AzureFunctionsJobHost__logging__applicationInsights__samplingSettings__isEnabled":"false"
    }
}

後續步驟Next steps