Ends in:
7 DAYS
14 HRS
19 MIN
28 SEC
Ends in:
7 D
14 H
19 M
28 S
Open Closed

Default settings applied on appsettings.json is not propagating when deployed as an ECS Task #8275


User avatar
0
Bryan-EDV created

I understand that we can change certain settings in the appsetings.json. This applies the default settings to the host and tenant level.

  "Settings": {
    "Abp.Identity.User.IsUserNameUpdateEnabled": false,
    "Abp.Identity.User.IsEmailUpdateEnabled": false,
    "Abp.Account.IsSelfRegistrationEnabled": false
  },

When testing locally using dotnet run or using a docker container, these settings work fine. I can see that the values in the settings page are updated correctly

However they are not applied when we deploy this to ECS (ABP backend is running in an ECS Task)

I've even tried to update using environment variables. But it doesn't work either

Could you outline any possible reason for this? I've checked that those settings are not overwritten in the DB


7 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    you can override SettingProvider and SettingManagement to log the setting value from where and check it log.

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(ISettingProvider))]
    public class MySettingProvider : SettingProvider
    {
        private readonly ILogger<MySettingManagement> _logger;
        public MySettingProvider([NotNull] ISettingDefinitionManager settingDefinitionManager, [NotNull] ISettingEncryptionService settingEncryptionService, [NotNull] ISettingValueProviderManager settingValueProviderManager, ILogger<MySettingManagement> logger) : base(settingDefinitionManager, settingEncryptionService, settingValueProviderManager)
        {
            _logger = logger;
        }
    
        protected async override Task<string> GetOrNullValueFromProvidersAsync(IEnumerable<ISettingValueProvider> providers, SettingDefinition setting)
        {
            foreach (var provider in providers)
            {
                var value = await provider.GetOrNullAsync(setting);
                _logger.LogInformation($"Get value from SettingProvider: {provider.Name}, Value: {value}");
                if (value != null)
                {
                    return value;
                }
            }
    
            return null;
        }
    }
    
    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(ISettingManager))]
    public class MySettingManagement : SettingManager
    {
        private readonly ILogger<MySettingManagement> _logger;
        public MySettingManagement(IOptions<SettingManagementOptions> options, IServiceProvider serviceProvider, ISettingDefinitionManager settingDefinitionManager, ISettingEncryptionService settingEncryptionService, ISettingManagementStore settingManagementStore, ILogger<MySettingManagement> logger) : base(options, serviceProvider, settingDefinitionManager, settingEncryptionService, settingManagementStore)
        {
            _logger = logger;
        }
    
        protected async override Task<string> GetOrNullInternalAsync(string name, string providerName, string providerKey, bool fallback = true)
        {
            var setting = await SettingDefinitionManager.GetAsync(name);
            var providers = Enumerable
                .Reverse(Providers);
    
            if (providerName != null)
            {
                providers = providers.SkipWhile(c => c.Name != providerName);
            }
    
            if (!fallback || !setting.IsInherited)
            {
                providers = providers.TakeWhile(c => c.Name == providerName);
            }
    
            string value = null;
            foreach (var provider in providers)
            {
                value = await provider.GetOrNullAsync(
                    setting,
                    provider.Name == providerName ? providerKey : null
                );
    
                _logger.LogInformation($"Get value from SettingProvider: {provider.Name}, Value: {value}");
                if (value != null)
                {
                    break;
                }
            }
    
            if (setting.IsEncrypted)
            {
                value = SettingEncryptionService.Decrypt(setting, value);
            }
    
            return value;
        }
    }
    
  • User Avatar
    0
    Bryan-EDV created

    Will post the results here soon

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    okay

  • User Avatar
    0
    Bryan-EDV created

    Hi managed to get it resolved. We realised that as part of our CI/CD pipeline, we were running dotnet publish "MyApp.sln"

    During the creation of artifacts, the last project to be published is NOT the HttpApi.Host project. Hence, appsettings.json for HttpApi.Host was overwritten by another project appsettings.json.

    The resolution was to only publish the needed artifact i.e. dotnet publish "MyApp.HttpApi.Host/MyApp.HttpApi.Host.csproj"

    Note: the commands are not exactly as used in our project but conveys the idea (we also added flags such as -c Release etc)

  • User Avatar
    0
    Bryan-EDV created

    Also, do you happen to know the change you made in this ticket: https://abp.io/qa/questions/7297/3a130461-8b69-1a8a-743f-133fccbac906

    We are having the exact same issue whereby the issuer still defaults to the main domain of the backend (api.mydomain.com) instead of the subdomain (tenant.api.mydomain.com).

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It's a new question.

    I think we close this. : )

  • User Avatar
    0
    Bryan-EDV created

    thanks,

    fyi managed to solve new question issue by removing serverBuilder.SetIssuer(new Uri(configuration["AuthServer:Authority"]!));

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06