Azure WebJob FileTrigger路径'D:\ home \ data \ ...'不存在 [英] Azure WebJob FileTrigger Path 'D:\home\data\...' does not exist

查看:78
本文介绍了Azure WebJob FileTrigger路径'D:\ home \ data \ ...'不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个WebJob,以便在创建Azure文件时读取它们. 当我在本地运行它时,它可以工作,但发布WebJob时却不能.

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.

我的Main()函数是:

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)
        {
            config.UseDevelopmentSettings();
            filesConfig.RootPath = @"c:\temp\files";
        }

        config.UseFiles(filesConfig);

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

创建文件时要触发的功能是:

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!"); 
    // ...
}

发布WebJob时出现的错误是:

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.

当在Azure文件的客户端"文件夹中创建新文件时,想法是使WebJob触发.

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

有人可以帮助我吗?

推荐答案

根据您的要求,我在我这边进行了测试,然后转载了您的问题.

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

未处理的异常:System.InvalidOperationException:路径'D:\ home \ data \ clients'不存在

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

发布WebJob时,在Azure Web App中运行时,FilesConfiguration.RootPath将设置为"D:\ HOME \ DATA"目录.您可以参考源代码: https ://github.com/Azure/azure-webjobs-sdk-extensions/blob/master/src/WebJobs.Extensions/Extensions/Files/Config/FilesConfiguration.cs

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: https://github.com/Azure/azure-webjobs-sdk-extensions/blob/master/src/WebJobs.Extensions/Extensions/Files/Config/FilesConfiguration.cs

正如下面的教程所提到的,应该将FilesConfiguration.RootPath设置为有效目录. https://azure.microsoft.com/zh-CN/blog/extensible-triggers-and-binders-with-azure-webjobs-sdk-1-1-0-alpha1 请检查并确保在WebJob中托管的Web APP中存在指定的目录.

As the following tutorial has mentioned, FilesConfiguration.RootPath should be set to a valid directory. https://azure.microsoft.com/en-us/blog/extensible-triggers-and-binders-with-azure-webjobs-sdk-1-1-0-alpha1 Please check and make sure that the specified directory is existed in the Web APP which hosts in your WebJob.

通过WebJob在Azure文件的客户端"文件夹中创建新文件时触发

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

据我所知,Azure存储有两个触发器:

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

  • QueueTrigger-排队Azure队列消息时.
  • BlobTrigger –上传Azure Blob时.

新的WebJobs SDK提供了一个File触发器,该触发器可以基于File事件触发功能. 但是,文件触发器可以监视对特定目录的文件添加/更改,但是似乎没有触发器可以监视Azure文件存储上的文件添加/更改.

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.

这篇关于Azure WebJob FileTrigger路径'D:\ home \ data \ ...'不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆