Tommy Tayler
Tommy Tayler

Reputation: 27

Automate turning off Azure function

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

Answers (1)

Delliganesh Sevanesan
Delliganesh Sevanesan

Reputation: 4776

There are three ways to disable/enable Azure functions.

  • Azure Portal
  • Azure CLI
  • Azure PowerShell

follow the MSDOC for different way to Enable/Disable the Azure function

You can use Azure CLI & Azure PowerShell to automate the process.

Disable Azure function

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"}

Enable Azure Function

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.

References

Upvotes: 1

Related Questions