I have this function App and I get the file once when I put one file on blob storage container! when I put 2 files, I get 4 files in my email addressee and the same file twice ! when I put 3 files I get 9 files , the same file duplicated 3 times , and when I put 4 files I get 16 files and the same file duplicated 4 times , how to resolve this ?
this my function app :
CodePudding user response:
As the Send an email (V2)
connector is in for each loop of Lists blob's value
, you are receiving everything in duplicate as it iterates all over the folder/container that you have set. After reproducing from our end this was working when we have changed Get Blob's Blob path to List of Files Path
of When a blob is added or modified (properties only) (V2)
and also use When a blob is added or modified (properties only) (V2)
content in Send email
too, we could receive emails on current item one time.
Here is the schema of my logic app
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Get_blob_content_(V2)_2": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/@{encodeURIComponent(encodeURIComponent(triggerBody()?['Path']))}/content",
"queries": {
"inferContentType": true
}
},
"runAfter": {
"Lists_blobs_(V2)": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Lists_blobs_(V2)": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent('JTJmY29udGFpbmVyMQ=='))}",
"queries": {
"nextPageMarker": "",
"useFlatListing": false
}
},
"metadata": {
"JTJmY29udGFpbmVyMQ==": "/container1"
},
"runAfter": {},
"type": "ApiConnection"
},
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Body": "<p>@{triggerBody()}</p>",
"Subject": "@triggerBody()?['DisplayName']",
"To": "<To email id>"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {
"Get_blob_content_(V2)_2": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_blob_is_added_or_modified_(properties_only)_(V2)": {
"evaluatedRecurrence": {
"frequency": "Second",
"interval": 1
},
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/triggers/batch/onupdatedfile",
"queries": {
"checkBothCreatedAndModifiedDateTime": false,
"folderId": "JTJmY29udGFpbmVyMQ=="
}
},
"metadata": {
"JTJmY29udGFpbmVyMQ==": "/container1"
},
"recurrence": {
"frequency": "Second",
"interval": 1
},
"splitOn": "@triggerBody()",
"type": "ApiConnection"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/***/resourceGroups/***/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/***/providers/Microsoft.Web/locations/centralus/managedApis/azureblob"
},
"office365": {
"connectionId": "/subscriptions/***/resourceGroups/***/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/***/providers/Microsoft.Web/locations/centralus/managedApis/office365"
}
}
}
}
}