Create your first Python function in Azure Function App
What is Azure Function?
Azure Functions is an event driven, compute-on-demand experience that extends the existing Azure application platform with capabilities to implement code triggered by events occurring in virtually any Azure or 3rd party service as well as on-premises systems. Azure Functions allows developers to take action by connecting to data sources or messaging solutions, thus making it easy to process and react to events. Azure Functions scale based on demand and you pay only for the resources you consume.
What is Python?
Python is a programming language that lets you work quickly and integrate systems more effectively.
First Python function in Azure Function App
Goal: Run Python Functions on Azure
Why? Python is a very powerful language and using Azure Function App it is possible to run many Python functions on the Cloud.
It is still in preview, but it is now possible to create a Python function to run in Azure.
As you can see below, I created my first serverless Python function app.
The function code is created locally and then deployed to Azure.
Calling the Endpoint and getting the result:
Calling the Endpoint from a browser (localhost):
Calling the Endpoint from the browser (Azure)
The code on Visual Code:
I used the link below to install all the required software:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python
Some commands to remember/annotations:
Run the command below in Windows CMD Prompt:
npm install -g azure-functions-core-toolsRun this commaand to activate your Python env inside Visual Code
.\.env\Scripts\activateRun the command in your terminal:
pip install azure-functionsRun the command below in Power Shell:
Set-ExecutionPolicy Unrestricted -ForceDeploy the function app on Azure:
func azure functionapp publish <<app name>>
Software installed:
Python 3.6.8
https://www.python.org/downloads/windows/
.NET Core 2.2 SDK
https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-2.2.203-windows-x64-installer
Node.js 8.5
https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
https://nodejs.org/en/download/