I'm trying to add some custom binding using my app settings for my Azure Function. I need to receive only string a string from my settings.
I would like to get simpleValue from my settings.
{
"bindings": [
{
"name": "someValue",
"type": "stringSetting",
"connection": "simpleValue",
"direction": "in"
}
],
"disabled": false
}
and the get it in Run method:
static void GetOrders(TraceWriter log, string someValue)
{
log.Info(someValue);
}
Is it even possible. Maybe there is other way to do it?
To find the application settings, see Get started in the Azure portal. The Application settings tab maintains settings that are used by your function app. You must select Show values to see the values in the portal. To add a setting in the portal, select New application setting and add the new key-value pair.
In the upper-left corner of the home page, select Create a resource. In the Search services and marketplace box, enter App Configuration and select Enter. Select App Configuration from the search results, and then select Create. Select the Azure subscription that you want to use to test App Configuration.
In your project, open the local. settings. json file and set the value of the AzureWebJobsStorage key to the connection string you copied. Repeat the previous step to add unique keys to the Values array for any other connections required by your functions.
App Settings configurations can be referred in binding json as %MY_CUSTOM_CONFIG% - enclosed within percent symbols.
Note that the connection property of triggers and bindings is a special case and automatically resolves values as app settings, without percent signs. https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings
I already found the solution. Just add:
using System.Configuration;
and add this line to code with the key ("simpleValue") value:
ConfigurationManager.AppSettings["simpleValue"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With