Differences
This shows you the differences between the selected revisions of the page.
guide_microsoft_azure_function_sftp 2019-11-19 | guide_microsoft_azure_function_sftp 2022-11-14 (current) | ||
Line 1: | Line 1: | ||
====== SFTP/FTPS file transfers in Microsoft Azure Function ====== | ====== SFTP/FTPS file transfers in Microsoft Azure Function ====== | ||
- | To use [[library|WinSCP .NET assembly]] to implement an SFTP/FTP functionality in [[https://docs.microsoft.com/en-us/azure/azure-functions/|Microsoft Azure Function]], just add [[library_install#nuget|WinSCP NuGet package]] to your Azure Functions project in Visual Studio and then use any [[library_examples|standard WinSCP code]]. | + | To use [[library|WinSCP .NET assembly]] to implement an SFTP/FTP functionality in [[https://learn.microsoft.com/en-us/azure/azure-functions/|Microsoft Azure Function]], just add [[library_install#nuget|WinSCP NuGet package]] to your Azure Functions project in Visual Studio and then use any [[library_examples|standard WinSCP code]]. |
The only problem you will face is, that for some reason, when publishing the project to an Azure storage, ''winscp.exe'' dependency is stored to the root folder of the function, instead of the ''bin'' subfolder along with other binaries (particularly the ''WinSCPnet.dll''). | The only problem you will face is, that for some reason, when publishing the project to an Azure storage, ''winscp.exe'' dependency is stored to the root folder of the function, instead of the ''bin'' subfolder along with other binaries (particularly the ''WinSCPnet.dll''). | ||
- | To overcome that, you need to use [[library_session#executablepath|''Session.ExecutablePath'']] to point to the actual location of ''winscp.exe''. You can use ''ExecutionContext.FunctionAppDirectory'' to refer to the root folder of the function. To get an instance of the [[https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#executioncontext|''ExecutionContext'']], add new parameter to the signature of [[https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#methods-recognized-as-functions|your entry method]] (usually ''Run''). | + | To overcome that, you need to use [[library_session#executablepath|''Session.ExecutablePath'']] to point to the actual location of ''winscp.exe''. You can use ''ExecutionContext.FunctionAppDirectory'' to refer to the root folder of the function. To get an instance of the [[https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#executioncontext|''ExecutionContext'']], add new parameter to the signature of [[https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#methods-recognized-as-functions|your entry method]] (usually ''Run''). |
The following example is for version 2.x of Azure Functions: | The following example is for version 2.x of Azure Functions: | ||
Line 40: | Line 40: | ||
</code> | </code> | ||
- | For version 1.x of Azure functions, the code is basically the same. Just for logging, you need to use ''TraceWriter'' instead of ''ILogger''. Read about [[https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions#migrating-a-locally-developed-application|Migrating from 1.x to later versions]]. | + | For version 1.x of Azure functions, the code is basically the same. Just for logging, you need to use ''TraceWriter'' instead of ''ILogger''. Read about [[https://learn.microsoft.com/en-us/azure/azure-functions/migrate-version-1-version-4|Migrating from version 1.x]]. |