Where to store files for Azure function?

前端 未结 1 1838
时光取名叫无心
时光取名叫无心 2021-02-15 13:12

I have files that I reference from inside by C# code such as:

public static string Canonical()
{
    return File.ReadAllText(@"C:\\\\myapp\\\\" + "         


        
1条回答
  •  余生分开走
    2021-02-15 13:34

    Yes, put the file at the root of Azure Function project and set its property Copy to Output Directory to Copy if newer. Use code below.

    public static async Task Run(HttpRequestMessage req, TraceWriter log, ExecutionContext context)
    {
        var data = File.ReadAllText(context.FunctionAppDirectory+"/CanonicalMessage.xml");
    
        //etc
    }
    

    Check the doc for more details.

    If we need to add this file from anywhere locally, right click on Function project, Edit .csproj. Add Item below, relative or absolute path are both ok.

    
      
        PreserveNewest
      
     
    

    0 讨论(0)
提交回复
热议问题