Avoid chained credential for local environment in sql package

This commit is contained in:
Sergio Matias 2025-06-22 01:28:14 -06:00
parent 7b326051bb
commit 73b909f780

View File

@ -17,6 +17,10 @@ namespace Core.Blueprint.SQLServer.Configuration
/// <param name="configuration">The application configuration object for accessing settings such as connection strings.</param>
/// <returns>An updated <see cref="IServiceCollection"/> with SQL Server services registered.</returns>
public static IServiceCollection AddSQLServer(this IServiceCollection services, IConfiguration configuration)
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
if (environment != "Local")
{
var chainedCredentials = new ChainedTokenCredential(
new ManagedIdentityCredential(),
@ -24,6 +28,7 @@ namespace Core.Blueprint.SQLServer.Configuration
new VisualStudioCredential(),
new VisualStudioCodeCredential()
);
}
services.AddScoped(typeof(IEntityRepository<,>), typeof(EntityRepository<,>));