Example #1
0
        /// <summary>
        /// Upserts a virtual network 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 virtual network rule to create</param>
        /// <returns>The updated server model</returns>
        public AzureSqlServerVirtualNetworkRuleModel UpsertVirtualNetworkRule(AzureSqlServerVirtualNetworkRuleModel model)
        {
            var resp = Communicator.CreateOrUpdate(model.ResourceGroupName, model.ServerName, model.VirtualNetworkRuleName, new Management.Sql.Models.VirtualNetworkRule()
            {
                VirtualNetworkSubnetId = model.VirtualNetworkSubnetId
            });

            return(CreateVirtualNetworkRuleModelFromResponse(model.ResourceGroupName, model.ServerName, resp));
        }
Example #2
0
        /// <summary>
        /// Convert a Management.Sql.Models.VnetFirewallRule to AzureSqlServerVirtualNetworkRuleModel
        /// </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 AzureSqlServerVirtualNetworkRuleModel CreateVirtualNetworkRuleModelFromResponse(string resourceGroup, string serverName, Management.Sql.Models.VirtualNetworkRule resp)
        {
            AzureSqlServerVirtualNetworkRuleModel vnetFirewallRuleName = new AzureSqlServerVirtualNetworkRuleModel();

            vnetFirewallRuleName.ResourceGroupName      = resourceGroup;
            vnetFirewallRuleName.ServerName             = serverName;
            vnetFirewallRuleName.VirtualNetworkRuleName = resp.Name;
            vnetFirewallRuleName.VirtualNetworkSubnetId = resp.VirtualNetworkSubnetId;

            return(vnetFirewallRuleName);
        }