My azure function does not trigger when WinSCP send a file with sftp

Tony Johansson 40 Reputation points
2023-05-26T12:28:28.0166667+00:00

Hello,

I have an azure function that is defined to use blob trigger and this works perfect when I upload a file from portal. As you can see in the signature the azure function should only trigger for xml file
The account I use is defined like this
Performance : Standard
Replication : Locally-redundant storage (LRS)
Account kind : SorageV2 (general prpose v2)

The azure function is defined signature is defined like this

public void Run(
            [BlobTrigger("input-xml/{name}.xml")] Stream inputBlob, IBinder binder, string name, ILogger log)
        {

The function is written in C#.NET
The problem occur when a customer send an xml file using WinSCP with sftp. The azure function does not react at all when the file is written in the container input-xml.
To be able to make my azure function to read the xml file I can restart the azure function. I can't understand the difference between drop a file by upload or use WinSCP with sftp. I mean as soon as an xml file is being located in the container input-xml the azure function should start to run. Target framework I use is .NET 5.0

Thanks in advance
Tony Johansson
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. VasimTamboli 5,215 Reputation points
    2023-05-30T14:54:50.8666667+00:00

    It appears that there are some differences in the way blob events are triggered when using SFTP compared to other methods like uploading files through the portal. To troubleshoot this issue, you can try the following steps:

    Enable Storage Diagnostic logs: Enable diagnostic logging for your storage account to capture detailed information about the blob events. This will help you verify if the blob receipts are received properly when files are uploaded via SFTP. You can refer to the Azure documentation on enabling diagnostic logs for Azure Storage.

    Validate SFTP blob receipts: Check the diagnostic logs to ensure that the blob events are being captured and received properly when files are uploaded via SFTP. Verify if the events are triggering the Azure Function as expected. This will help identify if the issue lies in the event triggering mechanism.

    Consider using EventGrid: Instead of relying solely on the blob trigger, you can set up an EventGrid subscription for the storage account and filter specifically for the SftpCommit event. This ensures that your Azure Function is triggered reliably when an SFTP file is committed to the container. You can refer to the Azure documentation on triggering Azure Functions on blob containers using an event subscription for more information.

    By following these steps, you should be able to gather more information about the events triggered by SFTP uploads and ensure that your Azure Function is properly triggered when files are uploaded via WinSCP with SFTP.


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.