Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
To build and test locally, you will need to:
To install Azure Functions Core tools you will need also these requirements:
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
source env/bin/activate
# In PowerShell
py -3.6 -m venv env
env\scripts\activate
# In CMD
python -m venv env
env\scripts\activate
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
Writing .funcignore
Writing .gitignore
Writing host.json
Writing local.settings.json
Writing D:\__Documents\WebAppProjects\functions-python-3\.vscode\extensions.json
Writing Dockerfile
This generates a Dockerfile with the following content:
FROM mcr.microsoft.com/azure-functions/python:2.0
COPY . /home/site/wwwroot
RUN cd /home/site/wwwroot && \
pip install -r requirements.txt
Using Docker, run the following command.
Replace <imagename> and <tag> with preferred names.
docker build . --tag <imagename>:<tag>
(example) docker build . -- pythonfunction:v1
Once image has been build you could run the following command to start the image:
docker run -p <portexposed>:<portusedinside> <imagename>:<tag>
(example) docker run -p 8080:80 pythonfunction:v1
Once started, you could browse to https://localhost:8080 (using example) to view your function running.
You could use Docker Hub or Azure Container Registry to deploy your Docker image.
/en-us/azure/container-registry/container-registry-get-started-portal#push-image-to-acr
/en-us/azure/container-registry/container-registry-get-started-portal#create-a-container-registry
/en-us/azure/container-registry/container-registry-get-started-portal#create-a-container-registry
/en-us/azure/container-registry/container-registry-get-started-portal#push-image-to-acr
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 <functionappname> and <function-name> with your functions values.
https://<functionappname>.azurewebsites.com/api/<function-name>
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in