0

I need to read from a JSON configuration file in Azure Function. Is there a way to refer to the file without hard-coding any paths(assuming it's in same directory as the code).

The solution in another answer was something like:

string configuration = string.IsNullOrEmpty(configurationFile) ? "" : File.ReadAllText(Environment.GetEnvironmentVariable("HOME") + @"\site\wwwroot\functionname\filename);

Is there a better way to get this path, or read JSON configuration in general for Azure Function?

Janusz Nowak
  • 2,595
  • 1
  • 17
  • 36
Shane
  • 369
  • 1
  • 2
  • 13

2 Answers2

1

Currently, the solution you found is the recommended approach, but with the next release, which is starting to roll out today (5/30/2017), we've introduced a feature to enhance this.

You can learn more about it here: https://github.com/Azure/azure-webjobs-sdk-script/wiki/Retrieving-information-about-the-currently-running-function

Fabio Cavalcante
  • 12,328
  • 3
  • 35
  • 43
  • The new runtime has been fully deployed and you can now follow the approach documented in the Wiki. Please let me know if this doesn't answer the question. – Fabio Cavalcante Jun 06 '17 at 03:38
0

you're able to find out some explanations about this same topic on this another thread, here.

I hope that this information help you.