[英]Timer-triggered function in Azure function app (C#)
In my Azure function app, I have two timer-triggered functions;在我的 Azure function 应用程序中,我有两个定时器触发的功能; one function is enabled and the other is disabled in
local.settings.json
(by specifying: AzureWebjobs.function2.Disabled= "true"
).一个 function 已启用,另一个在
local.settings.json
中禁用(通过指定: AzureWebjobs.function2.Disabled= "true"
)。
I want to change the disabled function to be enabled programmatically.我想将禁用的 function 更改为以编程方式启用。
This is my function app这是我的 function 应用程序
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");
}
}
and this is my local.settings.json
file:这是我的
local.settings.json
文件:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureWebJobs.Function2.Disabled": "true"
}
}
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.我不确定您是否可以通过编程方式更改 state,因为它位于运行时堆栈上,因此其中一个选项是使用
Azure CLI
,您可以使用以下内容。
az functionapp config appsettings set --name <myFunctionApp> --resource-group <myResourceGroup> --settings AzureWebJobs.<<Function Name>>.Disabled=true
Note: If you send false, it will enable the Function.注意:如果您发送 false,它将启用 Function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.