How to add configuration values in AppSettings.json in Azure functions. Is there any structure for it?

后端 未结 7 1981
别那么骄傲
别那么骄傲 2021-02-12 18:51

What is the standard structure to add keys to appsettings.json? Also, how to read those values in our run.csx? Normally in app.config, we had Con

7条回答
  •  闹比i
    闹比i (楼主)
    2021-02-12 19:36

    Here's how you can set it up:

    Step 1

    Add your json at the root of your repo, example app.settings.json

    Step 2

    Add the Diretory.Build.targets (.targets is the extension here) file as follows

    
      
        <_IsFunctionsSdkBuild Condition="$(_FunctionsTaskFramework) != ''">true
        <_FunctionsExtensionsDir>$(TargetDir)
        <_FunctionsExtensionsDir Condition="$(_IsFunctionsSdkBuild) == 'true'">$(_FunctionsExtensionsDir)bin
      
    
      
        
    
        
      
    
      
        
    
        
      
    
    
    

    This will explicitly tell the compiler to include the app.settings.json file when dotnet build is ran and will include said file in a the /bin, allowing your dll's to access it.

    Happy coding.

提交回复
热议问题