Create an Azure Function with Python
  • 03 Apr 2022
  • 2 Minutes to read
  • Contributors
  • Comments
  • Dark
  • PDF

Create an Azure Function with Python

  • Comments
  • Dark
  • PDF

#ServerlessTips - Azure Functions
Author: Dave McCollough Vice President - Information Technology

In this article, we will demonstrate how to create an Azure Function using Python.

Python is a general-purpose, high level programming language known for its readability and flexibility. Python can be used for scripting, backend web development, Data Science, AI and Machine Learning, IoT, etc.

Python is used across several Azure Services including web apps, functions, storage, databases, AI, etc.


  1. Active Azure Subscription
  2. Visual Studio Code with Azure Functions Core Tools and Azure Functions extension installed
  3. Python version 3.6 or greater

Create a local function project

  1. Open Visual Studio Code and click the Azure icon

  2. Click the folder icon to create your new project

  3. You will be prompted to select a location to save your project.

  4. Select Python from the Create New Project dropdown.

  5. Select the version of Python or Python environment you want to run your Azure Function project in.

  6. Select HTTP trigger as your project template.

  7. You will be prompted to create a function name. You can use the default (HTTPTrigger1) or change it based on your preference

  8. You will be prompted to select an Authorization level. For this example, you can choose Anonymous (choosing Anonymous means your function can be called without an API access key).

  9. You will be prompted to choose how you want to open your project, select Add to workspace (choosing Add to workspace means any configuration settings will apply only to this folder).

  10. Visual Studio will create your project

  11. Once your project is created, press the F5 Key to run your function

  12. Azure Functions Core tools will display output in the Terminal tab. This will allow you to access the URL of your function app.

  13. You can either copy/paste the URL into your browser or cmd or ctrl + click to open the URL in a browser

  14. To verify that your function is working, append a question mark and name parameter to the URL as shown below:

  15. After modifying the URL, the function will respond and update the browser

Publish your function to Azure

  1. Click the Azure icon followed by the deploy to Azure icon

  2. If you are not already signed into Azure, you will be prompted to sign in.

  3. Click Create new Function App in Azure.

  4. Enter a globally unique name for your function app.

  5. Select your runtime stack. This should be the version of Python you are running locally.

  6. Select the region for your resources.

  7. The resources to support your function app will be created in Azure.

  8. Login to the Azure Portal.

  9. Navigate to the resource groups page and select the resource you created in step 4.

  10. Select the function app from the list of resources.

  11. Click Functions in the left-hand navigation bar

  12. Click on your function

  13. Click on Code + Test in the left-hand navigation bar

  14. You can now view your function code. If you want to test your function, click Get function URL.

  15. Copy and paste the URL into your browser.
    Append the question mark and name parameter to the URL.

  16. After modifying the URL, the function will respond and update the browser.


In this article we reviewed how you can create and publish a Python function project from your local environment to Azure.


Was this article helpful?