2017-05-03 64 views
0

我正在尝试使索引MP4文件的Azure函数。我正在寻找一种方法来读取索引器所需的配置文件。我已经制作了一个控制台应用程序,它正在从我的硬盘读取配置文件,这是完美的。但是,如何读取Azure函数中的文件?阅读配置文件索引azure函数中的作业

例如:

EncodeFile(asset, @"e:\index.xml"); 

public static IAsset EncodeFile(IAsset asset, string configurationFile) 
{ 
    IJob job = _context.Jobs.Create("Media Encoder Standard Job"); 

    string MediaProcessorName = "Azure Media Indexer"; 
    IMediaProcessor processor = GetLatestMediaProcessorByName(MediaProcessorName); 

    string configuration = string.IsNullOrEmpty(configurationFile) ? "" : File.ReadAllText(**configurationFile**); 

    ITask task = job.Tasks.AddNew("My encoding task", 
     processor, 
     **configuration**, 
     TaskOptions.None); 

回答

0

但是我怎么看蔚蓝的功能中的一个文件?

我们可以将文件放在Azure功能站点下。

对于Azure函数App,如果我们创建了一个函数,那么它将在带有函数名称的WebApp上创建一个文件夹。如果我们想读取文件,我们可以将文件放到Azure kudu toolhttps://yourfunctionsite.scm.azurewebsites.net)的文件夹中。访问Azure Web应用程序D:\ home。我们可以从Azure WebApp Sandbox获得更多详细信息。

每个Azure Web应用程序都有一个由Azure存储存储/支持的主目录。这个网络共享是应用程序存储其内容的地方。该目录可用于具有读/写访问权限的沙箱。

enter image description here

在你的情况下,代码可改为:

string configuration = string.IsNullOrEmpty(configurationFile) ? "" : File.ReadAllText(Environment.GetEnvironmentVariable("HOME") + @"\site\wwwroot\functionname\filename); 

我也做一个测试吧。它在我身边正常工作。

enter image description here