Azure functions are contained inside Function App resources, which are a kind of App Service. For example, the screenshot below shows a Function App called ccl-experiment-1. Drilling on its Functions from the sidebar reveals that there is one Azure function in this app, called HTTP_ccl_experiment_1, which is a kind of HTTP trigger.
Function App
App Service
ccl-experiment-1
Functions
HTTP_ccl_experiment_1
To invoke the function, one uses the URL https://ccl-experiment-1.azurewebsites.net/api/HTTP_ccl_experiment_1 which is built out from the name of the app (ccl-experiment-1) as a subdomain from azurewebsites.net, and the actual function’s name HTTP_ccl_experiment_1.
https://ccl-experiment-1.azurewebsites.net/api/HTTP_ccl_experiment_1
azurewebsites.net
This particular function takes a query parameter name and then returns a Hello <name> message. Here is a sample run:
name
Hello <name>
Visual Studio Code creates a virtual environment for Azure functions, in a folder called .venv. It has its own copy of Python, pip, and site libraries.
.venv
Python
pip
I haven’t found a successful way to activate this environment. Doing source .venv does not seem to work.
source .venv
However, it seems that we can run install commands for this environment by doing a pip install as invoked as a script by the Python in the environment of interest. For example:
pip install
$ .venv/Scripts/python -m pip install --upgrade pip Collecting pip Using cached https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.2.3 Uninstalling pip-19.2.3: Successfully uninstalled pip-19.2.3 Successfully installed pip-20.1.1
Simplest way is to host in Azure storage
Using as an example static website CCL Notebooks, one notes that we end up creating three endpoints, all of them pointing to the same content, in this order:
Azure Blob Storage endpoint: https://cclstaticsitesnodr001.z22.web.core.windows.net/ is created when the storage account cclstaticsitesnodr001 is configured to host a static website
https://cclstaticsitesnodr001.z22.web.core.windows.net/
cclstaticsitesnodr001
Azure CDN endpoint: https://ccl-labnotebooks.azureedge.net/ is created when we map a custom domain name to the Azure Blob Storage endpoint
https://ccl-labnotebooks.azureedge.net/
Nice CCL endpoint: https://notebooks.chateauclaudia-labs.com/ is created when we map a custom domain to the Azure CDN endpoint.
https://notebooks.chateauclaudia-labs.com/
Below are the steps in this example, using the Azure Portal:
The name must be unique in Azure, and in our example it is chosen by combining these tokens:
ccl - since that is the organization owning the site (Chateau Claudia Labs, aka CCL)
ccl
staticsites - since this is meant to hold static web sites for CCL
staticsites
nodr - since we chose a cheap configuration for the storage account, which includes no disaster recovery, not needed in this case since the content originates in a Sphinx project in source control kept off Azure
nodr
001 - to support the possibility of multiple such accounts being created in the future
001
The storage account for CCL Notebooks was configured to be very cheap, an looks like this:
As described in host in Azure storage
This applies both to initial content as well as to a full update of the web site as its content evolves.
I prefer to do this from Visual Studio Code.
This is described in Deploy from Visual Studio Code
One selects the “Azure” icon on the left side of VS Code, which brings up some icons including an upload icon. Selecting it lets you choose the site to upload (which in this example should be build, since the Sphinx project built the site in that folder):
build
This is described in how to map custom domain to storage endpoint
This creates an Azure CDN endpoint in the Azure CDN Profile, highlighted in red in this picture:
Lastly, one has to create a CNAME with the domain provider (DreamHost in the example), as explained in How to add a custom domain to an Azure CDN endpoint
In DreamHost, the CNAME entry looks like this:
It results in the Azure CDN endpoint being mapped to a CCL endpoint, like this, highlighted in red: