I\'m aiming to get some Python 3 code running as an Azure Function, but I can\'t get Python 3 to work (I realize python support in Azure Functions is still experimental).
For the moment there is an open issue :
But as a workaround, everything is explain here (All credits to the author: Murat Eken)
Installing a site extension with an alternative Python version and configuring the handler mapping to use that installation by default..
2.1. Go to "Platform features > All Settings > Extensions > + Add
2.2. Install the "Python 3.6.2 x86" extension.
2.3. Go to "Platform features > Applications Settings
2.4. Add an handler mapping:
extension : fastCgi
processor: D:\home\python362x86\python.exe
arguments: D:\home\python362x86\wfastcgi.py
2.5 Add an application setting called WEBSITE_USE_PLACEHOLDER and set its value to 0. This is necessary to work around an Azure Functions issue that causes the Python extension to stop working after the function app is unloaded.
2.6. Save your app settings.
Here is the output of my function
"3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)]"
you can automate these step using an ARM Template, here are the interesting part of the template:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
//...
},
"variables": {
// ...
},
"resources": [
// ...
{
"type": "Microsoft.Web/sites",
// ...
"kind": "functionapp",
"properties": {
// ...
"siteConfig": {
"handlerMappings": [{
"arguments": "D:\\home\\python362x86\\wfastcgi.py",
"extension": "fastCgi",
"scriptProcessor": "D:\\home\\python362x86\\python.exe"
}]
// ...
},
"resources": [{
"name": "python362x86",
"type": "siteextensions",
"apiVersion": "2016-08-01",
"properties": {}
// ...
}]
// ...
}
}
]
}