Overview

2 Using Azure: Azure Functions and Image Processing

This chapter uses a practical, real-world scenario to introduce Azure’s serverless capabilities: ingesting image attachments sent via email, storing them, and generating web-optimized copies. The solution targets key outcomes—scalability, cost efficiency, low maintenance, and robustness—while deliberately excluding the album website, email setup, and sender-to-album logic. Everything is organized within a single resource group and relies on pay-per-use services so it can be built and experimented with using free or low-cost tiers.

The implementation centers on three Azure services working together. A storage account with blob containers holds both original and resized images. A Logic App (consumption plan) watches an email inbox, filters for messages with attachments, and saves those attachments as blobs—mapping email metadata to blob fields without writing code. An Azure Function (in a Function App on the consumption plan) is triggered by new blobs, resizes the images using the SixLabors ImageSharp library, and writes the optimized output to a separate container via an output binding. Along the way, the chapter highlights sensible defaults, access considerations, connections to storage, enabling monitoring with Application Insights, and validating the full flow with simple end-to-end tests.

After the build, the chapter reflects on the operational benefits: automatic scaling of Logic Apps and Functions, strong performance on demand, and resilient, fault-tolerant infrastructure without managing servers. Costs remain predictable and low thanks to generous free execution grants and pay-per-use pricing, though a precise bill depends on workload. It also notes improvements required for production—filtering to images only, choosing storage tiers thoughtfully, and adopting better naming and data modeling—before concluding with best practice housekeeping: delete the resource group to remove all deployed assets and avoid ongoing charges.

Application architecture overview
The first step is the resource group.
Go to the resource group section.
Create a new resource group
Enter values for the resource group.
When validation has passed, you can create the resource group.
We are now creating the Storage Account and blob storage of the solution
Click Create to create a new container within the storage account
Fill in the basic values for the storage account.
Networking settings for the storage account.
Data Protection settings for the storage account.
Storage account overview.
Storage account hierarchy: blobs inside containers inside a storage account.
Click on the “+ Container” button to create a new container
New container properties
Warning for public access level of “Container”
A complete container shown in the Azure Portal.
Add the Logic App and email account connection to the project.
Create a new Logic App using the Azure Portal.
Create a new Logic App.
Choose hosting plan for your Logic App. We will use “consumption”.
Fill in the details for the Logic App.
The overview screen for a Logic App
Connect your email account using the designer.
Adjust the settings for the “email arrives” step.
Choose the action “Create block blob” which will create a block blob for us and fill it with the email attachment.
Connect the action in the Logic App to the storage account.
Choose the Attachments Content dynamic field to iterate through the email attachments.
The operation changes to a ‘For each’ when choosing a collection of input, such as Attachments.
Select the email properties to use.
The complete Logic App has run for the first time.
The image file received on email and now stored in the storage account.
We are now at the “resizing images with Azure Functions” part of the application.
Decide on the container name and the access level.
Find the Function App section in the Azure Portal.
The types of Function app that you can create. Choose consumption for this exercise.
Add the properties for the Function App
Set up the hosting for the Azure Function App.
Enable Application Insights for the Function App
Function App Dashboard
The web frontend for a brand new Azure Function. Pretty, right?
Create a new function and use the blob storage trigger template.
Make sure the function template settings are correct, particularly the path.
The Integration section of the Function.
Add an output for the function that targets the “imageoutputcontainer” blob storage.
Now we have input and output open up the Function code.
The template Azure Function code.
C# code to resize an image.
Upload the function.proj file.
Saving a file in the editor triggers compilation of the function.
The function is triggered when a new image is inserted into the storage account.
The resized image in the blob container for output.
Steps to deleting the resources used in this chapter.

Summary

  • Every Azure resource has to be in a resource group, which is one of the first parts to create for any project on Azure.
  • Storage accounts can have blob containers that can hold blobs, which are pretty much any kind of binary object, such as images.
  • Logic apps are workflows consisting of connectors and triggers. Connectors let you hook into third party services such as email clients to manipulate their data. Triggers make the workflow start when a certain event happens.
  • Azure services such as storage, Functions and Logic Apps can be connected to create more powerful applications that can add value to your business.
  • Azure Functions are single-purpose compute processes that run entirely within Azure. They’re called functions because that is all they do; a single function.
  • It is not uncommon to build entire applications from hundreds or even thousands of Azure Functions, each responsible for a single purpose. This makes it simple to build, debug and maintain.
  • Azure application lifecycles can be much easier to manage than traditional applications, as you can focus only on the services you interact with and not worry about hardware and other infrastructure.
  • Azure Services can be extremely cost effective, such as using free Azure Function executions, only paying for the storage you are using (and not the whole allocation), and only paying for the actual executions of a Logic App.
  • Resource groups act as containers not just for organization, but also for lifecycle management—delete the group, and all resources inside are deleted too.
  • Storage accounts provide multiple data services (blobs, queues, tables, and files) under one roof, making them a core building block for many Azure solutions.
  • Blob containers allow you to fine-tune access levels, from fully private to anonymous blob access, depending on your scenario.
  • Logic Apps use triggers and actions to create workflows without code, letting you connect dozens of services with minimal setup.
  • Standard vs. Consumption plans for Logic Apps (and Functions) let you balance between pay-as-you-go flexibility and more predictable reserved capacity.
  • Functions are highly extensible; bindings let you connect inputs and outputs (like blobs, queues, or databases) without boilerplate code.
  • Application Insights can be integrated into Functions and Logic Apps to monitor health, performance, and usage patterns in near real-time.
  • Azure’s serverless services scale automatically, so you don’t have to provision or guess capacity ahead of time.
  • Pricing models often include generous free tiers (e.g., Functions and Logic Apps), which makes experimentation inexpensive or even free.
  • Designing with separation of concerns—Logic App for orchestration, Function for compute, Storage for persistence—helps keep solutions modular, flexible, and easier to maintain.

FAQ

What problem does the chapter’s solution address?Automatically ingesting large image attachments emailed by users, storing the originals and producing web-optimized copies to speed up an online photo album while keeping costs, maintenance, and scaling needs low.
Which Azure services are used in the architecture?A resource group, an Azure Storage account with blob containers, a Logic App (Consumption) to read email attachments and save them to storage, and a Function App (Consumption) that resizes images. Application Insights is enabled for monitoring.
What is a resource group and why use it?A resource group is a logical container in a single subscription and region that holds related resources (up to ~800). Grouping by project simplifies management, access, cost tracking, and clean-up (delete the group to remove everything inside).
How are email attachments ingested into Azure?Using a Logic App with the Office 365 Outlook trigger “When a new email arrives,” set Only with attachments = Yes and Include attachments = Yes, then an action “Create block blob” writes each attachment to the chosen blob container.
How should I configure Blob Storage access for this scenario?Set container public access thoughtfully. The walkthrough uses “Blob” (anonymous access to blob data) for simplicity, but production often prefers “Private” with authenticated access. Avoid “Container” unless listing should be public.
How is the Azure Function triggered and where does it write outputs?The function uses a Blob Storage Trigger on path imagecontainer/{name} so new uploads fire the function. An output binding writes the resized image to imageoutputcontainer/{rand-guid} via the named output binding (e.g., outputBlob).
Which code and libraries perform the image resize?A C# script function (run.csx) uses SixLabors.ImageSharp to load the input stream (myBlob), resize to 100×100, and write to outputBlob. A function.proj file references the NuGet package (SixLabors.ImageSharp) so the function can compile it.
How do I test and monitor the workflow end-to-end?Send an email with an image to the configured inbox. Check the Logic App run history, verify the original image in the input container, view Function logs for the trigger run, and confirm the resized image appears in the output container. Enable Application Insights for deeper telemetry.
How does the solution scale and what might it cost?Logic Apps and Functions on the Consumption plan auto-scale; Functions include 1M free executions/month. A sample scenario in the chapter estimates about $36.94/month for the outlined volumes and storage, but actual costs vary by usage and region.
How do I clean up to avoid ongoing charges?Delete the resource group created for the project in the Azure Portal. Confirm the group name when prompted; Azure removes the group and all contained resources.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Microsoft Azure in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Microsoft Azure in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Microsoft Azure in Action ebook for free