private static void ApplyWithAppSettings(this Microsoft.Azure.Management.AppService.Fluent.IWebApp webApp, Dictionary <string, string> settings)
 {
     webApp
     .Update()
     .WithAppSettings(settings)
     .Apply();
 }
        public static void WriteConfiguration(this IRuleConfiguration config, Microsoft.Azure.Management.AppService.Fluent.IWebApp webApp)
        {
            var settings = new Dictionary <string, string>();

            settings.AddRuleSettings(config);

            webApp.ApplyWithAppSettings(settings);
        }
Example #3
0
 public void Write(Microsoft.Azure.Management.AppService.Fluent.IWebApp webApp)
 {
     webApp
     .Update()
     .WithAppSetting("Aggregator_VstsTokenType", VstsTokenType.ToString())
     .WithAppSetting("Aggregator_VstsToken", VstsToken)
     .Apply();
 }
        public static void Delete(this IRuleConfiguration config, Microsoft.Azure.Management.AppService.Fluent.IWebApp webApp)
        {
            var settings = new Dictionary <string, string>();

            settings.AddRuleSettings(config);

            var update = webApp.Update();

            foreach (var key in settings.Keys)
            {
                update.WithoutAppSetting(key);
            }

            update.Apply();
        }
        public static void WriteConfiguration(this IAggregatorConfiguration config, Microsoft.Azure.Management.AppService.Fluent.IWebApp webApp)
        {
            var settings = new Dictionary <string, string>()
            {
                { "Aggregator_VstsTokenType", config.DevOpsTokenType.ToString() },
                { "Aggregator_VstsToken", config.DevOpsToken },
                { "Aggregator_SaveMode", config.SaveMode.ToString() },
            };

            foreach (var ruleSetting in config.RulesConfiguration.Select(kvp => kvp.Value))
            {
                settings.AddRuleSettings(ruleSetting);
            }

            webApp.ApplyWithAppSettings(settings);
        }
        public static async Task <IAggregatorConfiguration> ReadConfiguration(Microsoft.Azure.Management.AppService.Fluent.IWebApp webApp)
        {
            (string ruleName, string key) SplitRuleNameKey(string input)
            {
                int idx = input.LastIndexOf('.');

                return(input.Substring(0, idx), input.Substring(idx + 1));
            }

            var settings = await webApp.GetAppSettingsAsync();

            var ac = new Model.AggregatorConfiguration();

            foreach (var ruleSetting in settings.Where(kvp => kvp.Key.StartsWith(RULE_SETTINGS_PREFIX)).Select(kvp => new { ruleNameKey = kvp.Key.Substring(RULE_SETTINGS_PREFIX.Length), value = kvp.Value.Value }))
            {
                var(ruleName, key) = SplitRuleNameKey(ruleSetting.ruleNameKey);

                var ruleConfig = ac.GetRuleConfiguration(ruleName);
                if (string.Equals("Disabled", key, StringComparison.OrdinalIgnoreCase))
                {
                    ruleConfig.IsDisabled = Boolean.TryParse(ruleSetting.value, out bool result) && result;
                }

                if (string.Equals("Impersonate", key, StringComparison.OrdinalIgnoreCase))
                {
                    ruleConfig.Impersonate = string.Equals("onBehalfOfInitiator", ruleSetting.value, StringComparison.OrdinalIgnoreCase);
                }
            }

            Enum.TryParse(settings.GetValueOrDefault("Aggregator_VstsTokenType")?.Value, out DevOpsTokenType vtt);
            ac.DevOpsTokenType = vtt;
            ac.DevOpsToken     = settings.GetValueOrDefault("Aggregator_VstsToken")?.Value;
            ac.SaveMode        = Enum.TryParse(settings.GetValueOrDefault("Aggregator_SaveMode")?.Value, out SaveMode sm)
                ? sm
                : SaveMode.Default;
            ac.DryRun = false;
            return(ac);
        }
Example #7
0
 public static async Task <IAggregatorConfiguration> ReadConfiguration(Microsoft.Azure.Management.AppService.Fluent.IWebApp webApp)
 {