I am trying to read the eventhubname and connection string from Azure App Configuration, NOT function app settings, but I cannot get this to work, if I real from the function app itself it works fine but I need to read from App Configuration centralized configuration store.
Here is my small function so far
public class CDSSoftDelete
{
static string _eventHubname = null;
string _connectionString;
private readonly IConfiguration _config;
public CDSSoftDelete(IConfiguration config, IConfigurationRefresher configurationRefresher)
{
if (config == null) throw new ArgumentNullException(nameof(config));
if (configurationRefresher == null) throw new ArgumentNullException(nameof(configurationRefresher));
configurationRefresher.TryRefreshAsync();
_config = config;
_eventHubname = config["SLQueueManager:Settings:EventHubName"];
_connectionString = config["SLQueueManager:Settings:EventHubConnectionString"];
}
[FunctionName("CDSSoftDelete")]
public async Task Run([EventHubTrigger(_config["SLQueueManager:Settings:EventHubName"], Connection = _connectionString)] EventData[] events, ILogger log)
{
}
}
But this does not work because the _config variable does not have an object reference, so its a bit of a catch 22
How can I read those config settings correctly ?
Here is an example of how to get queue name from Azure App Configuration and use it for QueueTrigger. You should be able to do something similar for EventHubTrigger. It uses app setting binding expression. Please note that this is not supported in the consumption plan due to limitations in Azure Functions.