"When blob is added or modified" trigger will not be fired on subfolder

Mikhail Delly 126 Reputation points
2021-09-08T15:15:44.803+00:00

Does azure logic apps blob connector "When blob is added or modified" trigger support firing when subfolder was updated. According to using a flat listing https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-list?tabs=dotnet the blob hierarchy has the following structure:

blobcontainer/{guid1}/{guid2}/file.*

Is there a way to have "When blob is added or modified" triggered after adding new subfolder&file to blobcontainer/{guid1} if {guid1} exists.
The guid1 and guid2 folders are generating dynamically...

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,493 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,903 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,051 Reputation points
    2021-09-09T01:38:00.017+00:00

    The default connector doesn't allow this- it only watches one folder and since you'd need to update the logic app each time a folder is created, it would likely require some messy workarounds to make it happen.

    That being said, there is another option using the same approach as the Function's Storage/Event Grid trigger.

    Instead of a blob storage trigger, use a request trigger- the storage account will be pushing events to the Logic App instead of the other way around.

    130431-image.png

    Assuming you choose the default Event Grid format, the payload schema will be:

    {  
        "type": "array",  
        "items": {  
            "type": "object",  
            "properties": {  
                "topic": {  
                    "type": "string"  
                },  
                "subject": {  
                    "type": "string"  
                },  
                "eventType": {  
                    "type": "string"  
                },  
                "id": {  
                    "type": "string"  
                },  
                "data": {  
                    "type": "object",  
                    "properties": {  
                        "api": {  
                            "type": "string"  
                        },  
                        "clientRequestId": {  
                            "type": "string"  
                        },  
                        "requestId": {  
                            "type": "string"  
                        },  
                        "eTag": {  
                            "type": "string"  
                        },  
                        "contentType": {  
                            "type": "string"  
                        },  
                        "contentLength": {  
                            "type": "integer"  
                        },  
                        "blobType": {  
                            "type": "string"  
                        },  
                        "url": {  
                            "type": "string"  
                        },  
                        "sequencer": {  
                            "type": "string"  
                        },  
                        "storageDiagnostics": {  
                            "type": "object",  
                            "properties": {  
                                "batchId": {  
                                    "type": "string"  
                                }  
                            }  
                        }  
                    }  
                },  
                "dataVersion": {  
                    "type": "string"  
                },  
                "metadataVersion": {  
                    "type": "string"  
                },  
                "eventTime": {  
                    "type": "string"  
                }  
            },  
            "required": [  
                "topic",  
                "subject",  
                "eventType",  
                "id",  
                "data",  
                "dataVersion",  
                "metadataVersion",  
                "eventTime"  
            ]  
        }  
    }  
    

    In your storage account, go to Events -> + Event Subscription

    130441-image.png

    Give the subscription a name, and change event types to Blob Created (this will cover every blob in the storage account regardless of folder and will cover overwriting an existing blob, you can filter to container later).

    For the Endpoint Details you want to choose "Web Hook". The endpoint will be the one for your Logic App's request trigger.
    130481-image.png

    This creates an Event Grid Subscription Topic under the same resource group as your storage account.

    To filter to a specific container, open the event subscription back up and then add a subject filter for /blobServices/default/containers/<container name>. You can also make adjustments like using AAD authentication for your logic app instead of the trigger's key and batching.
    130502-image.png

    3 people found this answer helpful.
    0 comments No comments