Skip to main content

Notifications

Dynamics 365 Business Central SaaS: save a file to an SFTP server (the Logic App way)

Stefano Demiliani Profile Picture Stefano Demiliani 37,160 Most Valuable Professional

Yesterday I’ve provided a solution for saving a file generated directly from a Dynamics 365 Business Central SaaS tenant to an SFTP server by using Azure Functions. I’ve to admit that this is my preferred way because it gives me more freedom, scalability and adaptability. But obviously, that’s not the only possible way to do so.

Today, I want to describe another possible solution, absolutely reliable and that involves less coding skills: using Azure Logic Apps.

Azure Logic Apps make possible to execute custom workflow in the cloud without too much programming skills. You can create your workflows directly via a graphical front-end embedded in the Azure Portal and while you can see Azure Functions like a code triggered by an event, Logic Apps are instead a workflow triggered by an event. From a Logic App you can use connectors to connect to a wide range of applications and cloud services. Logic App is the “big brother” of Power Automate (Power Automate is built using Logic App itself, it’s hosted on Office 365 instead of Azure and is less scalable than Logic Apps).

How can we solve the “Dynamics 365 Business Central to SFTP” task by using Azure Logic Apps then?

The first part of the solution is described in yesterday’s post: you need to create an Azure Function for uploading a file from Dynamics 365 Business Central to an Azure Blob Storage container. Doing that, you can start creating a Logic App via the Azure Portal that uses the SFTP – SSH connector in order to download the uploaded file and transfer that file to the SFTP. This Logic App can be triggered automatically when a blob is added or modified in the Azure Blob Storage container.

To start creating the Logic App, go to the Azure Portal and create a new Logic App (here called SFTPBlobTransfer):

Then, in the Logic App Designer select Blank Logic App:

You can now create a trigger for your workflow. Select When a blob is added or modified (properties only) and then select the Azure Blob Storage container to monitor (here called d365bcfiles):

Then you need to add a trigger to get the blob content from the path of the container:

and then you need to add a new action to create a file by using the SFTP – SSH connector. Select the Create file action:

Now, as a first step you need to provide the SFTP details for the connection:

and then you can set up the Create file action by using the provided dynamic properties for the file name and the file content:

That’s all. Save the project and your Logic App is active and ready to be triggered. To test it, just upload or modify a file inside the container and your workflow will be triggered. You can monitor a running workflow directly in the portal:

More easy than yesterday’s solution isn’t it?

As a side note, Azure Logic Apps can be created and deployed also directly from Visual Studio.


This was originally posted here.

Comments

*This post is locked for comments