您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Azure Functions 的应用设置参考App settings reference for Azure Functions

函数应用中的应用设置包含对该函数应用的所有函数产生影响的全局配置选项。App settings in a function app contain global configuration options that affect all functions for that function app. 在本地运行时,这些设置将作为本地环境变量进行访问。When you run locally, these settings are accessed as local environment variables. 本文列出可在函数应用中使用的应用设置。This article lists the app settings that are available in function apps.

可以通过以下几种方法添加、更新和删除函数应用设置:There are several ways that you can add, update, and delete function app settings:

host.json 文件和 local.settings.json 文件中提供了其他全局配置选项。There are other global configuration options in the host.json file and in the local.settings.json file.

APPINSIGHTS_INSTRUMENTATIONKEYAPPINSIGHTS_INSTRUMENTATIONKEY

使用 Application Insights 时的 Application Insights 检测密钥。The Application Insights instrumentation key if you're using Application Insights. 请参阅监视 Azure FunctionsSee Monitor Azure Functions.

密钥Key 示例值Sample value
APPINSIGHTS_INSTRUMENTATIONKEYAPPINSIGHTS_INSTRUMENTATIONKEY 5dbdd5e9-af77-484b-9032-64f83bb83bb5dbdd5e9-af77-484b-9032-64f83bb83bb

AZURE_FUNCTIONS_ENVIRONMENTAZURE_FUNCTIONS_ENVIRONMENT

在函数运行时版本2.x 中,基于运行时环境配置应用程序行为。In version 2.x of the Functions runtime, configures app behavior based on the runtime environment. 此值在初始化期间会被读取。This value is read during initialization. 可以将 AZURE_FUNCTIONS_ENVIRONMENT 设置为任何值,但支持三个值开发过渡生产You can set AZURE_FUNCTIONS_ENVIRONMENT to any value, but three values are supported: Development, Staging, and Production. 如果未设置 AZURE_FUNCTIONS_ENVIRONMENT,则默认情况下,在本地环境中 Development,在 Azure 上 ProductionWhen AZURE_FUNCTIONS_ENVIRONMENT isn't set, it defaults to Development on a local environment and Production on Azure. 应使用此设置,而不是 ASPNETCORE_ENVIRONMENT 设置运行时环境。This setting should be used instead of ASPNETCORE_ENVIRONMENT to set the runtime environment.

AzureWebJobsDashboardAzureWebJobsDashboard

用于存储日志并在门户上的“监视”选项卡中显示这些日志的可选存储帐户连接字符串。Optional storage account connection string for storing logs and displaying them in the Monitor tab in the portal. 存储帐户必须是支持 Blob、队列和表的通用帐户。The storage account must be a general-purpose one that supports blobs, queues, and tables. 请参阅存储帐户存储帐户要求See Storage account and Storage account requirements.

密钥Key 示例值Sample value
AzureWebJobsDashboardAzureWebJobsDashboard DefaultEndpointsProtocol=https;AccountName=[name];AccountKey=[key]DefaultEndpointsProtocol=https;AccountName=[name];AccountKey=[key]

提示

有关性能和体验,建议使用 APPINSIGHTS_INSTRUMENTATIONKEY 和 App Insights 进行监视,而不使用 AzureWebJobsDashboardFor performance and experience, it is recommended to use APPINSIGHTS_INSTRUMENTATIONKEY and App Insights for monitoring instead of AzureWebJobsDashboard

AzureWebJobsDisableHomepageAzureWebJobsDisableHomepage

true 表示禁用针对函数应用根 URL 显示的默认登录页。true means disable the default landing page that is shown for the root URL of a function app. 默认值为 falseDefault is false.

密钥Key 示例值Sample value
AzureWebJobsDisableHomepageAzureWebJobsDisableHomepage true

如果省略此应用设置或将其设置为 false,则会显示类似于以下示例的页来响应 URL <functionappname>.azurewebsites.netWhen this app setting is omitted or set to false, a page similar to the following example is displayed in response to the URL <functionappname>.azurewebsites.net.

函数应用登录页

AzureWebJobsDotNetReleaseCompilationAzureWebJobsDotNetReleaseCompilation

true 表示在编译 .NET 代码时使用“发布”模式;false 表示使用“调试”模式。true means use Release mode when compiling .NET code; false means use Debug mode. 默认值为 trueDefault is true.

密钥Key 示例值Sample value
AzureWebJobsDotNetReleaseCompilationAzureWebJobsDotNetReleaseCompilation true

AzureWebJobsFeatureFlagsAzureWebJobsFeatureFlags

要启用的 beta 功能的逗号分隔列表。A comma-delimited list of beta features to enable. 由这些标志启用的 Beta 功能尚未准备好用于生产,但在发布这些功能之前可针对试验目的启用这些功能。Beta features enabled by these flags are not production ready, but can be enabled for experimental use before they go live.

密钥Key 示例值Sample value
AzureWebJobsFeatureFlagsAzureWebJobsFeatureFlags feature1,feature2feature1,feature2

AzureWebJobsSecretStorageTypeAzureWebJobsSecretStorageType

指定用于密钥存储的存储库或提供程序。Specifies the repository or provider to use for key storage. 目前,支持的存储库包括 blob 存储(“Blob”)和本地文件系统(“Files”)。Currently, the supported repositories are blob storage ("Blob") and the local file system ("Files"). 默认为在版本 2 中使用 blob,在版本 1 中使用文件系统。The default is blob in version 2 and file system in version 1.

密钥Key 示例值Sample value
AzureWebJobsSecretStorageTypeAzureWebJobsSecretStorageType 文件Files

AzureWebJobsStorageAzureWebJobsStorage

Azure Functions 运行时针对除 HTTP 触发的函数以外的其他所有函数使用此存储帐户连接字符串。The Azure Functions runtime uses this storage account connection string for all functions except for HTTP triggered functions. 存储帐户必须是支持 Blob、队列和表的通用帐户。The storage account must be a general-purpose one that supports blobs, queues, and tables. 请参阅存储帐户存储帐户要求See Storage account and Storage account requirements.

密钥Key 示例值Sample value
AzureWebJobsStorageAzureWebJobsStorage DefaultEndpointsProtocol=https;AccountName=[name];AccountKey=[key]DefaultEndpointsProtocol=https;AccountName=[name];AccountKey=[key]

AzureWebJobs_TypeScriptPathAzureWebJobs_TypeScriptPath

用于 TypeScript 的编译器的路径。Path to the compiler used for TypeScript. 允许根据需要重写默认值。Allows you to override the default if you need to.

密钥Key 示例值Sample value
AzureWebJobs_TypeScriptPathAzureWebJobs_TypeScriptPath %HOME%\typescript%HOME%\typescript

FUNCTION_APP_EDIT_MODEFUNCTION_APP_EDIT_MODE

指示是否启用了 Azure 门户中的编辑。Dictates whether editing in the Azure portal is enabled. 有效值为“readwrite”和“readonly”。Valid values are "readwrite" and "readonly".

密钥Key 示例值Sample value
FUNCTION_APP_EDIT_MODEFUNCTION_APP_EDIT_MODE readonlyreadonly

FUNCTIONS_EXTENSION_VERSIONFUNCTIONS_EXTENSION_VERSION

要在此函数应用中使用的 Functions 运行时版本。The version of the Functions runtime to use in this function app. 波浪符加主要版本号表示使用该主要版本的最新版本(例如“~2”)。A tilde with major version means use the latest version of that major version (for example, "~2"). 当同一主要版本的新版本可用时,会自动在函数应用中安装新版本。When new versions for the same major version are available, they are automatically installed in the function app. 若要让应用固定使用特定的版本,请使用完整版本号(例如“2.0.12345”)。To pin the app to a specific version, use the full version number (for example, "2.0.12345"). 默认为“~2”。Default is "~2". ~1 的值将应用固定到运行时的版本 1.x。A value of ~1 pins your app to version 1.x of the runtime.

密钥Key 示例值Sample value
FUNCTIONS_EXTENSION_VERSIONFUNCTIONS_EXTENSION_VERSION ~2~2

函数_WORKER_进程_计数FUNCTIONS_WORKER_PROCESS_COUNT

指定语言工作进程的最大数量,默认值为 1Specifies the maximum number of language worker processes, with a default value of 1. 允许的最大值为 10The maximum value allowed is 10. 函数调用在语言工作进程之间均匀分布。Function invocations are evenly distributed among language worker processes. 每隔10秒生成一次 Language 工作进程,直到达到函数_WORKER_进程_计数。Language worker processes are spawned every 10 seconds until the count set by FUNCTIONS_WORKER_PROCESS_COUNT is reached. 使用多语言工作进程与缩放不同。Using multiple language worker processes is not the same as scaling. 如果你的工作负荷混合使用了大量的 CPU 和 i/o 界限调用,请考虑使用此设置。Consider using this setting when your workload has a mix of CPU-bound and I/O-bound invocations. 此设置适用于所有 non-.NET 语言。This setting applies to all non-.NET languages.

密钥Key 示例值Sample value
函数_WORKER_进程_计数FUNCTIONS_WORKER_PROCESS_COUNT 22

FUNCTIONS_WORKER_RUNTIMEFUNCTIONS_WORKER_RUNTIME

要在函数应用中加载的语言辅助角色运行时。The language worker runtime to load in the function app. 这将对应于应用程序中正在使用的语言(例如,“dotnet”)。This will correspond to the language being used in your application (for example, "dotnet"). 对于多种语言的函数,需要将它们发布到多个应用,每个应用都具有相应的辅助角色运行时值。For functions in multiple languages you will need to publish them to multiple apps, each with a corresponding worker runtime value. 有效值为 dotnet (C#/F#)、node (JavaScript/TypeScript)、java (Java)、powershell (PowerShell)和 python (Python)。Valid values are dotnet (C#/F#), node (JavaScript/TypeScript), java (Java), powershell (PowerShell), and python (Python).

密钥Key 示例值Sample value
FUNCTIONS_WORKER_RUNTIMEFUNCTIONS_WORKER_RUNTIME dotnetdotnet

WEBSITE_CONTENTAZUREFILECONNECTIONSTRINGWEBSITE_CONTENTAZUREFILECONNECTIONSTRING

仅限 & 高级计划。For consumption & Premium plans only. 存储函数应用代码和配置的存储帐户的连接字符串。Connection string for storage account where the function app code and configuration are stored. 请参阅创建函数应用See Create a function app.

密钥Key 示例值Sample value
WEBSITE_CONTENTAZUREFILECONNECTIONSTRINGWEBSITE_CONTENTAZUREFILECONNECTIONSTRING DefaultEndpointsProtocol=https;AccountName=[name];AccountKey=[key]DefaultEndpointsProtocol=https;AccountName=[name];AccountKey=[key]

WEBSITE_CONTENTSHAREWEBSITE_CONTENTSHARE

仅限 & 高级计划。For consumption & Premium plans only. 函数应用代码和配置的文件路径。The file path to the function app code and configuration. 与 WEBSITE_CONTENTAZUREFILECONNECTIONSTRING 结合使用。Used with WEBSITE_CONTENTAZUREFILECONNECTIONSTRING. 默认值是以函数应用名称开头的唯一字符串。Default is a unique string that begins with the function app name. 请参阅创建函数应用See Create a function app.

密钥Key 示例值Sample value
WEBSITE_CONTENTSHAREWEBSITE_CONTENTSHARE functionapp091999e2functionapp091999e2

WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUTWEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT

函数应用可以横向扩展到的最大实例数。The maximum number of instances that the function app can scale out to. 默认值为无限制。Default is no limit.

备注

此设置是预览功能,只有在设置为值 <= 5 时才可靠This setting is a preview feature - and only reliable if set to a value <= 5

密钥Key 示例值Sample value
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUTWEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT 55

WEBSITE_NODE_DEFAULT_VERSIONWEBSITE_NODE_DEFAULT_VERSION

仅限 Windows。Windows only.
设置在 Windows 上运行函数应用时使用的 node.js 版本。Sets the version of Node.js to use when running your function app on Windows. 应使用波形符(~)使运行时使用目标主版本的最新可用版本。You should use a tilde (~) to have the runtime use the latest available version of the targeted major version. 例如,如果设置为 ~10,将使用最新版本的 node.js 10。For example, when set to ~10, the latest version of Node.js 10 is used. 如果主要版本以颚化符为目标,则无需手动更新次版本。When a major version is targeted with a tilde, you don't have to manually update the minor version.

密钥Key 示例值Sample value
WEBSITE_NODE_DEFAULT_VERSIONWEBSITE_NODE_DEFAULT_VERSION ~ 10~10

WEBSITE_RUN_FROM_PACKAGEWEBSITE_RUN_FROM_PACKAGE

让函数应用从已装载的包文件运行。Enables your function app to run from a mounted package file.

密钥Key 示例值Sample value
WEBSITE_RUN_FROM_PACKAGEWEBSITE_RUN_FROM_PACKAGE 1

有效值是解析为部署包文件位置的 URL 或 1Valid values are either a URL that resolves to the location of a deployment package file, or 1. 设置为 1 时,包必须位于 d:\home\data\SitePackages 文件夹中。When set to 1, the package must be in the d:\home\data\SitePackages folder. 使用此设置的 zip 部署时,包将自动上传到此位置。When using zip deployment with this setting, the package is automatically uploaded to this location. 在预览版中,此设置名为 WEBSITE_RUN_FROM_ZIPIn preview, this setting was named WEBSITE_RUN_FROM_ZIP. 有关详细信息,请参阅从包文件运行函数For more information, see Run your functions from a package file.

AZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALLAZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALL

默认情况下,Functions 代理将使用快捷方式从代理直接将 API 调用发送到同一 Function App 中的函数,而不是创建新的 HTTP 请求。By default Functions proxies will utilize a shortcut to send API calls from proxies directly to functions in the same Function App, rather than creating a new HTTP request. 此设置让你能够禁用该行为。This setting allows you to disable that behavior.

密钥Key ValueValue 描述Description
AZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALLAZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALL true 具有指向本地函数应用中的函数的后端 URL 的调用将不再直接发送到该函数,而是定向回 Function App 的 HTTP 前端Calls with a backend url pointing to a function in the local Function App will no longer be sent directly to the function, and will instead be directed back to the HTTP front end for the Function App
AZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALLAZURE_FUNCTION_PROXY_DISABLE_LOCAL_CALL falsefalse 这是默认值。This is the default value. 具有指向 Function App 中的函数的后端 URL 的调用将直接转发到该函数Calls with a backend url pointing to a function in the local Function App will be forwarded directly to that Function

AZURE_FUNCTION_PROXY_BACKEND_URL_DECODE_SLASHESAZURE_FUNCTION_PROXY_BACKEND_URL_DECODE_SLASHES

此设置控制 %2F 在路由参数插入后端 URL 时是否在路由参数中解码为斜杠。This setting controls whether %2F is decoded as slashes in route parameters when they are inserted into the backend URL.

密钥Key ValueValue 描述Description
AZURE_FUNCTION_PROXY_BACKEND_URL_DECODE_SLASHESAZURE_FUNCTION_PROXY_BACKEND_URL_DECODE_SLASHES true 包含编码斜杠的路由参数会将其解码。Route parameters with encoded slashes will have them decoded. example.com/api%2ftest 将成为 example.com/api/testexample.com/api%2ftest will become example.com/api/test
AZURE_FUNCTION_PROXY_BACKEND_URL_DECODE_SLASHESAZURE_FUNCTION_PROXY_BACKEND_URL_DECODE_SLASHES falsefalse 此选项为默认行为。This is the default behavior. 所有路由参数在传递时将保持不变All route parameters will be passed along unchanged

示例Example

以下是位于 URL myfunction.com 上的函数应用中的示例 proxies.jsonHere is an example proxies.json in a function app at the URL myfunction.com

{
    "$schema": "http://json.schemastore.org/proxies",
    "proxies": {
        "root": {
            "matchCondition": {
                "route": "/{*all}"
            },
            "backendUri": "example.com/{all}"
        }
    }
}
URL 解码URL Decoding 输入Input 输出Output
true myfunction.com/test%2fapimyfunction.com/test%2fapi example.com/test/apiexample.com/test/api
falsefalse myfunction.com/test%2fapimyfunction.com/test%2fapi example.com/test%2fapiexample.com/test%2fapi

后续步骤Next steps

了解如何更新应用设置Learn how to update app settings

查看 host.json 文件中的全局设置See global settings in the host.json file

查看应用服务应用的其他应用设置See other app settings for App Service apps