简体   繁体   English

定时器触发的 function 在 Azure function 应用程序(C#)

[英]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.

相关问题 计时器触发的Azure功能未在计划的时间触发,并且因Azure存储超时异常而失败 - Timer-triggered Azure Function not triggered on scheduled time and failed with Azure storage timeout exception 如果 function 的实例已经在执行,定时器触发的 Azure function 是否会执行? - Does a timer-triggered Azure function execute if an instance of the function is already executing? 在本地运行一次计时器触发的 Azure 函数的最简单方法是什么? - What is the simplest way to run a timer-triggered Azure Function locally once? 如何在计时器触发的函数上强制执行单例行为? - how to enforce singleton behavior on a timer-triggered function? 具有定时器触发的 Azure 功能的令牌缓存 - Token Cache with Timer-Triggered Azure Functions 如何调用 http 触发 azure function 从定时器触发 azure function - How to call http triggered azure function from timer triggered azure function 清除 Azure Function 应用程序和 C# 中的缓存? - Clearing cache in Azure Function app and c#? 定时器触发单元测试 Azure Function:提供测试数据 - Unit Tests for timer triggered Azure Function: provide test data 在添加Azure逻辑应用程序中使用(HttpTrigger – C#)的Azure函数 - Use Azure Function of (HttpTrigger – C#) in Add Azure Logic App 连接到Azure数据库的Azure Function App C#HTTP触发器 - Azure Function App C# HTTP Trigger connected to an Azure Database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM