-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathShowMessage.cs
37 lines (32 loc) · 1.59 KB
/
ShowMessage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
using Microsoft.Extensions.Logging;
namespace FunctionAppInProcess
{
public class ShowMessage(IConfiguration configuration, IConfigurationRefresherProvider refresherProvider)
{
private readonly IConfiguration _configuration = configuration;
private readonly IConfigurationRefresher _configurationRefresher = refresherProvider.Refreshers.First();
[FunctionName("ShowMessage")]
public IActionResult Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
// Signal to refresh the configuration if the registered key(s) is modified.
// This will be a no-op if the refresh interval has not elapsed.
// The configuration is refreshed asynchronously without blocking the execution of the current function.
_ = _configurationRefresher.TryRefreshAsync();
// Read configuration data
string key = "TestApp:Settings:Message";
string message = _configuration[key];
return new OkObjectResult(message ?? $"Please create a key-value with the key '{key}' in Azure App Configuration.");
}
}
}