推荐的方法是使用应用程序设置,您可以通过访问门户网站来进行设置。[注:不是说函数.json当他们说应用程序设置时。]
在azure门户中,导航到你的功能应用
foo
->
Confuguration
,你应该看到
Application Settings
已经定义了几个变量的选项卡。您需要通过单击
New application setting
按钮。将名称设置为
AzureWebJobs.bar.Disabled
和价值
true
变量名中没有数字。
选项2:使用主机.json
https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#functions
{
"functions": [ "function1", "function2" ] // Don't list function "bar" here, and it would get disabled.
}
请注意,门户将不会正确显示此项,并将“bar”列为已启用,但当您点击该函数时将获得404。
选项3:使用Disable属性
如果您使用的是C,您也可以使用
[Disable]
属性。这是一个函数1.x构造,但它也可以在2.x中工作。与上面类似,门户用户界面将不会正确显示这一点。
[Disable]
[FunctionName("Function1")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
}
// [FunctionName("Function1")] // Comment this or delete this line to disable this function
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
}
这在两个运行时都应该有效。该函数不会在azure门户中显示。