I have created an HTTP Function in VSCode using C# net6.0, and all I want to do is read from a local json file and give me a result. Using context.FunctionDirectory
leads me to ...\bin\Debug\net6.0\...
. In older .net stuff, I would expect to copy the file to the output directory as an artifact, but I'm coming up lacking on how to do that in .net 6.0 in an Azure Function. My poor Google skills have only led me down the path of adding a configuration file, but that's not exactly what I'm looking for. Is there an easy way to copy this file to the Function Directory so I can retrieve it during execution? Also, I've only run this locally, so I'm hoping whatever solution I find will also work when I push this up to Azure.
Asked
Active
Viewed 1,593 times
0

Brendan McMahon
- 13
- 1
- 4
-
have you tried using the [IWebHostEnvironment](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/web-host?view=aspnetcore-6.0#iwebhostenvironment-interface)? – Andy Sep 08 '22 at 01:57
-
See [Including a file when I publish my Azure function in Visual Studio](https://stackoverflow.com/a/70691516/5436889) – Mo Nazemi Sep 08 '22 at 02:29
1 Answers
0
ExecutionContext
parameter provides the FunctionDirectory
in .NET 6.
Is there an easy way to copy this file to the Function Directory so I can retrieve it during execution?
This is one of the ways to access the information from the code while it is in execution/running:
.NET 6 Azure Function
Refer to the GitHub Azure Functions Host article on using the FunctionAppDirectory
on the function which is in running/executing state.