@Shweta , thank you for reaching out to us. Let's consider we have an Azure Function App with 2 functions: HttpTrigger1
and BlobTrigger1
and that we want to disable the HttpTrigger1
function. This can be achieved by going to the Configuration
tab of our Function App and add a new boolean
app setting named using this pattern:
AzureWebJobs.HttpTrigger1.Disabled
Now, set it's value to true
, and you will see that it is disabled. Consequently, to enable the Function back, you can make AzureWebJobs.HttpTrigger1.Disabled
value false
. Further, if you want to disable this programmatically, you can use PowerShell or Azure CLI. Below is the script to set App Settings in your App Service:
$site = Get-AzWebApp -Name foo-app
$oldSettings = ($site.SiteConfig.AppSettings | % { $h = @{} } { $h[$_.Name] = $_.Value } { $h })
$newSettings = @{ AzureWebJobs.HttpTrigger1.Disabled = true }
Set-AzWebApp -ResourceGroupName foo-rg -Name foo-app -AppSettings ($oldSettings + $newSettings)
The best way AFAIK to achieve this is to use PowerShell Function App for running above scripts (since it has in-built support for PowerShell) and calling PowerShell Function App endpoint from your JavaScript code. I would also recommend you to watch Using PowerShell Modules in Azure Functions for more insights about Azure PowerShell functions. Let me know if you have further questions.
-----------------------------------------------------------------------------------------------------------
Please "Accept the answer" and upvote if the information helped you. This will help us and others in the community as well.