Share via

Disable Python Azure Function Using Hosted on Consuption Function App

Shervin Mirsaeidi 61 Reputation points
2021-06-26T02:39:47.687+00:00

Hi Team,

I have been trying to disable/enable Python Azure Function hosted on Consumption Function App but I have had no success. However I was able to disable/enable a C# Azure Function on Consumption plan. I have tried both methods suggested by this answer from the following Microsoft thread :

(https://learn.microsoft.com/en-us/answers/questions/396131/creating-a-azure-python-or-c-function-dynamically.html?childToView=420716#comment-420716)

First I tried to set the attribute "isDisabled" to "true" when I create the function using the Create Azure Function Rest API from the following documentation :

(https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/create-function)

Second I have tried to use the below endpoint to enable and disable a particular function.

https://management.azure.com/subscriptions/{subscriptionID}/resourceGroups/{resourcegroupname}/providers/Microsoft.Web/sites/{sitename}/functions/{functionappname}/properties/state?api-version=2018-11-01

Request Body:

{"properties":"disabled"}
OR
{"properties":"enabled"}

Both approaches do not work for Python function hosted on Consumption plan. But for C# only the second solution works. When I send the REST PUT request for the Python function hosted on Consumption plan I get a "bad request 400" response with the following error

{
"Code":"BadRequest",
"Message":"AppSetting with name 'AzureWebJobs.<my function name>.Disabled' is not allowed.",
"Target":null,
"Details":[
{
"Message":"AppSetting with name 'AzureWebJobs.<my function name>.Disabled' is not allowed."
},
{
"Code":"BadRequest"
},
{
"ErrorEntity":{
"ExtendedCode":"04072",
"MessageTemplate":"AppSetting with name '{0}' is not allowed.",
"Parameters":[
"AzureWebJobs.<my function name>.Disabled"
],
"Code":"BadRequest",
"Message":"AppSetting with name 'AzureWebJobs.<my function name>.Disabled' is not allowed."
}
}
],
"Innererror":null
}

Can you please let me know if you notice the same issue on your end? Also if there is anyway I can programmatically disable a Python Azure Function hosted on Consumption Function App using REST API? perhaps I need to get the higher tier for Python functions?

Thanks for your time

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

Answer accepted by question author

Pramod Valavala 20,661 Reputation points Microsoft Employee Moderator
2021-06-29T09:25:21.153+00:00

@Shervin Mirsaeidi The REST API (the same used by the button in UI) works by setting an app setting as mentioned in the docs.

Based on the error that you've shared, I would guess there is an invalid character, likely a - (hyphen) which isn't valid on Linux.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.