How to add an appsettings.json file to my Azure Function 3.0 configuration?

后端 未结 6 675
轻奢々
轻奢々 2021-01-18 02:52

The new Azure Function 3.0 SDK provides a way to implement a Startup class. It gives access to the collection of services that are available by dependency injection, where I

6条回答
  •  佛祖请我去吃肉
    2021-01-18 03:33

    In the startup class:

        IConfigurationRoot config = new ConfigurationBuilder()
                  .SetBasePath(Environment.CurrentDirectory)
                  .AddJsonFile("someSettings.json", optional: true, reloadOnChange: true)
                  .AddEnvironmentVariables()
                  .Build();
    

    Add a json file to you project that holds the settings. Note that local.settings.json is ignored/removed during deployment. (Name the file something else.)

提交回复
热议问题