how to get only directory name created inside container in logic app

Ananya Dixith 61 Reputation points
2024-04-16T04:34:47.3666667+00:00

Hi ,

Our requirement is to get only the directory name present inside container.

User's image

At first used list blobs and then path action

Used split action for path to get directory name, but its not working..

Anyone pls help us with this

Thanks in advance

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 18,996 Reputation points Moderator
    2024-04-22T16:08:14.3166667+00:00

    @Ananya Dixith Thanks for reaching out. You can retrieve the directory names using split function within compose action as "split(items('For_each')?['DisplayName'],'/')" and get first string which is directory name by using another compose action with input as "outputs('Compose')[0]". For your reference, I have tested this in my environment and here is the process. Here is my structure which is almost same as yours.User's image

    logic app is as follows:

    User's image

    Logic app code:

    {
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "For_each": {
                    "actions": {
                        "Compose": {
                            "inputs": "@split(items('For_each')?['DisplayName'],'/')",
                            "type": "Compose"
                        },
                        "Compose_1": {
                            "inputs": "@outputs('Compose')[0]",
                            "runAfter": {
                                "Compose": [
                                    "Succeeded"
                                ]
                            },
                            "type": "Compose"
                        }
                    },
                    "foreach": "@body('Lists_blobs_(V2)')?['value']",
                    "runAfter": {
                        "Lists_blobs_(V2)": [
                            "Succeeded"
                        ]
                    },
                    "type": "Foreach"
                },
                "Lists_blobs_(V2)": {
                    "inputs": {
                        "host": {
                            "connection": {
                                "name": "@parameters('$connections')['azureblob']['connectionId']"
                            }
                        },
                        "method": "get",
                        "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent('JTJmaGhqbGxs'))}",
                        "queries": {
                            "useFlatListing": false
                        }
                    },
                    "metadata": {
                        "JTJmaGhqbGxs": "/hhjlll"
                    },
                    "runAfter": {},
                    "type": "ApiConnection"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {
                "$connections": {
                    "defaultValue": {},
                    "type": "Object"
                }
            },
            "triggers": {
                "Recurrence": {
                    "evaluatedRecurrence": {
                        "frequency": "Month",
                        "interval": 3
                    },
                    "recurrence": {
                        "frequency": "Month",
                        "interval": 3
                    },
                    "type": "Recurrence"
                }
            }
        },
        "parameters": {
            "$connections": {
                "value": {
                    "azureblob": {
                        "connectionId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx/resourceGroups/rgn/providers/Microsoft.Web/connections/azureblob",
                        "connectionName": "azureblob",
                        "id": "/subscriptions/
    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx
    /providers/Microsoft.Web/locations/southindia/managedApis/azureblob"
                    }
                }
            }
        }
    }
    
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.