Reputation: 27
I have a function app that I need to turn off every day at 5pm.
Is there a way I can automate this turn off?
I thought about a timer but I have to run through checks before it can be turned back on
Upvotes: 0
Views: 940
Reputation: 4776
There are three ways to disable/enable Azure functions.
follow the MSDOC for different way to Enable/Disable the Azure function
You can use Azure CLI & Azure PowerShell to automate the process.
Here, I am using Azure PowerShell
Update the Function app setting "AzureWebJobs.QueueTrigger.Disabled"
is "true"
to disable the azure function.
Update-AzFunctionAppSetting -Name <YOUR_FUNCTION_APP_NAME> -ResourceGroupName <YOUR_RESOURCE_GROUP_NAME> -AppSetting @{"AzureWebJobs.QueueTrigger.Disabled" = "true"}
Update the Function app setting "AzureWebJobs.QueueTrigger.Disabled"
is "false"
to enable Azure function
Update-AzFunctionAppSetting -Name <FUNCTION_APP_NAME> -ResourceGroupName <RESOURCE_GROUP_NAME> -AppSetting @{"AzureWebJobs.QueueTrigger.Disabled" = "false"}
To automate this PowerShell scripts, you need to use the Azure Automation, create a runbook and schedule it to Enable/Disable the Azure function at specific time.
Upvotes: 1