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> /// <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> /// <returns>An updated <see cref="IServiceCollection"/> with SQL Server services registered.</returns>
public static IServiceCollection AddSQLServer(this IServiceCollection services, IConfiguration configuration) public static IServiceCollection AddSQLServer(this IServiceCollection services, IConfiguration configuration)
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
if (environment != "Local")
{ {
var chainedCredentials = new ChainedTokenCredential( var chainedCredentials = new ChainedTokenCredential(
new ManagedIdentityCredential(), new ManagedIdentityCredential(),
@ -24,6 +28,7 @@ namespace Core.Blueprint.SQLServer.Configuration
new VisualStudioCredential(), new VisualStudioCredential(),
new VisualStudioCodeCredential() new VisualStudioCodeCredential()
); );
}
services.AddScoped(typeof(IEntityRepository<,>), typeof(EntityRepository<,>)); services.AddScoped(typeof(IEntityRepository<,>), typeof(EntityRepository<,>));