Azure Logic App, upload files to sftp from blob storage

Oskar Svedman 21 Reputation points
2021-03-24T14:06:15.73+00:00

Hi,I need help with with a logic app I created. Probably a very simple config for someone how know how it works (not me...)

I want:

files are put in my blob container /sftpblob from an another system

the files should be uploaded to an external sftp server

after the file is uploaded the file should be moved to an archive folder in the blob storage.

I want an e-mail notification when a file is uploaded successful.

Today the upload is working but the files still remain in the blob storage container /sftpblob I get several files here each day so I want to "clean" it and move them to the archive container.

Thanks for any tips how to do this :)

81177-logic-app-design.png

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,318 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,796 Reputation points
    2021-03-24T15:14:23.923+00:00

    Hi @Anonymous

    Welcome to Microsoft Q&A! Thanks for posting the question.

    In your scenario, once the file is uploaded successfully to your SFTP server. You can now use the Create Blob to create the blob in the archive container of the storage account and Delete Blob to delete the file from your sftpblob container.

    Updated:

    I haven't added the Create File action to copy the blob content to SFTP server. In the third action, I am copying the blob content to my archive folder and in the last action, I am deleting the file from my original container (input). The below is just for reference and you can modify it according to your business requirement.

    82680-image.png

    For your reference adding only the action code view

    "actions": {  
                "Create_blob": {  
                    "inputs": {  
                        "body": "@body('Get_blob_content_using_path')",  
                        "host": {  
                            "connection": {  
                                "name": "@parameters('$connections')['azureblob']['connectionId']"  
                            }  
                        },  
                        "method": "post",  
                        "path": "/datasets/default/files",  
                        "queries": {  
                            "folderPath": "/archive",  
                            "name": "@triggerBody()?['Path']",  
                            "queryParametersSingleEncoded": true  
                        }  
                    },  
                    "runAfter": {  
                        "Get_blob_content_using_path": [  
                            "Succeeded"  
                        ]  
                    },  
                    "runtimeConfiguration": {  
                        "contentTransfer": {  
                            "transferMode": "Chunked"  
                        }  
                    },  
                    "type": "ApiConnection"  
                },  
                "Delete_blob": {  
                    "inputs": {  
                        "host": {  
                            "connection": {  
                                "name": "@parameters('$connections')['azureblob']['connectionId']"  
                            }  
                        },  
                        "method": "delete",  
                        "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(triggerBody()?['Path']))}"  
                    },  
                    "runAfter": {  
                        "Create_blob": [  
                            "Succeeded"  
                        ]  
                    },  
                    "type": "ApiConnection"  
                },  
                "Get_blob_content_using_path": {  
                    "inputs": {  
                        "host": {  
                            "connection": {  
                                "name": "@parameters('$connections')['azureblob']['connectionId']"  
                            }  
                        },  
                        "method": "get",  
                        "path": "/datasets/default/GetFileContentByPath",  
                        "queries": {  
                            "inferContentType": true,  
                            "path": "@triggerBody()?['Path']",  
                            "queryParametersSingleEncoded": true  
                        }  
                    },  
                    "runAfter": {},  
                    "type": "ApiConnection"  
                }  
            },  
    

    Feel free to reach out to me if you need any assistance.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

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.