To build and test locally, you will need to:
- Install Python 3.6
- Install Docker
- Install Azure Functions Core Tools version 2.0.3 or later
To install Azure Functions Core tools you will need also these requirements:
- Install .NET Core 2.1 for Windows.
- Install Node.js, which includes npm. For version 2.x of the tools, only Node.js 8.5 and later versions are supported.
- Install the Core Tools package:
npm install -g azure-functions-core-tools
Create and activate a virtual environment
To create a Functions project, it is required that you work in a Python 3.6 Virtual Environment. Run the following commands to create and activate a virtual environment named env.
# In Bash
python3.6 -m venv env
# In PowerShell
py -3.6 -m venv env
# In CMD
python -m venv env
Create a local Functions Project
To create a Functions project, it is required that you work in a Python 3.6 virtual environment. Run the following commands to create and activate a virtual environment named env. In the terminal window or from a command prompt, run the following command:
func init MyFunctionProj --worker-runtime python –docker
func init . --worker-runtime python --docker
You will see something like the following output.
Installing wheel package
Installing azure-functions==1.0.0a5 package
Installing azure-functions-worker==1.0.0a6 package
Running pip freeze
This generates a Dockerfile with the following content:
COPY . /home/site/wwwroot
RUN cd /home/site/wwwroot &&
pip install -r requirements.txt
Create a function
Run the function locally
Run locally as Docker container
Using Docker, run the following command.
docker build . --tag
(example) docker build . -- pythonfunction:v1
Once image has been build you could run the following command to start the image:
docker run -p
(example) docker run -p 8080:80 pythonfunction:v1
Once started, you could browse to http://localhost:8080 (using example) to view your function running.
Deploy your function app
You could use Docker Hub or Azure Container Registry to deploy your Docker image.
Push image to Docker Hub
First Create a container registry
Log in to ACR
Push image to ACR
Create function app via Azure Portal
Select the New button found on the upper left-hand corner of the Azure portal, then select Compute > Function App.
When configuring the settings, select Linux (Preview) for OS and Docker Image for Publish.
Under Configure Container, select either Azure container Registry or Docker Hub depending on how you deployed your Docker image.
Once deployed, you will be able to access the Function Apps page
Once deployed, you can test your Function App:
Be sure to change
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here