Skip to content

search4akash/Serverless-Image-Processing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌟 Serverless Image Processing with Azure Logic Apps & Shell Scripting

🔹 Project Overview

This project automates image processing using Azure Logic Apps and Linux shell scripting. The workflow includes:

✅ Uploading images to Azure Blob Storage.

✅ A Logic App triggers a shell script when a new image is uploaded.

✅ A Linux-based script processes the images (resize, watermark, etc.).

✅ The processed images are stored in another Blob container.


📚 Table of Contents


Step 1: Set Up Azure Blob Storage

  • Storage Setup Script: Infrastructure/storage_setup.sh
    • This script creates an Azure Storage Account with two containers:
      • raw-images → Stores the original images.
      • processed-images → Stores the processed images.

Step 2: Deploy a Linux VM (or Use ACI)

  • VM Setup Script: Infrastructure/vm_setup.sh
    • This script creates an Azure Linux VM or sets up Azure Container Instances (ACI) for running the image processing script.

Step 3: Write the Image Processing Shell Script

  • Image Processing Script: Scripts/process_images.sh
    • This script fetches images from Blob Storage, processes them, and uploads the processed images back to Blob Storage.

Step 4: Set Up Azure Logic Apps

  1. Create a Logic App:

    • Go to the Azure portal and create a new Logic App.
  2. Add Trigger: When a Blob is Added or Modified:

    • Choose the trigger "When a blob is added or modified (V2)".
    • Configure it to point to your raw-images container in your Azure Blob Storage.
    • This trigger will activate the Logic App whenever a new image is uploaded or an existing image is updated.
  3. Add Action: HTTP Request:

    • After the blob trigger, add a new action for the HTTP request.
    • Choose the action "HTTP".
    • Set the method to POST and provide the URL for your Flask API endpoint (e.g., http://<your-vm-ip>:8080/run-script).
    • In the body, you can include any relevant data if necessary (e.g., the name of the blob or any other parameters).
  4. Add Trigger: When an HTTP Request is Received:

    • If you want to manually trigger the processing, add a second trigger by choosing "When an HTTP request is received".
    • This will allow you to invoke the Logic App via an HTTP request whenever you need to process the images.
  5. Configure the Logic App:

    • Once you have set up both triggers, you can define the workflow further by connecting additional actions as needed, such as logging or sending notifications.

Step 5: Set Up an API to Run the Script

  • API Script: APIs/app.py
    • This Flask API allows the Logic App to trigger the image processing script.

Step 6: Test the System

  1. Upload an Image to raw-images:

    az storage blob upload --container-name raw-images --account-name store4serverless --file sample.jpg
  2. Trigger the Logic App:

    • This is automatically triggered by the blob upload.
  3. Test the Flask API Manually (if needed):

    curl -X POST http://<your-vm-ip>:8080/run-script
  4. Execute the Image Processing Script Manually (for testing):

    cd Scripts
    ./process_images.sh
  5. Check the processed-images Container to see if the processed image appears.


📊 Summary

Step Task Files
1️⃣ Set up Azure Blob Storage storage_setup.sh
2️⃣ Deploy Linux VM / ACI vm_setup.sh
3️⃣ Write Shell Script process_images.sh
4️⃣ Set Up Logic App Azure Portal
5️⃣ Create API to Trigger Script app.py
6️⃣ Test the Workflow Azure CLI

🎯 Learning Outcomes

✅ Hands-on Azure Logic Apps for automation.

✅ Advanced Bash scripting for image processing.

✅ Real-world Azure Blob Storage Management.

✅ Deployment of serverless solutions using ACI or VM.

✅ Secure VM automation with Flask APIs & HTTP triggers.


📚 Official Documentation


📞 Contact

For any help or inquiries regarding this project, feel free to reach out to me at search4akash@outlook.com!