Creating Azure Python Function App Hosted on Consuption Plan Using ARM Template

Shervin Mirsaeidi 61 Reputation points
2021-06-03T16:53:25.297+00:00

Hi team,

I been looking at the following post on this form :

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

and its mentioned in there how to create a Azure Python Function App on the Consumption hosting plan. It says to define WEBSITE_CONTENTAZUREFILECONNECTIONSTRING, WEBSITE_CONTENTSHARE app settings. But looking at this following documentation :

(https://learn.microsoft.com/en-us/azure/azure-functions/functions-infrastructure-as-code)

It says WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE are not supported for Linux machine. When I try to create a Python Azure Function App from the portal it says only Linux machine is allowed for Python. Is the documentation I posted above outdated or changed?

Can you please provide me direction? What I'm trying to do is create a Azure Python Function App using a ARM template using the REST API. I am using the following documentation:

(https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-rest)

Assuming I'm deploying to already created resource group with nothing in it. I have found a quick start template for creating a Node Function App on Consumption hosting plan using the following documentation :

(https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.web/function-app-create-dynamic)

Can you please share similar ARM template for creating Azure Python Function App on Consumption hosting plan similar to documentation above or perhaps guide me to the right direction

Thank you for your time

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,873 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,136 Reputation points
    2021-06-04T05:22:33.903+00:00

    @Shervin Mirsaeidi This statement is correct "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE are not supported for Linux machine". You can refer to function app setting document and it says the same for WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE

    Yes, python function are only supported in Linux OS. The same is mentioned in our function reference python document.
    102238-image.png

    You can refer to this document for operating system and language runtime support for the hosting plans.

    You can use the same ARM template and customize it according to your needs. For creating python function you need to pass the runtime value as python. You can find the valid values as mentioned in this document. Please refer to different properties for Microsoft.Web/sites. I have removed the WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE from the appSettings property. For linux ARM template updated the same as mentioned in Linux section and removed the "Microsoft.Web/serverfarms" section and dependencies.

    102216-image.png

    Attaching the ARM template for your reference.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Shervin Mirsaeidi 61 Reputation points
    2021-06-04T17:34:05.447+00:00

    @MayankBargali-MSFT

    Thank you for your response. That is exactly what I was looking for. However seems like after creating all the resources by running the ARM template were having the same issue we had in the other form, where without the WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE inside the siteConfig any newly created Python Function disappears after few seconds and when I try to run it I get a 404 not found error, and after couple mins the function disappears. Same as the screen shots I posted in the form :
    (https://learn.microsoft.com/en-us/answers/questions/396131/creating-a-azure-python-or-c-function-dynamically.html?childToView=407137#comment-407137)

    I have tried the same ARM template you provided and I have added WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE to the siteConfig and it works now. Even though the documentation says you cannot add these for Linux machine. I have attached my ARM template to this message incase someone else needs it. Please let me know if you noticed the same thing on your end? 102496-pythonfunctionappconsumptionhostedarmtemplate.txt


  2. Shervin Mirsaeidi 61 Reputation points
    2021-06-11T18:01:32.747+00:00

    @MayankBargali-MSFT

    The only way I can create a python azure function via REST API hosted on a consumption plan is to have the WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE set under my site configuration or else the function disappears after few seconds. I have created and executed the HTTP trigger Python Azure function on consumption plan successfully with this mentioned configuration. However, I have been trying to create a Timer Python Azure Function via REST API but I have had no luck. I have successfully created and deployed a Timer Python Azure function using visual studio code and after creation, I called the GET Function REST API to get a idea of what attributes are required in the REST API body. But when I create the function via REST API it creates successfully and when it runs it throws the error

    "Result: Failure Exception: FunctionLoadError: cannot load the myTimer function: the following parameters are declared in Python but not in function.json: {'mytimer'} Stack: File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 308, in _handle__function_load_request function_id, func, func_request.metadata) File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/functions.py", line 114, in add_function 'the following parameters are declared in Python but '"

    I have attached the payload I used in my REST API request to this message. Please let me know if I'm missing something?

    Thanks again for your time

    104810-requestbody.txt


Your answer

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