Usage of config files are important to when we have generic variables,parameters and environment values to store and call them in the source code. In Azure functions also we can maintain the configuration parameters when we write them from Cloud. In this blog I am going to show how we can use configuration parameters in Azure Function in cloud.
Steps:
1.Create an azure function and go to platform features.
2.Select Configuration from platform features:
3.Select "Application Settings" and click on "New Application String"
4.Enter configuration parameter name and values:
Here the parameter name is "testvalue" and is value is "sample"
5. Now use them in the code:
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
You are good to go now!!!
Similarly you can access the KeyVault values in config file and source codes.
Steps:
1.Create an azure function and go to platform features.
2.Select Configuration from platform features:
3.Select "Application Settings" and click on "New Application String"
4.Enter configuration parameter name and values:
Here the parameter name is "testvalue" and is value is "sample"
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
Magic Line:
Private static string superSecret=System.Environment.GetEnvironmentVariable("testvalue");
Private static string superSecret=System.Environment.GetEnvironmentVariable("testvalue");
You are good to go now!!!
Similarly you can access the KeyVault values in config file and source codes.
ReplyDeleteThank you for bringing this blog to my attention. This blog provides information that is very useful to me.
WeShape is an Azure DevOps consulting company that helps organizations optimize their software development processes and improve collaboration among teams.
Thank you!
Delete