Closed JFulfordMS closed 3 months ago
@JFulfordMS, can you provide more info like which of our packages you are using and what the version info is.
@JFulfordMS, can you provide more info like which of our packages you are using and what the version info is.
I'm using Azure.Data.AppConfiguration 1.4.1 and AzureAppConfiguration 7.2.0.
@JFulfordMS please follow the document below for using App Configuration in Azure Functions.
@JFulfordMS
To help me make sure I understand what you're talking about, can you tell/show me how you get the Function to use a schedule defined in App Configuration?
Sure, here is a way to test it. I set the parameter of "CdataHelper:Schedule" in an app configuration store to "*/30 ". Then reference it in the TimerTrigger constructor. The function changes the value of the parameter to "/5 * " and successfully gets the updated value on the next run, but the timer still only runs every 30 seconds.
`
private readonly IConfiguration _configuration;
private readonly IConfigurationRefresher _configurationRefresher;
private readonly ConfigurationClient configurationClient;
public CdataJobFunctions(IConfiguration configuration, IConfigurationRefresherProvider refresherProvider)
{
_configuration = configuration;
_configurationRefresher = refresherProvider.Refreshers.First();
configurationClient = new ConfigurationClient(Environment.GetEnvironmentVariable("ConfigConnectionString"));
}
static HttpClient httpClient = new HttpClient();
[FunctionName("DoUpdate")]
public async Task Run([TimerTrigger("%CdataHelper:Schedule%")] TimerInfo myTimer, ILogger log)
{
log.LogInformation($"Running at: {DateTime.Now}");
log.LogInformation(_configuration["CdataHelper:Schedule"]);
var setting = configurationClient.SetConfigurationSetting("CdataHelper:Schedule", "*/5 * * * * *");
await _configurationRefresher.TryRefreshAsync();
}
`
[2024-06-03T12:10:30.006Z] Executing 'DoUpdate' (Reason='Timer fired at 2024-06-03T08:10:30.0052795-04:00', Id=84a6331c-e7c1-46f0-8ac5-e872ac43b9cc) [2024-06-03T12:10:30.008Z] Running at: 6/3/2024 8:10:30 AM [2024-06-03T12:10:30.008Z] /30 [2024-06-03T12:10:30.595Z] Executed 'DoUpdate' (Succeeded, Id=84a6331c-e7c1-46f0-8ac5-e872ac43b9cc, Duration=590ms) [2024-06-03T12:11:00.010Z] Executing 'DoUpdate' (Reason='Timer fired at 2024-06-03T08:11:00.0094870-04:00', Id=9015ccad-a249-41f3-b1e1-cdb49d616c2d) [2024-06-03T12:11:00.014Z] Running at: 6/3/2024 8:11:00 AM [2024-06-03T12:11:00.015Z] /5 [2024-06-03T12:11:00.178Z] Executed 'DoUpdate' (Succeeded, Id=9015ccad-a249-41f3-b1e1-cdb49d616c2d, Duration=168ms) [2024-06-03T12:11:30.011Z] Running at: 6/3/2024 8:11:30 AM [2024-06-03T12:11:30.012Z] /5 [2024-06-03T12:11:30.500Z] Executed 'DoUpdate' (Succeeded, Id=39db3973-6db1-490c-99de-3381840462a1, Duration=491ms)
The trigger uses the app setting binding expression of the Azure Functions. While your code can pick up the latest value in App Configuration, I suspect Azure Functions won't pick up the new setting without the function app being restarted (just like how app setting works in Azure Functions).
Closing. Please reopen it if there are further questions.
Curious if this is a pending feature or a bug but a Timer Trigger referencing a schedule from an App Configuration store doesn't get refreshed values and continues to run at the initial schedule when the function last started. I've validated that the function itself is successfully refreshing the values.