Avoid chained credential for local environment in sql package

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

View File

@@ -18,12 +18,17 @@ namespace Core.Blueprint.SQLServer.Configuration
/// <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 chainedCredentials = new ChainedTokenCredential( var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
if (environment != "Local")
{
var chainedCredentials = new ChainedTokenCredential(
new ManagedIdentityCredential(), new ManagedIdentityCredential(),
new SharedTokenCacheCredential(), new SharedTokenCacheCredential(),
new VisualStudioCredential(), new VisualStudioCredential(),
new VisualStudioCodeCredential() new VisualStudioCodeCredential()
); );
}
services.AddScoped(typeof(IEntityRepository<,>), typeof(EntityRepository<,>)); services.AddScoped(typeof(IEntityRepository<,>), typeof(EntityRepository<,>));