I have created a Azure Function
, which is having a dependency on ini
file.
public class DataProcessingFunction
{
FunctionName("DataProcessingFunction")]
public async Task Run([EventGridTrigger]EventGridEvent eventGridEvent,ILogger log)
{
string iniFolderPath = $@"{Directory.GetCurrentDirectory()}\Ini\";
string iniFileName = "Sample.ini";
var iniConfig = FileManager.ReadFile(iniFolderPath, iniFileName);
}
}
I have selected Copy if never
option in Visual Studio while publishing the code to Azure function
Also, I have tried selecting Embedded Resource
. But I am not able to find the file
I get an exception
File not found.
Add/Upload option in Azure portal is disabled because I am publishing the function from Visual studio
Question: Do I need to upload file to blob and then refer it in a code?
Here is the way to do it.
ExecutionContext context;
// You can modify your function method to take an additional parameter of type ExecutionContext
public static async Task Run(<.... Other parameters>, ILogger log, ExecutionContext context)
Then build the path by combining function directory, "templates" is the directory I have in the function app project which is deployed along with other code, emails.html is file within templates (For each of these files you have to set, copy-always or copy-if-newer in the properties.). Instead of templates you can have your .ini file.
string templatePath = Path.Combine(context.FunctionAppDirectory, "Templates", "emails.html");