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. 本文列出從 Azure Functions 執行時間2.x 版開始可用的設定。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.

其他函數應用程式設定選項的管理是在應用程式設定中進行。Other function app configuration options are managed in your app settings.

有些 host.json 設定只有在本機執行時,才會在 local.settings.json 檔案中使用。Some host.json settings are only used when running locally in the local.settings.json file.

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

下列範例主機. json檔案已指定所有可能的選項(不包括僅供內部使用的任何選項)。The following sample host.json file 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": 1.0, 
              "samplingPercentageIncreaseTimeout" : "00:00:01",
              "samplingPercentageDecreaseTimeout" : "00:00:01",
              "minSamplingPercentage": 0.1,
              "maxSamplingPercentage": 0.1,
              "movingAverageRatio": 1.0
            },
            "samplingExcludedTypes" : "Dependency;Event",
            "samplingIncludedTypes" : "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檔案。For 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. 若要避免記錄取樣,請將 samplingExcludedTypes: "Request" 新增至 applicationInsights 值。To avoid log sampling, add samplingExcludedTypes: "Request" to the applicationInsights value.

屬性Property 預設Default 說明Description
samplingSettingssamplingSettings n/an/a 請參閱applicationInsights. samplingSettingsSee applicationInsights.samplingSettings.
samplingExcludedTypessamplingExcludedTypes nullnull 您不想要取樣的類型清單(以分號分隔)。A semi-colon delimited list of types that you don't want to be sampled. 可辨識的類型為:相依性、事件、例外狀況、頁面檢視、要求、追蹤。Recognized types are: Dependency, Event, Exception, PageView, Request, Trace. 系統會傳送指定類型的所有實例;未指定的類型會進行取樣。All instances of the specified types are transmitted; the types that aren't specified are sampled.
samplingIncludedTypessamplingIncludedTypes nullnull 您想要取樣的類型清單(以分號分隔)。空白清單表示所有類型。A semi-colon delimited list of types that you want to be sampled; an empty list implies all types. 在這裡所列的 samplingExcludedTypes 覆寫類型中列出的類型。Type listed in samplingExcludedTypes override types listed here. 可辨識的類型為:相依性、事件、例外狀況、頁面檢視、要求、追蹤。Recognized types are: Dependency, Event, Exception, PageView, Request, Trace. 系統會傳送指定類型的所有實例;未指定的類型會進行取樣。All instances of the specified types are transmitted; the types that aren't specified are sampled.
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 1.01.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 0.10.1 當取樣百分比不同時,此屬性會決定允許的取樣百分比上限。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.

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). 如果 enableHttpTriggerExtendedInfoCollection 為 true,則預設為啟用。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. 如果 enableHttpTriggerExtendedInfoCollection 為 true,則預設為啟用。Enabled by default if enableHttpTriggerExtendedInfoCollection is true. 如果 enableHttpTriggerExtendedInfoCollection 為 false,則不適用此設定。This setting doesn't apply if enableHttpTriggerExtendedInfoCollection is false.

applicationInsights. snapshotConfigurationapplicationInsights.snapshotConfiguration

如需有關快照集的詳細資訊,請參閱.net 應用程式中的例外狀況的 Debug 錯快照集和疑難排解啟用 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,則每個(ProcessName,InstrumentationKey)元組的 Snapshotuploader.exe 都是唯一的。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.
版本version 要安裝的配套版本。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.

配套版本隨著套件在配套中的增加而變更。Bundle versions increment as packages in the bundle change. 當配套中的套件以主要版本遞增時,就會發生主要版本變更。Major version changes occur when packages in the bundle increment by a major version. 套件組合中的主要版本變更通常會與函式執行時間的主要版本變更一致。Major version changes in the bundle usually coincide with a change in the major version of the Functions runtime.

預設配套所安裝的目前延伸模組集合會在此副檔名 json檔案中列舉。The current set of extensions installed by the default bundle is enumerated in this extensions.json file.

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. 在無伺服器的使用情況方案中,有效範圍是從 1 秒到 10 分鐘,而預設值是 5 分鐘。In a serverless Consumption plan, the valid range is from 1 second to 10 minutes, and the default value is 5 minutes.

在 Premium 方案中,有效範圍是從1秒到60分鐘,而預設值為30分鐘。In the Premium plan, the valid range is from 1 second to 60 minutes, and the default value is 30 minutes.

在專用(App Service)方案中,沒有整體限制,而預設值為30分鐘。In a Dedicated (App Service) plan, there is no overall limit, and the default value is 30 minutes. 值為 -1 表示不受限制的執行,但建議保留固定的上限。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] 屬性設定為 [true] 時,就會處理 requirements.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

目標為 v2 執行階段的函數應用程式必須要有 "version": "2.0" 版本字串。The version string "version": "2.0" is required for a function app that targets the v2 runtime.

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" ]
}

後續步驟Next steps