Azure Function App
Table of Content
- HTTP Trigger Azure Function App
- Timer-Triggered Azure Function App
- Azure Queue Storage Trigger
- Azure Function App Authentication using Azure Entra ID
How to Deploy an Azure HTTP Trigger Function App Using Python and the Azure CLI
Azure Function Apps offer a powerful serverless compute option that allows developers to execute code in response to events—without managing infrastructure. In this step-by-step guide, we'll walk you through deploying an Azure Function App using Python, from local development to cloud deployment, using the Azure CLI and the Azure Functions Core Tools.
Whether you're new to serverless or want to automate your Python workloads on Azure, this tutorial is for you.
✅ Step 1: Create a Python Virtual Environment
Before you do anything, it's good practice to isolate your project dependencies using a virtual environment.
1python -m venv .venv
2source .venv/bin/activate
⚙️ Step 2: Initialize the Azure Function App Project
Use the Azure Functions Core Tools to bootstrap your local function project.
1func init --python
This sets up the necessary file structure for a Python-based Azure Function App.
☁️ Step 3: Set Up Azure Resources
Create a Resource Group
A resource group in Azure is a container that holds related resources for your app.
1az group create --name azure-app-function-rg --location northeurope
Create a Storage Account
Function Apps need a storage account to manage runtime state and logging.
1az storage account create --name appafuncstorageacc --location northeurope --resource-group azure-app-function-rg --sku Standard_LRS
🧱 Step 4: Create Your HTTP Trigger Function
Now, let's add an actual function to your project. This function will be triggered by an HTTP request.
1func new --name httpTriggerAppFunc01 --template "HTTP trigger" --authlevel "anonymous"
Breakdown of the Command:
func new: Creates a new function.--name httpTriggerAppFunc01: The function is named httpTriggerAppFunc01.--template "HTTP trigger": Sets it to respond to HTTP requests.--authlevel "anonymous": Makes it public (no API key required).
🧪 Step 5: Run the Function Locally
You can test your function locally before deploying it to Azure.
1func start
Visit http://localhost:7071/api/httpTriggerAppFunc01 in your browser to test.
🚀 Step 6: Create the Azure Function App in the Cloud
This command provisions the actual cloud resources where your function code will live and run.
1az functionapp create --resource-group azure-app-function-rg --consumption-plan-location northeurope --runtime python --runtime-version 3.10 --functions-version 4 --name httpTriggerFuncApp01 --os-type linux --storage-account appafuncstorageacc
📤 Step 7: Deploy Your Function to Azure
Push your local function project to Azure so it's live and accessible from anywhere.
1func azure functionapp publish httpTriggerFuncApp01
🧹 Step 8: Clean Up Resources
When you're done experimenting, it’s a good idea to remove the Azure resources to avoid unnecessary charges.
1az group delete --name azure-app-function-rg
📌 Conclusion
Congratulations! 🎉 You've successfully created and deployed a Python Azure Function App with an HTTP trigger using the Azure CLI and Azure Functions Core Tools. This setup allows you to scale functions on demand while keeping infrastructure management to a minimum.
Whether you're building APIs, webhooks, or automation scripts, Azure Functions provide a robust platform to run event-driven serverless workloads.
If you found this helpful, don’t forget to share or bookmark this guide for future reference!
Automate with Azure: Build a Python Timer-Triggered Azure Function App
Want to run tasks on a schedule—without managing a server or cron job? With Azure Function Apps, you can easily schedule code execution using Timer Triggers, making it perfect for automation, maintenance tasks, or reporting workflows.
In this guide, we’ll walk through how to create a Python-based Azure Function App triggered by a timer (running every 5 seconds), deploy it using the Azure CLI, and manage it effectively.
🐍 Step 1: Set Up a Python Virtual Environment
Start by isolating your Python project using a virtual environment:
1python -m venv .venv
2source .venv/bin/activate
This ensures your dependencies remain clean and manageable.
⚙️ Step 2: Initialize Your Azure Function Project
Use the Azure Functions Core Tools to initiate a new project structure configured for Python:
1func init --python
This creates the scaffolding for a Python-based Azure Function.
⏱️ Step 3: Create a Timer Trigger Function
Let’s add a function that runs every 5 seconds using a cron-style schedule.
1func new --name timerTriggerAppFunc01 --template "Timer trigger" --schedule "*/5 * * * * *"
🔍 Schedule Explained:
The schedule uses a CRON expression where:
*/5= every 5 seconds- The rest are minute, hour, day, etc.
Your function will now run automatically every 5 seconds.
🧪 Step 4: Test Locally
Run your function locally to ensure everything works before deploying to the cloud.
1func start
You should see the function logging its execution every 5 seconds in your terminal.
☁️ Step 5: Create Azure Resources
Resource Group
Create a resource group to house your Azure Function and related resources:
1az group create --name azure-app-function-rg --location northeurope
Storage Account
A storage account is required for Azure Functions to store logs, checkpoints, and more:
1az storage account create --name appafuncstorageacc --location northeurope --resource-group azure-app-function-rg --sku Standard_LRS
🏗️ Step 6: Create the Function App in Azure
Now provision the actual Function App in Azure where your code will be deployed:
1az functionapp create --resource-group azure-app-function-rg --consumption-plan-location northeurope --runtime python --runtime-version 3.10 --functions-version 4 --name timerTriggerAppFunc01 --os-type linux --storage-account appafuncstorageacc
This sets up a serverless environment using Python 3.10 on a Linux OS.
🚀 Step 7: Deploy to Azure
Publish your local function to the cloud:
1func azure functionapp publish timerTriggerAppFunc01
Azure will handle the rest—provisioning the runtime and wiring up the schedule.
🧹 Step 8: Clean Up (Optional)
If you’re done testing and want to avoid any costs, remove the resource group:
1az group delete --name azure-app-function-rg
Build a Python Azure Function Triggered by Azure Storage Queue
Need to process tasks asynchronously and reliably? Azure Storage Queues paired with Azure Function Apps make a great combo for scalable background processing. In this hands-on guide, you’ll learn how to build a Python-based Azure Function that automatically fires when a message is added to an Azure Storage Queue.
Perfect for handling jobs like order processing, background emails, or event buffering—this solution is lightweight, serverless, and fast to deploy.
🐍 Step 1: Set Up a Python Virtual Environment
Let’s start by preparing an isolated Python development environment:
1python -m venv .venv
2source .venv/bin/activate
This keeps your dependencies organized and project-specific.
☁️ Step 2: Create Required Azure Resources
Create a Resource Group
This is the container that holds all the Azure resources related to your function:
1az group create --name azure-app-function-rg --location northeurope
Create a Storage Account
This is where Azure will store the function's metadata and queue data:
1az storage account create --name appafuncstorageacc --location northeurope --resource-group azure-app-function-rg --sku Standard_LRS
Create a Storage Queue
This queue will be the trigger source for your function:
1az storage queue create --name testaueueforappfun --account-name appafuncstorageacc
You can enqueue messages here, and the function will respond automatically.
⚙️ Step 3: Initialize the Azure Function Project
Set up the function project environment:
1func init --python
This prepares your folder for developing Azure Functions using Python.
🔄 Step 4: Create the Queue Trigger Function
Add a function that responds to new messages in the storage queue:
1func new --name queueStorageTriggerAppFunc01 --template "Queue trigger"
This generates the necessary boilerplate and configuration files.
By default, it looks for a connection string named AzureWebJobsStorage and listens to the queue specified in function.json.
🧪 Step 5: Test the Function Locally
Run your project to see if everything works as expected:
1func start
To simulate a real use case, you can manually enqueue a message to the queue from Azure CLI or Storage Explorer and watch the function process it in real time.
🚀 Step 6: Create the Function App in Azure
Let’s deploy the cloud infrastructure where your function will live:
1az functionapp create --resource-group azure-app-function-rg --consumption-plan-location northeurope --runtime python --runtime-version 3.10 --functions-version 4 --name queueStorageTriggerAppFunc01 --os-type linux --storage-account appafuncstorageacc
This command spins up a fully managed Function App tied to your queue and storage.
📤 Step 7: Deploy the Function to Azure
Push your local function to the cloud environment:
1func azure functionapp publish queueStorageTriggerAppFunc01
Once deployed, your function will listen to the specified queue 24/7 and process messages automatically.
🧹 Step 8: Clean Up (Optional)
Done testing? You can safely remove all created resources with a single command:
1az group delete --name azure-app-function-rg
🎯 Use Cases for Queue Trigger Functions
Azure Queue Trigger Functions are incredibly useful for:
- Background job processing
- Asynchronous workflows
- Order or ticket processing
- Email notifications
- Logging or telemetry pipelines
They're reliable, scalable, and serverless—perfect for building reactive systems.
Securing Your Azure Function App with Azure Active Directory (Azure AD)
Security is a top priority when building cloud-native applications. Azure Function Apps make it easy to build and scale serverless APIs, but they shouldn’t be left wide open to the public. The good news? You can enable Azure Active Directory (AAD) authentication with just a few steps—no need to write custom auth logic.
In this tutorial, we'll walk you through enabling Azure AD authentication for your Azure Function App using a registered app, client secret, and Azure Identity provider settings.
✅ Bonus: We’ll show how to generate a Bearer token to test your authenticated function endpoint.
🎯 Step 1: Register an Application in Azure AD
To begin, you need an app registration in Azure AD that represents your client/service.
- Navigate to Azure Active Directory > App registrations
- Click "New registration"
- Provide a meaningful name and register the application
🔐 Step 2: Configure API Permissions and Secrets
Once your app is registered:
Expose the API
- Under your app registration, go to "Expose an API"
- Click "Add" next to Application ID URI
- Provide a URI like:
1api://f13ac6e2-b9a1-470d-99c3-82a1e6ab3d44
Grant API Permissions
- Go to "API permissions"
- Add necessary permissions and click "Grant admin consent"
Create a Client Secret
- Navigate to "Certificates & Secrets"
- Click "New client secret"
- Copy the value immediately after creation
Example:
client_secret:WPL4X~tyA7h3xOdPgQ.J-dFGKObzMQUjI9rQZbKZSecret ID:a7f8c1bb-12c7-467a-95d4-c0deadc733ab
⚠️ Never share your client secret publicly. This value is randomized for demo purposes.
🔍 Step 3: Gather Required Identifiers
You'll need the following values from your app registration:
Tenant ID (Directory ID):
1c9d8f9a-03a1-4bd5-bc33-7e3c9a1fb987Client ID (Application ID):
f13ac6e2-b9a1-470d-99c3-82a1e6ab3d44Object ID:
b3ed79c3-5f32-4039-b8a4-d2ec9fc98ac9Application ID URI:
api://f13ac6e2-b9a1-470d-99c3-82a1e6ab3d44
⚙️ Step 4: Configure Authentication on the Azure Function App
Now go to your Azure Function App and configure authentication settings:
- Navigate to Function App > Authentication
- Click "Add identity provider"
- Choose Microsoft (Azure Active Directory) and pick "Use existing app registration"
Fill in the following fields:
Issuer URL:
1https://sts.windows.net/1c9d8f9a-03a1-4bd5-bc33-7e3c9a1fb987/v2.0Authority:
1https://login.microsoftonline.comTenant ID:
1c9d8f9a-03a1-4bd5-bc33-7e3c9a1fb987Audience:
api://f13ac6e2-b9a1-470d-99c3-82a1e6ab3d44Client ID:
f13ac6e2-b9a1-470d-99c3-82a1e6ab3d44Client Secret:
(Use the value created earlier)
🔒 Step 5: Set Allowed Token Audiences
- Go to Function App > Authentication
- In the Identity provider section, click "Edit"
- Under Allowed Token Audiences, paste the following:
1api://f13ac6e2-b9a1-470d-99c3-82a1e6ab3d44
This ensures that only tokens issued for your specific application are accepted.
🛠️ Step 6: Generate a Bearer Token for Testing
You can test the secure endpoint by generating a Bearer token using client_credentials flow.
🔐 Use the following payload in a POST request:
Token Endpoint:
1https://login.microsoftonline.com/1c9d8f9a-03a1-4bd5-bc33-7e3c9a1fb987/oauth2/v2.0/token
Request Body:
1{
2 "client_id": "35cb4a08-2d5b-4b63-8e16-1f33f952b521",
3 "client_secret": "cLJ8Q~HfmdfhuxYEBn32zAs-frKSzMnQUsWOycRy",
4 "grant_type": "client_credentials",
5 "scope": "api://f13ac6e2-b9a1-470d-99c3-82a1e6ab3d44/.default"
6}
Use a tool like Postman, curl, or a simple Python script to request the token.
Once you receive the token, include it in the Authorization header of your API requests:
1Authorization: Bearer <your_token_here>
✅ Summary
You've successfully protected your Azure Function App with Azure AD authentication. By doing this:
- Only valid, authenticated clients can access your APIs
- You centralize identity using Microsoft Entra ID (formerly Azure AD)
- You avoid the need for managing user accounts or passwords in your code
This setup is ideal for securing internal tools, microservices, and APIs that need access control via Azure AD.