0

以下是我的项目结构:

ProjectX
- www (folder)
- - index.html (target file that want to access)
- MyFunc.cs (Function)
- local.settings.json

部署到 Azure Linux Function 后,我找不到找到index.html.

我已经尝试过以下路径:

  1. /home/site/wwwroot/
  2. /home/site/wwwroot/MyFunc/
  3. /家/网站/
  4. /home/site/wwwroot/bin/
  5. /home/site/wwwroot/bin/runtimes

以下是我检查文件的编码:

public static async Task Run([ServiceBusTrigger(ServiceBusContext.MyQueueName, Connection = "ServiceBus")] Message msg, ILogger log)
{
    // change to different paths
    var testDir1 = new DirectoryInfo($@"/home/site/wwwroot/");
    FindFileInfo(testDir1, log);
}

public static void FindFileInfo(DirectoryInfo dir, ILogger log)
{
    FileInfo[] files = dir.GetFiles();
    foreach (FileInfo file in files)
    {
        log.LogInformation("Check File, RootDir=" + dir.FullName + ", File: {0}", file.Name);
    }
}
4

1 回答 1

0

可以使用context.FunctionAppDirectory

public static async Task Run([ServiceBusTrigger(ServiceBusContext.MyQueueName, Connection =
"ServiceBus")] Message msg, ILogger log, ExecutionContext context)
{
    var path = Path.Combine(context.FunctionAppDirectory, "www", "index.html");
}
于 2021-06-10T03:38:07.420 回答