Azure函数应用程序(C#)中的计时器触发的函数 [英] Timer-triggered function in Azure function app (C#)
问题描述
在我的Azure函数应用程序中,我有两个计时器触发的函数;在 local.settings.json
中启用一个功能,然后禁用另一个功能(通过指定: AzureWebjobs.function2.Disabled ="true"
).
In my Azure function app, I have two timer-triggered functions; one function is enabled and the other is disabled in local.settings.json
(by specifying: AzureWebjobs.function2.Disabled= "true"
).
我想将禁用功能更改为以编程方式启用.
I want to change the disabled function to be enabled programmatically.
这是我的功能应用程序
public class Function1
{
[FunctionName("Function1")]
public void Run1([TimerTrigger("*/5 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation("function1");
}
[FunctionName("Function3")]
public void Run2([TimerTrigger("*/5 * * * * *")] TimerInfo myTimer, ILogger log)
{
log.LogInformation("function2");
}
}
这是我的 local.settings.json
文件:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureWebJobs.Function2.Disabled": "true"
}
}
推荐答案
我不确定是否可以通过编程方式更改状态,因为它位于运行时堆栈中,因此选项之一是使用 Azure CLI
,您可以在下面使用某些内容.
I'm not sure if you can programmatically change the state , since it's lying on the runtime stack, therefore one of the option is using Azure CLI
, you may use something below.
az functionapp config appsettings set --name< myFunctionApp>--resource-group< myResourceGroup>--settings AzureWebJobs.<<功能名称>> .Disabled = true
注意:如果发送false,它将启用该功能.
Note: If you send false, it will enable the Function.
这篇关于Azure函数应用程序(C#)中的计时器触发的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!