Hi @Aadhil Imam
The Blob Storage trigger would be the most appropriate for your scenario. This trigger starts a function whenever a new or updated blob is detected in the specified Blob Storage container.
For the implementation, you can follow these general steps:
- Create an event-based Blob Storage triggered function in a new project.
- Validate locally within Visual Studio Code using the Azurite emulator.
- Create a blob storage container in a new storage account in Azure.
- Create a function app in the Flex Consumption plan (preview).
- Create an event subscription to the new blob container.
- Deploy and validate your function code in Azure.
For a Python code example, you can refer to the following snippet:
import logging
import azure.functions as func
from azure.storage.blob import BlobServiceClient
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
# Create a blob service client
blob_service_client = BlobServiceClient.from_connection_string("<your_connection_string>")
# Get the container client
container_client = blob_service_client.get_container_client("<your_container_name>")
# Read the blob data
blob_client = container_client.get_blob_client(myblob.name)
data = blob_client.download_blob().readall()
# Process the data
processed_data = process_data(data) # Replace with your data processing logic
# Write the processed data to the destination blob
dest_blob_client = container_client.get_blob_client("<destination_blob_name>")
dest_blob_client.upload_blob(processed_data, overwrite=True)
Please replace <your_connection_string>
, <your_container_name>
, and <destination_blob_name>
with your actual Blob Storage connection string, container name, and destination blob name, respectively. Also, replace process_data(data)
with your actual data processing logic.
Additional reference: https://medium.com/@kvanshika94/connecting-to-azure-blob-storage-using-azure-functions-python-4fefa1adf66b
If this answer solves your problem, please mark it as accepted.