Azure WebJob FileTrigger Path 'D:\home\data\...' does not exist


I've created a WebJob to read files from Azure Files when they are created. When I run it locally it works but it doesn't when I publish the WebJob.

My Main() function is:

static void Main()
        string connection = "DefaultEndpointsProtocol=https;AccountName=MYACCOUNTNAME;AccountKey=MYACCOUNTKEY";

        JobHostConfiguration config = new JobHostConfiguration(connection);

        var filesConfig = new FilesConfiguration();
        if (config.IsDevelopment)
            filesConfig.RootPath = @"c:\temp\files";


        var host = new JobHost(config);
        // The following code ensures that the WebJob will be running continuously

The function to be triggered when the file is created is:

public void TriggerTest([FileTrigger(@"clients\{name}", "*.txt", WatcherChangeTypes.Created)] Stream file, string name, TextWriter log)
    log.WriteLine(name   " received!"); 
    // ...

And the error I get when the WebJob is published is:

[08/17/2016 00:15:31 > 4df213: ERR ] Unhandled Exception: System.InvalidOperationException: Path 'D:\home\data\clients' does not exist.

The ideia is to make the WebJob to trigger when new files are created in the "clients" folder of the Azure Files.

Can someone help me?


According to your requirement, I tested it on my side, then I reproduced your issue.

Unhandled Exception: System.InvalidOperationException: Path 'D:\home\data\clients' does not exist

When publish the WebJob, the FilesConfiguration.RootPath would be set to the “D:\HOME\DATA” directory when running in Azure Web App. You could refer to the source code:

As the following tutorial has mentioned, FilesConfiguration.RootPath should be set to a valid directory. Please check and make sure that the specified directory is existed in the Web APP which hosts in your WebJob.

Trigger when new files are created in the "clients" folder of the Azure Files via WebJob

As far as I know, there has two triggers for Azure Storage:

  • QueueTrigger - When an Azure Queue Message is enqueued.
  • BlobTrigger – When an Azure Blob is uploaded.

The new WebJobs SDK provide a File trigger which could trigger functions based on File events. However, a file trigger could monitor file additions/changes to a particular directory, but there seems to be no trigger for monitor file additons/changes on Azure File Storage.