public ActionResult Index(string IPAddress) { var sqlManagementClient = createSqlManagementClient(); FirewallRuleUpdateParameters parameters = new FirewallRuleUpdateParameters(); parameters.StartIPAddress = IPAddress; parameters.EndIPAddress = IPAddress; parameters.Name = ConfigurationManager.AppSettings["FirewallRuleName"]; sqlManagementClient.FirewallRules.Update(ConfigurationManager.AppSettings["SQLServerName"], ConfigurationManager.AppSettings["FirewallRuleName"], parameters); return View(GetSqlFirewallRuleList().Where(f => f.Name == ConfigurationManager.AppSettings["FirewallRuleName"]).SingleOrDefault()); }
/// <summary> /// Updates an existing server-level Firewall Rule for an Azure SQL /// Database Server. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Sql.IFirewallRuleOperations. /// </param> /// <param name='serverName'> /// Required. The name of the Azure SQL Database Server that has the /// Firewall Rule to be updated. /// </param> /// <param name='ruleName'> /// Required. The name of the Firewall Rule to be updated. /// </param> /// <param name='parameters'> /// Required. The parameters for the Update Firewall Rule operation. /// </param> /// <returns> /// Represents the firewall rule update response. /// </returns> public static Task<FirewallRuleUpdateResponse> UpdateAsync(this IFirewallRuleOperations operations, string serverName, string ruleName, FirewallRuleUpdateParameters parameters) { return operations.UpdateAsync(serverName, ruleName, parameters, CancellationToken.None); }
/// <summary> /// Updates an existing server-level Firewall Rule for an Azure SQL /// Database Server. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Sql.IFirewallRuleOperations. /// </param> /// <param name='serverName'> /// Required. The name of the Azure SQL Database Server that has the /// Firewall Rule to be updated. /// </param> /// <param name='ruleName'> /// Required. The name of the Firewall Rule to be updated. /// </param> /// <param name='parameters'> /// Required. The parameters for the Update Firewall Rule operation. /// </param> /// <returns> /// Represents the firewall rule update response. /// </returns> public static FirewallRuleUpdateResponse Update(this IFirewallRuleOperations operations, string serverName, string ruleName, FirewallRuleUpdateParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IFirewallRuleOperations)s).UpdateAsync(serverName, ruleName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// Updates an existing server-level firewall rule for a SQL Database /// server that belongs to a subscription. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/gg715280.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Sql.IFirewallRuleOperations. /// </param> /// <param name='serverName'> /// The name of the SQL database server to which this rule will be /// applied. /// </param> /// <param name='ruleName'> /// The name of the firewall rule to be updated. /// </param> /// <param name='parameters'> /// Parameters for the Update Firewall Rule operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static FirewallRuleUpdateResponse Update(this IFirewallRuleOperations operations, string serverName, string ruleName, FirewallRuleUpdateParameters parameters) { try { return operations.UpdateAsync(serverName, ruleName, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }