Tutorial: Create and deploy serverless Azure Functions in Python with Visual Studio Code

In this article, you use Visual Studio Code and the Azure Functions extension to create a "serverless" HTTP endpoint with Python and to also add a connection (or "binding") to storage. The Azure Functions extension for Visual Studio Code greatly simplifies the process of using Functions by automatically handling many configuration concerns.

The serverless environment of Azure Functions means that Azure presents your app's endpoints and public URLs without your needing to provision a virtual machine, publish a web app, or otherwise manage servers and resources. Azure efficiently manages all those resources for you, which significantly reduces the overhead and cost of hosting your application. (For more information, see the Azure Functions overview.)

If you encounter issues with any of the steps in this tutorial, we'd love to hear the details. Use the This page feedback button at the end of each article.

For a demonstration video, see Build Azure Functions with VS Code (youtube.com) from virtual PyCon 2020. You might also be interested in the longer session, Easy data processing with Azure Functions (youtube.com).

Configure your environment

Azure Functions Core Tools

Follow the instructions for your operating system on Work with Azure Functions Core Tools. Ignore the comments in the article about the Chocolatey package manager, which are not necessary to complete this tutorial.

When installing Node.js, use the default options and do not select the option to automatically install necessary tools. Also be sure to use the -g option with the npm install commands so that the Core Tools are available to subsequent commands.


The Core Tools are written in .NET Core, and the Core Tools package is best installed using the Node.js package manager, npm, which is why you need to install .NET Core and Node.js at present, even for working with Azure Functions in Python. You can, however bypass the .NET Core requirement using "extension bundles" as described in the aforementioned documentation. Whatever the case, you need install these components only once, after which Visual Studio Code automatically prompts you to install any updates.

Visual Studio Code, Python, and the Azure Functions extension

Install the following software:

Sign in to Azure

Once you've installed the Azure extension, sign into your Azure account by navigating to the Azure explorer, select Sign in to Azure under Functions, and follow the prompts in the browser.

Sign in to Azure through VS Code

After signing in, verify that the status bar says Azure: Signed In and your subscription(s) appears in the Azure explorer:

Visual Studio Code status bar showing Azure account

Visual Studio Code Azure App Service explorer showing subscriptions


If you see the error "Cannot find subscription with name [subscription ID]", this may be because you are behind a proxy and unable to reach the Azure API. Configure HTTP_PROXY and HTTPS_PROXY environment variables with your proxy information in your terminal:

# Windows
set HTTPS_PROXY=https://username:password@proxy:8080
set HTTP_PROXY=http://username:password@proxy:8080
# macOS/Linux
export HTTPS_PROXY=https://username:password@proxy:8080
export HTTP_PROXY=http://username:password@proxy:8080

Verify your environment

To verify that all the Azure Functions tools are installed, open the Visual Studio Code Command Palette (F1), select the Terminal: Create New Integrated Terminal command, and once the terminal opens, run the command func:

Check Azure Functions core tools prerequisites

The output that starts with the Azure Functions logo (you need to scroll the output upwards) indicates that the Azure Functions Core Tools are present.

If the func command isn't recognized, then run npm install -g azure-functions-core-tools again and verify that the install succeeds. Make sure also that you use the -g switch with the install command; otherwise npm installs the package in the current folder only.

The func command works through the func.cmd file that's installed in the Node.js global folder. To see the location of this folder, run npm -l and examine the location at the end of the output.

Having issues? Let us know.