MatheusNani Thank you for posting your question in Microsoft Q&A. Based on my understanding, you are referring to code snippet in doc: Connect to an App Configuration store and added AddAzureAppConfiguration
in ConfigureAppConfiguration
section.
However, you need to add AddAzureAppConfiguration
to ConfigureServices
so that this service is available through dependency injection. I assume, you are reading AppConfiguration values in your function code and here is the full code sample for your reference.
Reference snippet for reading AppConfiguration: (https://github.com/Azure/AppConfiguration/blob/main/examples/DotNetCore/AzureFunction/FunctionAppIsolatedMode/ShowMessage.cs)
public class ShowMessage
{
private readonly IConfiguration _configuration;
private readonly ILogger _logger;
public ShowMessage(IConfiguration configuration, ILoggerFactory loggerFactory)
{
_configuration = configuration;
_logger = loggerFactory.CreateLogger<ShowMessage>();
}
[Function("ShowMessage")]
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");
var response = req.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
// Read configuration data
string key = "TestApp:Settings:Message";
string message = _configuration[key];
response.WriteString(message ?? $"Please create a key-value with the key '{key}' in Azure App Configuration.");
return response;
}
}
If you face any issues following the code sample, share the full code snippet of how you read values in your function code. For second part, you are actually reading app settings of AZURE_FUNCTIONS_ENVIRONMENT
and it returns as expected (doc reference: AZURE_FUNCTIONS_ENVIRONMENT).
I hope this helps with your question and let me know for any other questions.