In modern cloud-based solutions, there is often a need to automate file transfers between systems, especially to transfer files to an SFTP (Secure File Transfer Protocol) server. This is particularly important when integrating cloud services like Azure with external or on-premises systems. Azure Functions, a serverless compute service, provides a lightweight and scalable way to implement such file transfer operations.
If you missed previous parts of this series, you can check it out here, where we discussed “Create Function App on Azure Portal” and “Create C# function to use it in Azure function”.
Firstly, we will need a SFTP server for testing. For today, we will use the demo SFTP environment of “SFTPCloud”.
We can get access to the SFTP server using HOST, USERNAME, PASSWORD and SFTP PORT.
We will use FileZilla to access SFTP server and its files for testing.
Add above-mentioned SFTP server details and configured it in FileZilla. Also, create 2 Directory: “in” for adding files and “out” for reading files which are available in the out folder.
- Create Code unit in AL extension, to add file in SFTP through C# function we have created on Azure Function App. To get Function URL to use it as API, please go to Azure Portal > Function App > Select create Function > open C# function that we have published > click on GET FUNCTION URL > Copy URL to use it further.
- I have also created Page Action to execute the function.
- Once we will click on “Add File SFTP” action, it will pass Sales Order Number and Customer Name to the function created in code unit. The code will get executed through Azure function and it will create file in “in” folder of SFTP server.
- As we can see in the below snapshot, data has been fetched correctly.
Great job making it this far! In the final part of our series, we’ll cover how to read an XML file from an SFTP server using an Azure Function App and AL. Click here to proceed. If you haven’t read the previous parts, you can start from Part 1 by Clicking here or revisit Part 2 by Clicking here.If you’re curious about how we can assist you in reaching your goals, don’t hesitate to get in touch. Our dedicated team is ready to provide support every step of the way.Let’s turn your vision into reality together!