Creating an HTTP-triggered Azure function
In this first example, we will create an HTTP-triggered Azure function. This means that you can browse to the page hosting the actual function:
- To begin, we will create a new directory and navigate to that directory:
mkdir http cd http
- Now, we will initialize a function using the following command. The
--docker
parameter specifies that we will build our function as a Docker container. This will result in a Dockerfile being created for us. We will select the Python language, option3
in the following screenshot:func init --docker
This will create the required files for our function to work:
Figure 11.7: Creating a Python function
- Next, we will create the actual function. Enter the following code and select the fifth option,
HTTP trigger
, and name the functionpython-http
:func new
This should result in an output like Figure 11.8:
Figure 11.8: Creating an HTTP-triggered function
- The code of the function is stored in the directory...