(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon

How to create an Azure Logic App for email and Blob Storage integration

João Barros 21 de October de 2026 6 min read

This tutorial shows how to create an Azure Logic App that receives emails (Office 365 Outlook) and automatically saves attachments to Azure Blob Storage. It is useful to automate file ingestion, reduce manual work and integrate emails with ETL pipelines. It can save dozens of hours per month if you receive 100–500 attachments, and allows you to prepare files for further processing by Azure Functions, Data Factory or Power BI.

Prerequisites

  • Azure subscription with permissions to create resources. Ideally you have the Contributor role on the Resource Group or equivalent permissions for Storage and Logic App.
  • Office 365 account with access to Outlook/Exchange Online. Authentication can be delegated (user account) or via Service Principal, depending on the connector.
  • Existing Resource Group or permission to create one. A dedicated Resource Group for logic and storage is recommended to ease cost management.
  • Basic knowledge of the Azure Portal and Blob Storage concepts (containers, tiers, lifecycle). It is useful to know how to copy connection strings or generate SAS tokens for debugging.

Step 1: Create a Storage Account and container

We need a Storage Account with a container to store the attachments. The container can be private because the Logic App will use credentials to write. For production environments choose appropriate replication (for example, Standard_LRS). The account can support thousands of files; if you anticipate 10k–100k attachments per month, review lifecycle policies and tiers (Hot/Cool/Archive) to optimize costs.

# Exemplo com Azure CLI
az storage account create --name mylogicstorageacct --resource-group myResourceGroup --location westeurope --sku Standard_LRS --kind StorageV2
az storage container create --name email-attachments --account-name mylogicstorageacct

After creating it, securely store the connection string or account key (Key Vault is recommended). Set the container access level to Private and consider adding a lifecycle policy to move blobs older than 90 days to Cool/Archive.

Step 2: Create the Logic App (Consumption) in the Azure Portal

In the Portal create a Logic App (Consumption) — it is simple and cost-effective for event-driven workflows. Give it a name and associate it with the Resource Group and location. The Consumption option bills per action and per execution, being suitable for moderate ingestion patterns (hundreds to a few thousand runs per day). For very high loads (thousands per minute) consider Logic Apps (Standard).

Choose the plan according to the desired latency and throughput: Consumption is near‑real time for connectors like Office 365 Outlook and is sufficient for most ingestion scenarios.

Step 3: Configure the Office 365 Outlook trigger - When a new email arrives

In the Logic App designer add the "When a new email arrives (V3)" trigger from the Office 365 Outlook connector. Authenticate with the Office 365 account. Configure filters to avoid noise — for example only emails with attachments, Subject contains "Invoice" or From contains "@fornecedor.com". This reduces the number of runs and costs. The connector uses a push trigger, so latency is usually under a minute.

Trigger: When a new email arrives (V3)
- Folder: Inbox
- Has Attachments: Yes
- Include Attachments: Yes
- Filter: Subject contains "Invoice"  (optional)

If you need to process only specific file types, you can filter by Content-Type or attachment name later in the flow.

Step 4: Iterate attachments and create files in Blob Storage

Add an "Apply to each" action over the Attachments output from the trigger. Inside the loop use the Azure Blob Storage connector action "Create blob" to write each attachment. To authenticate choose the Storage Account created (via connection string or Managed Identity, if configured).

# Campos importantes na ação Create blob
- Folder Path / Container: email-attachments
- Blob Name: @{concat(formatDateTime(utcNow(),'yyyyMMddHHmmss'),'-',replace(items('Apply_to_each')?['name'],' ','_'))}
- Blob Content: @{base64ToBinary(items('Apply_to_each')?['contentBytes'])}

Using a timestamp in the name reduces duplicates and helps order files. To ensure valid names replace spaces and invalid characters (e.g.: replace(...)). Check the maximum attachment size supported by the connector; generally messages with attachments up to ~150 MB can be processed but this depends on the Exchange/tenant configuration.

Step 5: Handle errors and avoid duplicates

Add a condition to check if the file already exists before creating it — for example using the "Get blob metadata" or "List blobs" action to look for a matching name. Alternatively, use a naming scheme with a timestamp and a unique identifier (MessageId).

To manage errors, use the "Configure run after" capability so that in case of failure or timeout a recovery action is executed: send an email to the admin, write a record in Table Storage or create an item in a Queue for reprocessing. This eases monitoring and reduces file loss.

# Exemplo de BlobName com timestamp e MessageId
@{concat(formatDateTime(utcNow(),'yyyyMMddHHmmss'),'-',triggerOutputs()?['body/messageId'],'-',items('Apply_to_each')?['name'])}

Also consider adding a validation step (e.g.: check mime-type and size) and a Storage lifecycle policy (e.g.: delete after 180 days) to control costs.

Verify the result

To confirm everything works, send a test email with 2–3 varied attachments to the monitored account. In the Portal, open the Logic App, view the Run history and expand an execution to inspect inputs/outputs of each action. You should see the list of attachments, creation of each blob and success codes (200/201).

Also check the email-attachments container that the blobs were created with the correct content (confirm size and type). If something fails, the error details appear in the run history with the connector message — this helps adjust timeout and retry limits.

Conclusion

You now have an Azure Logic App that automates ingestion of email attachments to Azure Blob Storage — useful for ETL pipelines, backups or later processing by Functions or Data Factory. Practical next steps: filter by MIME type, add validation/antivirus, use Managed Identity for secure authentication, or connect to an Azure Function for processing (for example, CSV→Parquet conversion). Tip: use blob names with metadata, configure lifecycle policies (e.g.: move to Cool after 30 days) and monitor execution costs to optimize the process.