0

Below is my project Structure:

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

After I deployed to Azure Linux Function, I could not find a way to find index.html.

I tried below paths already:

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

Below is my coding for checking file:

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);
    }
}

1 Answer 1

0

Can use 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");
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.