Azure Webjob - accessing local file system

余生长醉 提交于 2019-12-22 05:14:51

问题


I have a legacy exe which takes local machine file path, processes it and produces output file in again the local path. Can this be run on Azure Webjob?

I was thinking to write a wrapper exe which downloads file from blob storage -> store it in local file system -> call the legacy exe with local file path -> get the output and upload it to the blob again.

Will this approach work or there are limitations?


回答1:


Such exe should run fine, as long as you get to pass it the folders to write from/to. Before getting into WebJobs, I suggest testing it manually in a Web App using Kudu Console, to make sure it runs fine.

Then if your goal is to have it work with blob input/output, the wrapper exe should work. Obviously, it'd be cleaner to have it directly work with blog streams, but if the legacy exe is a given and can't be changed, the wrapper approach should be fine.




回答2:


If you end up writing a wrapper, then the Files binding extension for the WebJobs SDK might be of interest to you: https://github.com/Azure/azure-webjobs-sdk-extensions. For example:

    // When new files arrive in the "import" directory, they
    // are uploaded to a blob container then deleted.
    public static void ImportFile(
        [FileTrigger(@"import\{name}", "*.dat", autoDelete: true)] Stream file,
        [Blob(@"processed/{name}")] CloudBlockBlob output,
        string name,
        TextWriter log)
    {
        output.UploadFromStream(file);
        file.Close();

        log.WriteLine(string.Format("Processed input file '{0}'!", name));
    }


来源:https://stackoverflow.com/questions/32942056/azure-webjob-accessing-local-file-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!