0

I have a webjob that I have set up to be triggered when a file is added to a directory:

[FileTrigger(@"<DIR>\<dir>\{name}", "*", WatcherChangeTypes.Created, autoDelete: true)] Stream file,

I have it configured:

var config = new JobHostConfiguration
                {
                    JobActivator = new NinjectActivator(kernel)
                };
                var filesConfig = new FilesConfiguration();
#if DEBUG
                filesConfig.RootPath = @"C:\Temp\";
#endif
                config.UseFiles(filesConfig);
                config.UseCore();

The path is for working locally and I was expecting that commenting out the FilesConfiguration object leaving it default would allow it to pick up the connection string I have set up and trigger when files are added. This does not happen it turns out that by default the RootPath is set to "D:\Home" and produces an InvalidOperationException

System.InvalidOperationException : Path 'D:\home\data\<DIR>\<dir>' does not exist.

How do I get the trigger to point at the File storage area of the storage account I have set up for it. I have tried removing the FilesConfiguration completely from Program.cs in the hope that it would work against the settings but it only produces the same Exception.

onesixtyfourth
  • 744
  • 9
  • 30

1 Answers1

0

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

When you publish to azure, the default directory is D:\HOME\DATA, so when you run webjob it could not find the path so you get the error message.

How do I get the trigger to point at the File storage area of the storage account I have set up for it.

The connectionstring you have set have two applies: one is used for dashboard logging and the other is used for application functionality (queues, tables, blobs).

It seems that you could not get filetrigger working with azure file storage. So, if you want to invoke your filetrigger when you create new file, you could go to D:\home\data\ in KUDU to create a DIR folder and then create new .txt file in it.

The output is as below:

enter image description here

BTW, it seems that you'd better not use autoDelete when you create file, if use you will get error like:

NotSupportedException: Use of AutoDelete is not supported when using change type 'Changed'.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30
  • Yes and this is exactly what I am doing but I was hoping I could get it to trigger from File storage. Will keep an eye on autodelete. Can I mount a directory in the D:\Data\Home hierarchy on my local machine? – onesixtyfourth Jul 10 '18 at 09:06
  • And the FileTrigger here could [monitor file additions/changes to a particular directory](https://stackoverflow.com/questions/38986420/azure-webjob-filetrigger-path-d-home-data-does-not-exist), but there seems to be [no trigger for monitor file additons/changes on Azure File Storage](https://feedback.azure.com/forums/287593-logic-apps/suggestions/20324680-add-trigger-for-azure-file-storage). – Joey Cai Jul 10 '18 at 09:19
  • Just to update on this I ended up going with a Blob and BlobTrigger to achieve what we needed. – onesixtyfourth Jul 13 '18 at 06:50
  • Glad to see you have solve you problem. As I have said, you could use queue, blob trigger to achieve it. – Joey Cai Jul 13 '18 at 07:17