Azure Functions : Application settings from Azure
Values hard coded to an application is the brightest “DO NOT” thing in software development. But how to bring your Azure Function more professional level?
Start using application settings
You can define key value pairs on the Microsoft Azure portal for your Function app. Go to your app and find the Settings section, and click on the configuration button.
You can add your keys and values by clicking the New application setting button.
Application Settings are exposed as environment variables for access by your application at runtime. Learn more
Access your settings from your code
You can access your newly created setting from C# using the GetEnvironmentVariable call.
System.Environment.GetEnvironmentVariable("yourvariablename");
What about local debugging?
You do not need to add and modify the environment variables in your operating system. Add a new json file to your solution called ‘local.settings.json’, and fill it up with some data like below:
{
"IsEncrypted": false,
"Values": {
"yourvariablename": "fanncyyy!"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*",
"CORSCredentials": false
},
"ConnectionStrings": {
"SecretSQL": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}
Tags In
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Hi, I am András,
I am a seasoned software engineer from Budapest, Hungary with a strong focus on mobile app development using .NET MAUI and Xamarin.Forms. My expertise also extends to website building for my happy customers and other complex system designing. I am passionate about developing well-organized, maintainable software solutions.