Workflow from Email to blob using logic apps

Power BI Admin Ciel 0 Reputation points
2024-04-29T07:54:32.59+00:00

can anyone help me on this error. Actually i created flow where it takes the file from mail and upload it on the blob folder.User's image

Azure SQL Database
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 19,078 Reputation points Moderator
    2024-04-29T10:14:56.62+00:00

    @Power BI Admin Ciel Thanks for your question. I have reproduced your issue in my environment and I am able to successfully upload the blobs that are received as attachments from the email. Here is my logic app code for your reference.

    User's image

    {
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "Compose": {
                    "inputs": "@triggerBody()?['attachments']",
                    "runAfter": {},
                    "type": "Compose"
                },
                "For_each": {
                    "actions": {
                        "Create_blob_(V2)": {
                            "inputs": {
                                "body": "@{items('For_each')?['contentBytes']}",
                                "headers": {
                                    "ReadFileMetadataFromServer": true
                                },
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['azureblob']['connectionId']"
                                    }
                                },
                                "method": "post",
                                "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files",
                                "queries": {
                                    "folderPath": "/hhjlll",
                                    "name": "@{items('For_each')?['name']}",
                                    "queryParametersSingleEncoded": true
                                }
                            },
                            "runtimeConfiguration": {
                                "contentTransfer": {
                                    "transferMode": "Chunked"
                                }
                            },
                            "type": "ApiConnection"
                        }
                    },
                    "foreach": "@outputs('Compose')",
                    "runAfter": {
                        "Compose": [
                            "Succeeded"
                        ]
                    },
                    "type": "Foreach"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {
                "$connections": {
                    "defaultValue": {},
                    "type": "Object"
                }
            },
            "triggers": {
                "When_a_new_email_arrives_(V3)": {
                    "inputs": {
                        "fetch": {
                            "method": "get",
                            "pathTemplate": {
                                "template": "/v3/Mail/OnNewEmail"
                            },
                            "queries": {
                                "fetchOnlyWithAttachment": true,
                                "folderPath": "Id::AAMkADExZTRjNDJmLTMwNzktNGM4ZC05YThmLTQ5NWMwODk0ZGQxMwAuAAAAAABrSNp1lgosTJyDa_IAMdNMAQAMlk7ChMbeS7yA0c_URndrAAOD5QzHAAA=",
                                "importance": "Any",
                                "includeAttachments": true
                            }
                        },
                        "host": {
                            "connection": {
                                "name": "@parameters('$connections')['office365']['connectionId']"
                            }
                        },
                        "subscribe": {
                            "body": {
                                "NotificationUrl": "@{listCallbackUrl()}"
                            },
                            "method": "post",
                            "pathTemplate": {
                                "template": "/GraphMailSubscriptionPoke/$subscriptions"
                            },
                            "queries": {
                                "fetchOnlyWithAttachment": true,
                                "folderPath": "Id::AAMkADExZTRjNDJmLTMwNzktNGM4ZC05YThmLTQ5NWMwODk0ZGQxMwAuAAAAAABrSNp1lgosTJyDa_IAMdNMAQAMlk7ChMbeS7yA0c_URndrAAOD5QzHAAA=",
                                "importance": "Any"
                            }
                        }
                    },
                    "metadata": {
                        "Id::AAMkADExZTRjNDJmLTMwNzktNGM4ZC05YThmLTQ5NWMwODk0ZGQxMwAuAAAAAABrSNp1lgosTJyDa_IAMdNMAQAMlk7ChMbeS7yA0c_URndrAAOD5QzHAAA=": "Azure SDK"
                    },
                    "splitOn": "@triggerBody()?['value']",
                    "type": "ApiConnectionNotification"
                }
            }
        },
        "parameters": {
            "$connections": {
                "value": {
                    "azureblob": {
                        "connectionId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/sw/providers/Microsoft.Web/connections/azureblob",
                        "connectionName": "azureblob",
                        "id": "/subscriptions/
    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    /providers/Microsoft.Web/locations/southindia/managedApis/azureblob"
                    },
                    "office365": {
                        "connectionId": "/subscriptions/
    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    /resourceGroups/sw/providers/Microsoft.Web/connections/office365-1",
                        "connectionName": "office365-1",
                        "id": "/subscriptions/
    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    /providers/Microsoft.Web/locations/southindia/managedApis/office365"
                    }
                }
            }
        }
    }
    
    

Your answer

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