/// <summary> /// Upserts a Firewall Rule /// </summary> /// <param name="resourceGroup">The name of the resource group</param> /// <param name="serverName">The name of ther server</param> /// <param name="model">The firewall rule to create</param> /// <returns>The updated server model</returns> public AzureSqlServerFirewallRuleModel UpsertFirewallRule(AzureSqlServerFirewallRuleModel model) { var resp = Communicator.CreateOrUpdate(model.ResourceGroupName, model.ServerName, model.FirewallRuleName, Util.GenerateTracingId(), new FirewallRuleCreateOrUpdateParameters() { Properties = new FirewallRuleCreateOrUpdateProperties() { EndIpAddress= model.EndIpAddress, StartIpAddress = model.StartIpAddress } }); return CreateFirewallRuleModelFromResponse(model.ResourceGroupName, model.ServerName, resp); }
/// <summary> /// Convert a Management.Sql.Models.FirewallRule to AzureSqlServerFirewallRuleModel /// </summary> /// <param name="resourceGroup">The resource group the server is in</param> /// <param name="serverName">The name of the server</param> /// <param name="resp">The management client server response to convert</param> /// <returns>The converted server model</returns> private static AzureSqlServerFirewallRuleModel CreateFirewallRuleModelFromResponse(string resourceGroup, string serverName, Management.Sql.Models.FirewallRule resp) { AzureSqlServerFirewallRuleModel firewallRule = new AzureSqlServerFirewallRuleModel(); firewallRule.StartIpAddress = resp.Properties.StartIpAddress; firewallRule.EndIpAddress = resp.Properties.EndIpAddress; firewallRule.FirewallRuleName = resp.Name; firewallRule.ResourceGroupName = resourceGroup; firewallRule.ServerName = serverName; return firewallRule; }