Open Closed

Please stop using periods (".") in setting names #557


User avatar
1
rachanee-mwp created

We are having problem overrriding settings in live environments because setting names with periods (".") are not supported (by Auzre App Service Configuration, Key Vault and CD pipeline task to transform appsetting.json). So, please cosider changing to use other delimiter like underscore ("_") please.


5 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    if there's a document that you can show this issue (that Azure doesn't accept dots in setting name)

  • User Avatar
    0
    rachanee-mwp created

    1. Key Vault We put some credentials in Azure Key Vault and integrate with settings in the appsettting.json. The secret names are set in following pattern for hirachycal settings. Unfortunately, they do not support setting name with periods (".").

    2. Azure App Service Configuration Normally, Azure App Service allow to override settings via app configuraiton. However, for App Service for Container we cannot do that if the setting name consist of periods (".").

  • User Avatar
    0
    alper created
    Support Team Director

    thank you. I've created an issue https://github.com/abpframework/abp/issues/6272 closing this, you can track the GitHub issue.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi @rachanee-mwp

    You can create a custom ConfigurationSettingValueProvider then read settings via underscore name.

    
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
    	Configure<AbpSettingOptions>(options =>
    	{
    		options.ValueProviders.InsertAfter(typeof(ConfigurationSettingValueProvider), typeof(MyConfigurationSettingValueProvider));
    	});
    }
    
    
    public class MyConfigurationSettingValueProvider : ISettingValueProvider, ITransientDependency
    {
    	public const string ConfigurationNamePrefix = "Settings:";
    
    	public const string ProviderName = "MC";
    
    	public string Name => ProviderName;
    
    	protected IConfiguration Configuration { get; }
    
    	public MyConfigurationSettingValueProvider(IConfiguration configuration)
    	{
    		Configuration = configuration;
    	}
    
    	public virtual Task<string> GetOrNullAsync(SettingDefinition setting)
    	{
    		return Task.FromResult(Configuration[ConfigurationNamePrefix + setting.Name.Replace(".", "_")]);
    	}
    
    	public Task<List<SettingValue>> GetAllAsync(SettingDefinition[] settings)
    	{
    		return Task.FromResult(settings.Select(x => new SettingValue(x.Name, Configuration[ConfigurationNamePrefix + x.Name.Replace(".", "_")])).ToList());
    	}
    }
    
  • User Avatar
    1
    rachanee-mwp created

    @maliming, We do that as a workaround for now, but it would be better to have the those setting names from the framework itself because want to keep code (.cs and appsetting.json files) to be similar to the orginal version as much as possible for ease of code merging when doing upgrading.

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