Serverless has been around for several years and continues to generate significant buzz. Simply put, it means someone provides an environment where you upload and run your function code. Providers offer serverless environments for many popular languages such as Java, Node.js, C#, and Python.
I practice Python as a side project. I do not code at a developer level but learn enough to perform useful work. As I further explore Azure services I want to employ my knowledge of Python to create practical Azure Functions for a deeper understanding of serverless capabilities. If you share an interest in these complimentary tools, read on as I experiment and learn.
Working through Azure certification gave me a small taste of many, but not all, of the services available in Azure. I know much more about when to use certain services and how they compliment each other, but there’s a yearning for more. My background in networking made IaaS easy. I want to know more about other capabilities and get closer to the business-critical components: applications and data.
Shortly after my exam I explored Azure Functions. I started with a ‘quick start’ that amounted to deploying a Function App and running the basic code already in the template. It worked but did not improve my knowledge of Functions. I needed to step back and find information showing how the Azure Functions components interacted with each other and the code.
This post introduces the documentation providing fundamental concepts of Azure Functions, with a focus on Python. However, most of the documents apply regardless of the runtime environment and would be relevant regardless of the language you choose. This reading list provided the building blocks that I needed to understand how my Python functions would run, take input, and provide output in the Azure environment. Future posts will build upon this knowledge to create and deploy working Functions with Python.
Prerequisite: Readers should already have working knowledge in the language of their choice. For a Python developer, full benefit of this post requires knowledge of certain programming terms and coding practices such as:
- Classes and methods
- Return values
- Environment variables
The following documents, in order, provide the basic understanding of Azure Functions components. I list a few key concepts gleaned from each document for later reference.
An Introduction to Azure Functions
- The basic overview of Functions
- Available triggers
- Supported Azure service integrations
Azure Functions Developer’s Guide
- Common information across all Function types (language-agnostic)
- Common Binding parameters
- Function App folder structure
- Supported Bindings table (trigger, input, and/or output)
Azure Functions Python Developer Guide
The document provides the meat of how Python interacts with the Functions environment.
- Defining entry points
- Location of and referencing shared code
- Referencing inputs and outputs
- Accessing Environment variables
- Build to Azure
func azure functionapp publish <app name> --build remote
- Testing and Mocks
- Method return represented as special binding name $return
Note: The Azure Functions Core Tools uses the Az CLI environment when interacting with Azure. You should have Az CLI installed and be authenticated to run the publish command.
Azure Functions Triggers and Bindings Concepts
More info on triggers and bindings Always one trigger; Trigger always input binding Optionally multiple additional input and output bindings Azure Functions Python Developer Guide (above) explains how Python interfaces with bindings
Code and Test Azure Functions Locally
I provide this document at the end as it will probably play a prominent role in a future post. It explains setting up your local environment to develop for Azure Functions. The tooling includes runtime to enable local testing prior to deployment. If you read all of the documents above, you learned that the local.settings.json file mimics settings and environment variables available to your Function in Azure. Use Visual Studio Code or follow the instructions for Azure Functions Core Tools to ease development and testing of Azure Function apps.
Less than an hour of reading provided foundational understanding to develop some basic Function Apps and know where to turn for advanced information. Armed with this we can advance to building some practical Function apps, using these to spring into more advanced use cases.