Enhancing Local Azure Functions Development with Blob Trigger, Timer Trigger, Http Trigger Using Azure Storage and Azurite Extensions
- sujosutech
- Mar 31
- 5 min read
Extending the Local Development Workflow
Microsoft's guide to local Azure Functions development using the Azure Functions Core Tools and Azurite already covers foundational setups like running a local storage emulator. Building on this, we can add three advanced trigger types to enhance functionality—Blob Trigger for file-based events, Timer Trigger for scheduled tasks, and Timer Trigger.
Developing Azure Functions locally is a great way to test and debug your cloud applications without needing to deploy every change to the cloud. This can save both time and costs, especially during the development phase. To accomplish this, you can use the Azure Functions Core Tools along with Azurite, a local emulator for Azure Storage services.

At Sujosu Technology, we optimize Azure Functions development workflows, enabling businesses to build, test, and deploy serverless applications seamlessly. In this blog, we explore how to set up local Azure Functions development, integrate triggers, and streamline workflows with Azure Storage and Azurite extensions.
Why Develop Azure Functions Locally?
Building Azure Functions locally offers several advantages:
Faster Development & Testing – Avoid delays from cloud deployments.
Cost Savings – Reduce Azure consumption costs during development.
Seamless Debugging – Get real-time feedback within the local environment.
Realistic Cloud Simulation – Use Blob, Timer, and HTTP Triggers to mimic production workflows.
Setting Up Your Local Environment
To get started, initialize an Azure Functions project locally by running the following command:
func init sujosuFunctionApp --worker-runtime node
func init: This command initializes a new Azure Functions project.
Sujosu FunctionApp: This is the name of your function app (you can replace it with any name you'd like).
worker runtime node: This specifies that the runtime for the function will be Node.js.
This will set up the necessary directory structure and configuration files for your Azure Functions project with Node.js as the runtime
If you encounter the following error:

This means that PowerShell script execution policies are blocking the function runtime. To resolve this, check the execution policy status by running: Get-ExecutionPolicy
If it’s restricted, you can temporarily bypass this for local testing by running:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
What the Command Does:
Scope Restriction: The change applies only to the current PowerShell process, and once you close the session, the execution policy will revert to its original state.
Temporary Bypass: It allows you to execute scripts that are normally blocked, such as those with Restricted or RemoteSigned policies.
After adjusting the policy, proceed with:
func init sujosuFunctionApp --worker-runtime node
This will create the default project structure for your Azure Functions app. You can then navigate to this directory: cd sujosuFunctionApp
Adding the Azurite and Azure Storage Extensions
To enhance your local development, install the Azurite and Azure Storage extensions in Visual Studio Code:
Open the Extensions Marketplace.
Search for Azurite and Azure Storage, and install both.
Using Azurite
After installation:
Start the Azurite services from the bottom panel in VS Code.
This provides a local Azure Storage emulator to interact with blob containers, queues, and tables.
Using Azure Storage
The Azure Storage extension allows you to:
Browse and interact with local blob containers.
Upload and manage blobs seamlessly within VS Code.
Creating Blob Trigger with Azurite
A Blob Trigger function is activated when a new blob is added or an existing blob is modified in a specified Azure Blob Storage container. This is especially useful when dealing with file uploads, data processing, or event-based workflows. Here’s how to implement it:
Use Cases
Image Processing
Scenario: Users upload high-resolution images to a uploads container.
Action: A Blob Trigger resizes images to thumbnails, optimizes them, and saves to a processed container.
Business Impact: Faster page loads and reduced storage costs.
Log File Analysis
Scenario: Systems dump logs into a raw-logs container hourly.
Action: Parse logs for errors, trigger alerts, and archive to cold storage.
Business Impact: Proactive issue resolution and audit compliance.
Data Ingestion
Scenario: CSV files from IoT devices land in a staging container.
Action: Convert CSV data into structured database entries.
Business Impact: Real-time analytics-ready data.
Step 1: Create the Function
Run the following command to create a Blob Trigger function:
func new --template "Azure Blob Storage trigger" --name BlobTriggerFunction
To see a list of available templates, use:
func templates list
This will display all the function templates you can use, including BlobTrigger, HttpTrigger, TimerTrigger, and more.
Step 2: Update the Code
Modify the container path and add your logic in the generated function file. This ensures the function processes the required blobs.

Step 3: Configure local.settings.json
Update the configuration to point to Azurite:

This configuration uses the UseDevelopmentStorage=true setting to run Azurite locally instead of connecting to Azure Storage in the cloud.
Step 4: Upload a Blob
Using the Azure Storage extension:
Attach to the Azurite emulator.
Navigate to your blob container.
Right-click and choose Upload Blob.
Observe the function triggering and processing the blob in the terminal logs.
Implementing Timer Trigger Function
The Timer Trigger is commonly used for scheduled tasks, such as recurring jobs, cron jobs, and other background processes. You can configure your Timer Trigger using cron expressions.
Use Cases
Daily Reports
Scenario: Generate a sales summary PDF every day at 8 AM.
Cron Schedule: 0 0 8 *
Buso iness Impact: Stakeholders receive actionable insights at sunrise.
Database Cleanup
Scenario: Delete expired user sessions nightly.
Cron Schedule: 0 0 0 * (Midnight UTC).
Business Impact: Optimized database performance.
Batch Processing
Scenario: Aggregate user activity data hourly for dashboards.
Cron Schedule: 0 0
Business Impact: Real-time business intelligence.
Step 1: Create the Function
Run the following command:
func new --template "Timer Trigger" --name TimerTriggerFunction
Step 2: Update the Code
Set up the schedule dynamically using an environment variable in local.settings.json:

In this setup, the schedule property is dynamically set to the value of the BATCH_JOB_CRON environment variable, which is configured in the local.settings.json. You can adjust this cron expression to match your specific scheduling needs. For example, "* /5 *" will trigger the function every 5 minutes.
Make sure the relevant entries are added to local.settings.json:

Implementing HTTP Trigger
The HTTP Trigger allows you to call Azure Functions through HTTP requests. Here’s how to set it up:
Use Cases
RESTful APIs
Scenario: A frontend app fetches product data via a GET endpoint.
Business Impact: Decoupled microservices architecture.
Webhook Handlers
Scenario: Process payment success/failure events from Stripe.
Business Impact: Automated order fulfillment and inventory updates.
Authentication Services
Scenario: Validate user credentials and issue JWT tokens.
Business Impact: Secure access control for apps.
Step 1: Create the Function
Run:
func new --template "HTTP Trigger" --name HttpTriggerFunction
Step 2: Update the Code
Here's a simple example of an HTTP Trigger function:

Combining Triggers for End-to-End Workflows
Imagine a job portal:
Blob Trigger: Resumes uploaded to a resumes container are parsed for skills.
Timer Trigger: A nightly job matches skills to job listings and emails candidates.
HTTP Trigger: Candidates view matches via an API integrated with a frontend app.
Running the Azure Functions Application Locally
After setting up your triggers, start the Azure Functions runtime to test them:
Start the Functions Server: Navigate to the project directory and run:
func start
This launches the Azure Functions host locally, listening for trigger events.
Observe Logs:
Blob Trigger: Upload a file to the blob container and watch the terminal log its processing.
Timer Trigger: Logs will appear at scheduled intervals.
HTTP Trigger: The terminal displays the HTTP endpoint (e.g.,http://localhost:7071/api/HttpTriggerFunction).

Project Structure:

Conclusion:
Streamline Local Development with Azure Functions & Azurite
Developing Azure Functions locally with Blob, Timer, and HTTP Triggers simplifies testing, debugging, and deployment. By leveraging Azurite and Azure Storage Extensions, businesses can create cost-effective, scalable, and cloud-ready applications.
At Sujosu Technology, we help enterprises:
Optimize serverless workflows with Azure Functions.
Automate cloud deployments with efficient triggers.
Enhance scalability and security with Azure’s best practices.
Ready to accelerate your Azure Functions development? Partner with Sujosu Technology for expert solutions!
コメント