private static void SeedFirewallRules(DevOpsFlexDbContext context, DevOpsSystem system) { var sfaRule = new SqlFirewallRule { System = system, Name = "SFA LAN", StartIp = "193.240.137.225", EndIp = "193.240.137.254" }; var capRule = new SqlFirewallRule { System = system, Name = "Cap UK", StartIp = "212.167.5.1", EndIp = "212.167.5.255" }; context.SqlFirewallRules.AddOrUpdate( r => r.Name, sfaRule, capRule); }
private void FirewallRules(ISqlServer sqlServer, AzureSqlProps sQLProps) { Log.Information("Collecting FirewallRules for {0}", sqlServer.Name); var _firewallRules = sqlServer.FirewallRules.List(); Log.Information("{0} FirewallRules for server {1}", _firewallRules.Count, sqlServer.Name); foreach (var item in _firewallRules) { SqlFirewallRule _sqlFirewallRule = new SqlFirewallRule(); _sqlFirewallRule.ParentId = item.ParentId; _sqlFirewallRule.SqlServerName = item.SqlServerName; _sqlFirewallRule.StartIPAddress = item.StartIPAddress; _sqlFirewallRule.EndIPAddress = item.EndIPAddress; _sqlFirewallRule.Kind = item.Kind; sQLProps.SqlFirewallRule.Add(_sqlFirewallRule); } }
/// <summary> /// Checks for the existence of a specific Azure Sql Firewall rule, if it doesn't exist it will create it. /// </summary> /// <param name="client">The <see cref="SqlManagementClient"/> that is performing the operation.</param> /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this database spec.</param> /// <returns>The async <see cref="Task"/> wrapper.</returns> public static async Task CreateFirewallRuleIfNotExistsAsync(this SqlManagementClient client, SqlFirewallRule model) { Contract.Requires(client != null); Contract.Requires(model != null); await client.CreateFirewallRuleIfNotExistsAsync( await FlexConfiguration.SqlServerChooser.Choose(client, model.System.Location.GetEnumDescription()), model.AzureParameters); }