I'm new to minimal api net7 .I want to log the application insights when any exception raise and read the configuration from app.settings.json in another common library. here i'm using the concept of endpoints to segregate the minimal api net7.
here is the example
public class RegisterEndpoint : IEndpoint
{
public void RegisterEndpoints(WebApplication app)
{
var apiRoute = app.MapGroup("api/register");
apiRoute.MapGet("user", User user, IRegisterService _regService) =>
{
//check user exists or not
if(!isUserExists)
{
// register the user in this methos if any exception
//raise log into application insights and if any configuration is required need to send
// how to do that ?
// need to send as a parameter app.logger and builder.configuration to every method
}
});
}
}
Register service is in another common class library and want to log the application insights and read configuration from app.settings.json. Please suggest me best approach to do.
Thanks everyone in advance!