First, you need to add the html file to your project, and in the properties, set Copy to Output Directory to "Copy if newer".
Then in your function code, take in an additional ExecutionContext context
parameter (note that this is Microsoft.Azure.WebJobs.ExecutionContext
and not System.Threading.ExecutionContext
). And when you need to access your html file, you can then write:
string htmlFilePath = Path.Combine(context.FunctionAppDirectory, "test.html");
That's assuming you added the file at the root of your VS project. If you instead added it in some Data
folder (better practice), you'd write:
string htmlFilePath = Path.Combine(context.FunctionAppDirectory, "Data", "test.html");
See here for full working sample.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…