public void TestCreateAndUpdateIPv6FirewallRule()
        {
            string testPrefix = "ipv6firewallrulecrudtest-";

            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();

                // Create IPv6 Firewall Rule and Validate
                string ipv6FirewallRuleName = SqlManagementTestUtilities.GenerateName(testPrefix);

                IPv6FirewallRule toCreate = new IPv6FirewallRule()
                {
                    StartIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0000",
                    EndIPv6Address   = "0000:0000:0000:0000:0000:ffff:0000:0000"
                };
                var fr1 = sqlClient.IPv6FirewallRules.CreateOrUpdate(resourceGroup.Name, server.Name, ipv6FirewallRuleName, toCreate);
                SqlManagementTestUtilities.ValidateIPv6FirewallRule(toCreate, fr1, ipv6FirewallRuleName);

                // Update Firewall Rule and Validate
                toCreate = new IPv6FirewallRule()
                {
                    StartIPv6Address = "0000:0000:0000:0000:0000:ffff:0101:0101",
                    EndIPv6Address   = "0000:0000:0000:0000:0000:ffff:ffff:ffff"
                };
                fr1 = sqlClient.IPv6FirewallRules.CreateOrUpdate(resourceGroup.Name, server.Name, ipv6FirewallRuleName, toCreate);
                SqlManagementTestUtilities.ValidateIPv6FirewallRule(toCreate, fr1, ipv6FirewallRuleName);
            }
        }
        public async void TestCreateUpdateGetManagedInstanceVulnerabilityAssessments()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();
                var resourceGroup             = context.CreateResourceGroup();
                var managedInstance           = context.CreateManagedInstance(resourceGroup);

                // Verify Policy is empty to begin with
                ManagedInstanceVulnerabilityAssessment policyThatWasReceived = sqlClient.ManagedInstanceVulnerabilityAssessments.Get(resourceGroup.Name, managedInstance.Name);
                Assert.Null(policyThatWasReceived.StorageContainerPath);
                Assert.Null(policyThatWasReceived.StorageAccountAccessKey);
                Assert.False(policyThatWasReceived.RecurringScans.IsEnabled);

                // Set policy and then get policy and verify correctness
                ManagedInstanceVulnerabilityAssessment policyThatWasSet = await SetPolicy(context, sqlClient, resourceGroup, managedInstance);

                policyThatWasReceived = sqlClient.ManagedInstanceVulnerabilityAssessments.Get(resourceGroup.Name, managedInstance.Name);
                Assert.Equal(policyThatWasSet.StorageContainerPath, policyThatWasReceived.StorageContainerPath);
                Assert.Null(policyThatWasSet.StorageAccountAccessKey);
                Assert.Equal(policyThatWasSet.RecurringScans.IsEnabled, policyThatWasReceived.RecurringScans.IsEnabled);
                SqlManagementTestUtilities.AssertCollection(policyThatWasSet.RecurringScans.Emails, policyThatWasReceived.RecurringScans.Emails);
                Assert.Equal(policyThatWasSet.RecurringScans.EmailSubscriptionAdmins, policyThatWasReceived.RecurringScans.EmailSubscriptionAdmins);

                // Delete policy and then get policy and verify correctness
                sqlClient.ManagedInstanceVulnerabilityAssessments.Delete(resourceGroup.Name, managedInstance.Name);

                // Get policy after deletion
                policyThatWasReceived = sqlClient.ManagedInstanceVulnerabilityAssessments.Get(resourceGroup.Name, managedInstance.Name);
                Assert.Null(policyThatWasReceived.StorageContainerPath);
                Assert.Null(policyThatWasReceived.StorageAccountAccessKey);
                Assert.False(policyThatWasReceived.RecurringScans.IsEnabled);
            }
        }
示例#3
0
        public void TestListElasticPoolActivity()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();

                Dictionary <string, string> tags = new Dictionary <string, string>()
                {
                    { "tagKey1", "TagValue1" }
                };

                // Create a elastic pool
                //
                string epName  = SqlManagementTestUtilities.GenerateName();
                var    epInput = new ElasticPool()
                {
                    Location       = server.Location,
                    Tags           = tags,
                    DatabaseDtuMax = 5,
                    DatabaseDtuMin = 0
                };
                var returnedEp = sqlClient.ElasticPools.CreateOrUpdate(resourceGroup.Name, server.Name, epName, epInput);
                SqlManagementTestUtilities.ValidateElasticPool(epInput, returnedEp, epName);

                // Get the Elastic Pool Activity List
                var activity = sqlClient.ElasticPoolActivities.ListByElasticPool(resourceGroup.Name, server.Name, epName);

                Assert.Equal(1, activity.Where(a => a.ElasticPoolName == epName).Count());
                Assert.Equal(1, activity.Where(a => a.Operation == "CREATE").Count());
            }
        }
示例#4
0
        public void FailoverElasticPool()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();
                Server server = context.CreateServer(resourceGroup);

                // Create elastic pool
                string epName = SqlManagementTestUtilities.GenerateName();
                var    ep     = sqlClient.ElasticPools.CreateOrUpdate(resourceGroup.Name, server.Name, epName, new ElasticPool()
                {
                    Location = server.Location
                });
                Assert.NotNull(ep);

                // Create database in elastic pool
                string dbName  = SqlManagementTestUtilities.GenerateName();
                var    dbInput = new Database()
                {
                    Location      = server.Location,
                    ElasticPoolId = ep.Id
                };
                var db = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, dbName, dbInput);
                Assert.NotNull(db);

                // Failover elastic pool
                sqlClient.ElasticPools.Failover(
                    resourceGroup.Name,
                    server.Name,
                    epName);
            }
        }
示例#5
0
        public void TestCreateAndUpdateFirewallRule()
        {
            string testPrefix = "firewallrulecrudtest-";

            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();

                // Create Firewall Rule and Validate
                //
                string firewallRuleName = SqlManagementTestUtilities.GenerateName(testPrefix);

                FirewallRule toCreate = new FirewallRule()
                {
                    StartIpAddress = "0.0.0.0",
                    EndIpAddress   = "0.0.0.0"
                };
                var fr1 = sqlClient.FirewallRules.CreateOrUpdate(resourceGroup.Name, server.Name, firewallRuleName, toCreate);
                SqlManagementTestUtilities.ValidateFirewallRule(toCreate, fr1, firewallRuleName);

                // Update Firewall Rule and Validate
                toCreate = new FirewallRule()
                {
                    StartIpAddress = "1.1.1.1",
                    EndIpAddress   = "255.255.255.255"
                };
                fr1 = sqlClient.FirewallRules.CreateOrUpdate(resourceGroup.Name, server.Name, firewallRuleName, toCreate);
                SqlManagementTestUtilities.ValidateFirewallRule(toCreate, fr1, firewallRuleName);
            }
        }
示例#6
0
        public void TestShortTermRetentionPolicyOnPremium()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                // Valid Retention Days for Basic DB is 1 to 35 days.
                int defaultRetentionDays = 7;

                // Valid Differential Backup Interval Hours is 12 or 24.
                int defaultDiffBackupIntervalHours = 12;

                // Create a DTU - Premium DB.
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();
                Database            database      = sqlClient.Databases.CreateOrUpdate(
                    resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(),
                    new Database
                {
                    Location = server.Location,
                    Sku      = new Microsoft.Azure.Management.Sql.Models.Sku(ServiceObjectiveName.P1)
                });

                // Test GET operation can get default retention days and diffbackupinterval value.
                BackupShortTermRetentionPolicy policyDefault = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(defaultRetentionDays, policyDefault.RetentionDays);
                Assert.Equal(defaultDiffBackupIntervalHours, policyDefault.DiffBackupIntervalInHours);

                // Attempt to set retention period to 36 days (invalid); Attemp to set the differential backup interval to 24 hours (valid); Verify the operation fails on updating the policy.
                BackupShortTermRetentionPolicy parameters1 = new BackupShortTermRetentionPolicy(retentionDays: 36, diffBackupIntervalInHours: 24);
                sqlClient.BackupShortTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroup.Name, server.Name, database.Name, parameters1);
                Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities.Wait(TimeSpan.FromSeconds(3));
                BackupShortTermRetentionPolicy policy = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(defaultRetentionDays, policy.RetentionDays);
                Assert.Equal(defaultDiffBackupIntervalHours, policy.DiffBackupIntervalInHours);

                // Attempt to set retention period to 35 days (valid); Attemp to set the differential backup interval to 20 hours (invalid); Verify the operation fails on updating the policy.
                BackupShortTermRetentionPolicy parameters2 = new BackupShortTermRetentionPolicy(retentionDays: 35, diffBackupIntervalInHours: 20);
                sqlClient.BackupShortTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroup.Name, server.Name, database.Name, parameters2);
                Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities.Wait(TimeSpan.FromSeconds(3));
                BackupShortTermRetentionPolicy policy2 = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(defaultRetentionDays, policy2.RetentionDays);
                Assert.Equal(defaultDiffBackupIntervalHours, policy2.DiffBackupIntervalInHours);

                // Increase retention period to 35 days (valid); Increase differential backup interval to 24 hours (valid); Verify the operation success.
                BackupShortTermRetentionPolicy parameters3 = new BackupShortTermRetentionPolicy(retentionDays: 35, diffBackupIntervalInHours: 24);
                sqlClient.BackupShortTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroup.Name, server.Name, database.Name, parameters3);
                Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities.Wait(TimeSpan.FromSeconds(3));
                BackupShortTermRetentionPolicy policy3 = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(parameters3.RetentionDays, policy3.RetentionDays);
                Assert.Equal(parameters3.DiffBackupIntervalInHours, policy3.DiffBackupIntervalInHours);

                // Decrease retention period to 7 days again; Decrease differential backup interval to 12 hours again (valid); Verify the operation success.
                BackupShortTermRetentionPolicy parameters4 = new BackupShortTermRetentionPolicy(retentionDays: 7, diffBackupIntervalInHours: 12);
                sqlClient.BackupShortTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroup.Name, server.Name, database.Name, parameters4);
                Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities.Wait(TimeSpan.FromSeconds(3));
                BackupShortTermRetentionPolicy policy4 = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(parameters4.RetentionDays, policy4.RetentionDays);
                Assert.Equal(parameters4.DiffBackupIntervalInHours, policy4.DiffBackupIntervalInHours);
            }
        }
示例#7
0
        public async void TestCreateUpdateGetDeleteDatabaseVulnerabilityAssessmentBaselines()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                string testPrefix = "sqlvulnerabilityassessmentbaselinetest-";

                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();
                var resourceGroup             = context.CreateResourceGroup();
                var managedInstance           = context.CreateManagedInstance(resourceGroup);

                // Create managed database
                //
                string dbName = SqlManagementTestUtilities.GenerateName(testPrefix);
                var    db1    = sqlClient.ManagedDatabases.CreateOrUpdate(resourceGroup.Name, managedInstance.Name, dbName, new ManagedDatabase()
                {
                    Location = managedInstance.Location,
                });
                Assert.NotNull(db1);

                // Set policy
                await SetPolicy(context, sqlClient, resourceGroup, managedInstance, dbName);

                // Test baseline for database level rule
                ValidateBaselineRule(sqlClient, resourceGroup, managedInstance, dbName, isServerLevelRule: true);

                // Test baseline for server level rule
                ValidateBaselineRule(sqlClient, resourceGroup, managedInstance, dbName, isServerLevelRule: false);
            }
        }
示例#8
0
        public void TestAllScenariosPrivateEndpointConnection()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                sqlClient     = context.GetClient <SqlManagementClient>();
                networkClient = context.GetClient <NetworkManagementClient>();

                var            location                = TestEnvironmentUtilities.DefaultEuapPrimaryLocationId;
                ResourceGroup  resourceGroup           = context.CreateResourceGroup(location);
                Server         server                  = context.CreateServer(resourceGroup, location);
                VirtualNetwork vnet                    = CreateVirtualNetwork(resourceGroup, location);
                IList <PrivateEndpointConnection> pecs = CreatePrivateEndpoints(resourceGroup, location, server, vnet, n: 2);

                PrivateEndpointConnection pec1 = pecs[0];
                pec1.PrivateLinkServiceConnectionState.Status = "Approved";
                sqlClient.PrivateEndpointConnections.CreateOrUpdate(resourceGroup.Name, server.Name, pec1.Name, pec1);
                PrivateEndpointConnection pec1r = sqlClient.PrivateEndpointConnections.Get(resourceGroup.Name, server.Name, pec1.Name);
                SqlManagementTestUtilities.ValidatePrivateEndpointConnection(pec1, pec1r);

                PrivateEndpointConnection pec2 = pecs[1];
                pec2.PrivateLinkServiceConnectionState.Status = "Rejected";
                sqlClient.PrivateEndpointConnections.CreateOrUpdate(resourceGroup.Name, server.Name, pec2.Name, pec2);
                PrivateEndpointConnection pec2r = sqlClient.PrivateEndpointConnections.Get(resourceGroup.Name, server.Name, pec2.Name);
                SqlManagementTestUtilities.ValidatePrivateEndpointConnection(pec2, pec2r);

                sqlClient.PrivateEndpointConnections.Delete(resourceGroup.Name, server.Name, pec1.Name);
                Assert.Throws <Microsoft.Rest.Azure.CloudException>(() => sqlClient.PrivateEndpointConnections.Get(resourceGroup.Name, server.Name, pec1.Name));

                sqlClient.PrivateEndpointConnections.Delete(resourceGroup.Name, server.Name, pec2.Name);
                Assert.Throws <Microsoft.Rest.Azure.CloudException>(() => sqlClient.PrivateEndpointConnections.Get(resourceGroup.Name, server.Name, pec2.Name));
            }
        }
示例#9
0
        public void TestShortTermRetentionPolicyOnBasic()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                int basicRetention = 7;

                // Create a Basic DB so it defaults to 7 days retention.
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();
                Database            database      = sqlClient.Databases.CreateOrUpdate(
                    resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(),
                    new Database
                {
                    Location = server.Location,
                    Sku      = new Microsoft.Azure.Management.Sql.Models.Sku(ServiceObjectiveName.Basic)
                });

                // Attempt to increase retention period to 8 days and verfiy that the operation fails.
                BackupShortTermRetentionPolicy parameters = new BackupShortTermRetentionPolicy(retentionDays: 8);
                sqlClient.BackupShortTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroup.Name, server.Name, database.Name, parameters);
                Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities.Wait(TimeSpan.FromSeconds(3));
                BackupShortTermRetentionPolicy policy = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(basicRetention, policy.RetentionDays);

                // Attempt to dncrease retention period to 3 days and verify operation failure.
                parameters = new BackupShortTermRetentionPolicy(retentionDays: 3);
                sqlClient.BackupShortTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroup.Name, server.Name, database.Name, parameters);
                Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities.Wait(TimeSpan.FromSeconds(3));
                policy = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(basicRetention, policy.RetentionDays);
            }
        }
示例#10
0
        public async void TestExportDatabaseVulnerabilityAssessmentScans()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                string testPrefix = "sqlvulnerabilityassessmentexportscantest-";

                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();
                var resourceGroup             = context.CreateResourceGroup();
                var managedInstance           = context.CreateManagedInstance(resourceGroup);

                // Create managed database
                //
                string dbName = SqlManagementTestUtilities.GenerateName(testPrefix);
                var    db1    = sqlClient.ManagedDatabases.CreateOrUpdate(resourceGroup.Name, managedInstance.Name, dbName, new ManagedDatabase()
                {
                    Location = managedInstance.Location,
                });
                Assert.NotNull(db1);

                // Set policy
                await SetPolicy(context, sqlClient, resourceGroup, managedInstance, dbName);

                // Run some scans
                string scanId = string.Format("scan1_{0}", testPrefix);
                sqlClient.ManagedDatabaseVulnerabilityAssessmentScans.InitiateScan(resourceGroup.Name, managedInstance.Name, dbName, scanId);
                sqlClient.ManagedDatabaseVulnerabilityAssessmentScans.Export(resourceGroup.Name, managedInstance.Name, dbName, scanId);
            }
        }
示例#11
0
        public void TestShortTermRetentionPolicyOnPremium()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                // Create a Premium DB so it defaults to 35 days retention.
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();
                Database            database      = sqlClient.Databases.CreateOrUpdate(
                    resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(),
                    new Database
                {
                    Location = server.Location,
                    Sku      = new Microsoft.Azure.Management.Sql.Models.Sku(ServiceObjectiveName.P1)
                });

                // Decrease retention period to 8 days and verfiy that it was updated.
                BackupShortTermRetentionPolicy parameters = new BackupShortTermRetentionPolicy(retentionDays: 8);
                sqlClient.BackupShortTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroup.Name, server.Name, database.Name, parameters);
                Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities.Wait(TimeSpan.FromSeconds(3));
                BackupShortTermRetentionPolicy policy = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(parameters.RetentionDays, policy.RetentionDays);

                // Increase retention period to 35 days again and verfiy that it was updated.
                parameters = new BackupShortTermRetentionPolicy(retentionDays: 35);
                sqlClient.BackupShortTermRetentionPolicies.CreateOrUpdateWithHttpMessagesAsync(resourceGroup.Name, server.Name, database.Name, parameters);
                Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities.Wait(TimeSpan.FromSeconds(3));
                policy = sqlClient.BackupShortTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(parameters.RetentionDays, policy.RetentionDays);
            }
        }
示例#12
0
        public void FailoverReadableSecondaryInstance()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();

                var             rg = context.CreateResourceGroup(ManagedInstanceTestUtilities.Region);
                ManagedInstance managedInstance = context.CreateManagedInstance(rg);
                Assert.NotNull(managedInstance);
                var resourceGroupName = rg.Name;

                // Wait for first full backup to finish
                if (HttpMockServer.Mode == HttpRecorderMode.Record)
                {
                    Thread.Sleep(TimeSpan.FromMinutes(6));
                }
                try
                {
                    sqlClient.ManagedInstances.Failover(resourceGroupName, managedInstance.Name, ReplicaType.ReadableSecondary);
                }
                catch (Exception ex)
                {
                    Assert.Contains("failover is not supported", ex.Message);
                }
            }
        }
示例#13
0
        public virtual void TestDatabaseSensitivityLabels()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup resourceGroup     = context.CreateResourceGroup();
                string        resourceGroupName = resourceGroup.Name;

                Server server     = context.CreateServer(resourceGroup);
                string serverName = server.Name;

                ISqlManagementClient client = context.GetClient <SqlManagementClient>();
                CreateFirewallRule(resourceGroupName, serverName, client);

                string   databaseName = GetDatabaseName();
                Database database     = client.Databases.CreateOrUpdate(
                    resourceGroupName, serverName, databaseName,
                    new Database()
                {
                    Location = server.Location,
                });
                Assert.NotNull(database);

                CreateTableIfNeeded(serverName, server.FullyQualifiedDomainName, databaseName);

                RunTest(client, resourceGroupName, serverName, databaseName);

                client.Databases.Delete(resourceGroupName, serverName, databaseName);
                client.Servers.Delete(resourceGroupName, serverName);
            }
        }
        private void createManagedInstances(SqlManagementTestContext context, ResourceGroup resourceGroup, IList <string> managedInstanceNames)
        {
            SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();

            Sku sku = new Sku();

            sku.Name = "MIGP8G4";
            sku.Tier = "GeneralPurpose";

            VirtualNetwork vnet = ManagedInstanceTestFixture.CreateVirtualNetwork(context, resourceGroup, TestEnvironmentUtilities.DefaultLocationId);

            foreach (string miName in managedInstanceNames)
            {
                ManagedInstance managedInstance = sqlClient.ManagedInstances.CreateOrUpdate(resourceGroup.Name, miName, new ManagedInstance()
                {
                    AdministratorLogin         = SqlManagementTestUtilities.DefaultLogin,
                    AdministratorLoginPassword = SqlManagementTestUtilities.DefaultPassword,
                    SubnetId = vnet.Subnets[0].Id,
                    Tags     = new Dictionary <string, string>(),
                    Location = TestEnvironmentUtilities.DefaultLocationId,
                    Sku      = sku,
                });
                Assert.NotNull(managedInstance);
            }
        }
        public void TestPauseResumeDatabase()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();

                // Create data warehouse
                string dbName = SqlManagementTestUtilities.GenerateName();
                var    db1    = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, dbName, new Database()
                {
                    Location = server.Location,
                    Sku      = SqlTestConstants.DefaultDataWarehouseSku()
                });
                Assert.NotNull(db1);

                // Pause
                sqlClient.Databases.Pause(resourceGroup.Name, server.Name, dbName);
                // TODO: Get result and verify that status is now resumed - blocked by https://github.com/Azure/autorest/issues/2295

                // Resume
                sqlClient.Databases.Resume(resourceGroup.Name, server.Name, dbName);
                // TODO: Get result and verify that status is now resumed - blocked by https://github.com/Azure/autorest/issues/2295
            }
        }
        public void TestCreateLedgerDatabase()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();

                ResourceGroup resourceGroup = context.CreateResourceGroup();
                Server        server        = context.CreateServer(resourceGroup);

                // Create database with IsLedgerOn
                string   databaseName = SqlManagementTestUtilities.GenerateName();
                Database ledgerDb     = sqlClient.Databases.CreateOrUpdate(
                    resourceGroup.Name,
                    server.Name,
                    databaseName,
                    new Database()
                {
                    Location   = server.Location,
                    IsLedgerOn = true
                });

                // Get the created database and validate IsLedgerOn parameter is set
                Database databaseResponse = sqlClient.Databases.Get(resourceGroup.Name, server.Name, databaseName);
                Assert.True(databaseResponse.IsLedgerOn);
            }
        }
示例#17
0
        public ManagedInstanceTestFixture()
        {
            Context = new SqlManagementTestContext(this);

            try
            {
                SqlManagementClient sqlClient = Context.GetClient <SqlManagementClient>();

                ResourceGroup = Context.CreateResourceGroup();

                // Create vnet and get the subnet id
                VirtualNetwork vnet = CreateVirtualNetwork(Context, ResourceGroup, TestEnvironmentUtilities.DefaultLocationId);

                Sku sku = new Sku();
                sku.Name        = "MIGP8G4";
                sku.Tier        = "GeneralPurpose";
                ManagedInstance = sqlClient.ManagedInstances.CreateOrUpdate(ResourceGroup.Name,
                                                                            "crud-tests-" + SqlManagementTestUtilities.GenerateName(), new ManagedInstance()
                {
                    AdministratorLogin         = SqlManagementTestUtilities.DefaultLogin,
                    AdministratorLoginPassword = SqlManagementTestUtilities.DefaultPassword,
                    Sku      = sku,
                    SubnetId = vnet.Subnets[0].Id,
                    Tags     = new Dictionary <string, string>(),
                    Location = TestEnvironmentUtilities.DefaultLocationId,
                });
            }
            catch (Exception ex)
            {
                Context.Dispose();
            }
        }
示例#18
0
        public void FailoverReadableSecondaryDatabase()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();
                Server server = context.CreateServer(resourceGroup);

                // Create database
                string dbName  = SqlManagementTestUtilities.GenerateName();
                var    dbInput = new Database()
                {
                    Location = server.Location,
                    Sku      = new Microsoft.Azure.Management.Sql.Models.Sku(ServiceObjectiveName.P1)
                };
                var db = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, dbName, dbInput);
                Assert.NotNull(db);

                // Failover database
                sqlClient.Databases.Failover(
                    resourceGroup.Name,
                    server.Name,
                    dbName,
                    "ReadableSecondary");
            }
        }
        public void TestDatabasePointInTimeRestore()
        {
            // Warning: This test takes around 20 minutes to run in record mode.

            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();

                Database db1 = CreateDatabaseAndWaitUntilBackupCreated(
                    sqlClient,
                    resourceGroup,
                    server,
                    dbName: SqlManagementTestUtilities.GenerateName());

                // Create a new database that is the first database restored to an earlier point in time
                string   db2Name  = SqlManagementTestUtilities.GenerateName();
                Database db2Input = new Database
                {
                    Location           = server.Location,
                    CreateMode         = CreateMode.PointInTimeRestore,
                    RestorePointInTime = db1.EarliestRestoreDate.Value,
                    SourceDatabaseId   = db1.Id
                };
                Database db2 = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, db2Name, db2Input);
                Assert.NotNull(db2);
                SqlManagementTestUtilities.ValidateDatabase(db2Input, db2, db2Name);
            }
        }
        public void TestRecoverInstanceDatabase()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();

                // Use exising CI/database, otherwise 10 hours are needed for waiting new created database is replicated in paired cluster.
                // In worst case, more than 1 day is needed for waiting
                string resourceGroup       = "restore-rg";
                string managedInstanceName = "restorerunnermanagedserverwus";
                var    managedInstance     = sqlClient.ManagedInstances.Get(resourceGroup, managedInstanceName);

                // List recoveralbe database
                var listResponse = sqlClient.RecoverableManagedDatabases.ListByInstance(resourceGroup, managedInstance.Name);

                // Get more than 1 database
                Assert.True(listResponse.Count() > 0);
                RecoverableManagedDatabase sourceManagedDb = listResponse.First();
                String targetDbName = SqlManagementTestUtilities.GenerateName();
                var    targetInput  = new ManagedDatabase()
                {
                    Location              = managedInstance.Location,
                    CreateMode            = "Recovery",
                    RecoverableDatabaseId = sourceManagedDb.Id
                };

                // Issue recovery request
                var targetDb = sqlClient.ManagedDatabases.CreateOrUpdate(resourceGroup, managedInstanceName, targetDbName,
                                                                         targetInput);

                Assert.NotNull(targetDb);
                SqlManagementTestUtilities.ValidateManagedDatabase(targetInput, targetDb, targetDbName);
                sqlClient.ManagedDatabases.Delete(resourceGroup, managedInstance.Name, targetDb.Name);
            }
        }
示例#21
0
        private async Task <ManagedInstanceVulnerabilityAssessment> SetPolicy(SqlManagementTestContext context, SqlManagementClient sqlClient, ResourceGroup resourceGroup,
                                                                              ManagedInstance managedInstance)
        {
            // Modify the policy properties, send and receive and see it its still ok
            ManagedServerSecurityAlertPolicy updatedManagedServerPolicy = new ManagedServerSecurityAlertPolicy
            {
                State = SecurityAlertsPolicyState.Enabled,
                EmailAccountAdmins = true
            };

            //Set security alert policy for server
            sqlClient.ManagedServerSecurityAlertPolicies.CreateOrUpdate(resourceGroup.Name, managedInstance.Name, updatedManagedServerPolicy);

            VulnerabilityAssessmentTestUtilities.StorageContainerInfo StorageContainerInfo = await VulnerabilityAssessmentTestUtilities.CreateStorageContainer(context, resourceGroup);

            ManagedInstanceVulnerabilityAssessment policy = new ManagedInstanceVulnerabilityAssessment()
            {
                StorageContainerPath   = StorageContainerInfo.StorageContainerPath.ToString(),
                StorageContainerSasKey = StorageContainerInfo.StorageAccountAccessKey,
                RecurringScans         = new VulnerabilityAssessmentRecurringScansProperties()
                {
                    IsEnabled = false,
                    Emails    = new List <string>()
                    {
                        "*****@*****.**", "*****@*****.**"
                    },
                    EmailSubscriptionAdmins = true
                }
            };

            return(sqlClient.ManagedInstanceVulnerabilityAssessments.CreateOrUpdate(resourceGroup.Name, managedInstance.Name, policy));
        }
        public void TestLongTermRetentionV2Policies()
        {
            string defaultPolicy = "PT0S";

            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();
                Database            database      = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(), new Database {
                    Location = server.Location
                });

                // Get the policy and verify it is the default policy
                //
                LongTermRetentionPolicy policy = sqlClient.LongTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(defaultPolicy, policy.WeeklyRetention);
                Assert.Equal(defaultPolicy, policy.MonthlyRetention);
                Assert.Equal(defaultPolicy, policy.YearlyRetention);
                Assert.Equal(0, policy.WeekOfYear);

                // Set the retention policy to two weeks for the weekly retention policy
                //
                LongTermRetentionPolicy parameters = new LongTermRetentionPolicy(weeklyRetention: "P2W");
                sqlClient.LongTermRetentionPolicies.CreateOrUpdate(resourceGroup.Name, server.Name, database.Name, parameters);

                // Get the policy and verify the weekly policy is two weeks but all the rest stayed the same
                //
                policy = sqlClient.LongTermRetentionPolicies.Get(resourceGroup.Name, server.Name, database.Name);
                Assert.Equal(parameters.WeeklyRetention, policy.WeeklyRetention);
                Assert.Equal(defaultPolicy, policy.MonthlyRetention);
                Assert.Equal(defaultPolicy, policy.YearlyRetention);
                Assert.Equal(0, policy.WeekOfYear);
            }
        }
        public async void TestShortTermRetentionPolicyOnGeneralPurposeScriptUse()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                // Valid Retention Days for GeneralPurpose DB is 1 to 35 days.
                int defaultRetentionDays = 7;

                // Create a vCore - GeneralPurpose DB.
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                Server              server        = context.CreateServer(resourceGroup);
                SqlManagementClient sqlClient     = context.GetClient <SqlManagementClient>();
                Database            database      = sqlClient.Databases.CreateOrUpdate(
                    resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(),
                    new Database
                {
                    Location = server.Location,
                    Sku      = new Microsoft.Azure.Management.Sql.Models.Sku(ServiceObjectiveName.P1)
                });

                // Test Update operation through GET operation.
                var strPolicy = await sqlClient.BackupShortTermRetentionPolicies.GetAsync(resourceGroup.Name.ToString(), server.Name.ToString(), database.Name.ToString());

                strPolicy.RetentionDays = 28;
                await sqlClient.BackupShortTermRetentionPolicies.BeginCreateOrUpdateAsync(resourceGroup.Name.ToString(), server.Name.ToString(), database.Name.ToString(), strPolicy);

                Assert.Equal(28, strPolicy.RetentionDays);
            }
        }
示例#24
0
        public void TestGetCapabilities()
        {
            Dictionary <string, string> tags = new Dictionary <string, string>();
            string suiteName = this.GetType().FullName;

            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();

                LocationCapabilities capabilities = sqlClient.Capabilities.ListByLocation(TestEnvironmentUtilities.DefaultLocation);

                Assert.NotNull(capabilities);

                foreach (ServerVersionCapability s in capabilities.SupportedServerVersions)
                {
                    Assert.NotNull(s.Name);
                    foreach (EditionCapability e in s.SupportedEditions)
                    {
                        Assert.NotNull(e.Name);
                        foreach (ServiceObjectiveCapability o in e.SupportedServiceLevelObjectives)
                        {
                            Assert.NotNull(o.Name);
                            Assert.NotNull(o.PerformanceLevel);
                            foreach (MaxSizeRangeCapability m in o.SupportedMaxSizes)
                            {
                                Assert.NotNull(m.MinValue);
                                Assert.NotNull(m.MaxValue);
                            }
                        }
                    }
                }
            }
        }
        public void TestCreateAndDropVirtualNetworkRule()
        {
            string testPrefix = "virtualnetworkrulecrudtest-";

            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                // Basic setup
                var            location        = TestEnvironmentUtilities.DefaultEuapPrimaryLocationId;
                ResourceGroup  resourceGroup   = context.CreateResourceGroup(location);
                VirtualNetwork getVnetResponse = CreateVirtualNetwork(context, resourceGroup, location: location, subnetCount: 1);

                Server server = context.CreateServer(resourceGroup, location);
                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();

                // create virtual network rules
                string vnetfirewallRuleName = SqlManagementTestUtilities.GenerateName(testPrefix);

                VirtualNetworkRule rule = new VirtualNetworkRule()
                {
                    VirtualNetworkSubnetId           = getVnetResponse.Subnets[0].Id.ToString(),
                    IgnoreMissingVnetServiceEndpoint = false
                };
                VirtualNetworkRule vfr = sqlClient.VirtualNetworkRules.CreateOrUpdate(resourceGroup.Name, server.Name, vnetfirewallRuleName, rule);
                SqlManagementTestUtilities.ValidateVirtualNetworkRule(rule, vfr, vnetfirewallRuleName);

                // delete virtual network rules
                sqlClient.VirtualNetworkRules.Delete(resourceGroup.Name, server.Name, vfr.Name);
            }
        }
        public void FailoverReadableSecondaryInstance()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup resourceGroup = new ResourceGroup(
                    TestEnvironmentUtilities.DefaultLocationId, name: "mibrkic");
                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();

                string managedInstanceName = "sqlcl-failovertests-dotnetsdk1";

                VirtualNetwork vnet = ManagedInstanceTestFixture.CreateVirtualNetwork(context, resourceGroup, TestEnvironmentUtilities.DefaultLocationId);

                Microsoft.Azure.Management.Sql.Models.Sku sku = new Microsoft.Azure.Management.Sql.Models.Sku
                {
                    Name = "MIBC8G5",
                    Tier = "BusinessCritical"
                };

                ManagedInstance managedInstance = sqlClient.ManagedInstances.CreateOrUpdate(resourceGroup.Name,
                                                                                            managedInstanceName + SqlManagementTestUtilities.GenerateName(methodName: "failover_readable_secondary"), new ManagedInstance()
                {
                    AdministratorLogin         = SqlManagementTestUtilities.DefaultLogin,
                    AdministratorLoginPassword = SqlManagementTestUtilities.DefaultPassword,
                    Sku      = sku,
                    SubnetId = vnet.Subnets[0].Id,
                    Tags     = new Dictionary <string, string>(),
                    Location = TestEnvironmentUtilities.DefaultLocationId,
                });
                Assert.NotNull(managedInstance);

                sqlClient.ManagedInstances.Failover(resourceGroup.Name, managedInstance.Name, ReplicaType.ReadableSecondary);
            }
        }
        public async void TestDatabaseBlobAuditingPolicy()
        {
            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                ResourceGroup       resourceGroup = context.CreateResourceGroup();
                SqlManagementClient client        = context.GetClient <SqlManagementClient>();
                Server server = context.CreateServer(resourceGroup);

                Database database = client.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(DatabaseNamePrefix), new Database()
                {
                    Location = server.Location,
                });
                Assert.NotNull(database);

                StorageAccountInformation storageAccountInformation = await CreateStorageAccountAsync(context, resourceGroup);

                DatabaseBlobAuditingPolicy databasePolicy = new DatabaseBlobAuditingPolicy
                {
                    State                       = BlobAuditingPolicyState.Enabled,
                    StorageEndpoint             = storageAccountInformation.Endpoint,
                    StorageAccountAccessKey     = storageAccountInformation.PrimaryKey,
                    RetentionDays               = RetentionDays,
                    IsStorageSecondaryKeyInUse  = IsStorageSecondaryKeyInUse,
                    IsAzureMonitorTargetEnabled = true,
                    QueueDelayMs                = 1000
                };

                ExtendedDatabaseBlobAuditingPolicy extendedDatabasePolicy = new ExtendedDatabaseBlobAuditingPolicy
                {
                    State                       = BlobAuditingPolicyState.Enabled,
                    StorageEndpoint             = storageAccountInformation.Endpoint,
                    StorageAccountAccessKey     = storageAccountInformation.PrimaryKey,
                    RetentionDays               = RetentionDays,
                    IsStorageSecondaryKeyInUse  = IsStorageSecondaryKeyInUse,
                    PredicateExpression         = PredicateExpression,
                    IsAzureMonitorTargetEnabled = true,
                    QueueDelayMs                = 1000
                };

                DatabaseBlobAuditingPolicy databaseResultPolicy = await client.DatabaseBlobAuditingPolicies.CreateOrUpdateAsync(resourceGroup.Name, server.Name, database.Name, databasePolicy);

                VerifyDatabaseBlobAuditingPolicy(databasePolicy, databaseResultPolicy);
                databaseResultPolicy = await client.DatabaseBlobAuditingPolicies.GetAsync(resourceGroup.Name, server.Name, database.Name);

                VerifyDatabaseBlobAuditingPolicy(databasePolicy, databaseResultPolicy);

                ExtendedDatabaseBlobAuditingPolicy extendedDatabaseResultPolicy = await client.ExtendedDatabaseBlobAuditingPolicies.CreateOrUpdateAsync(resourceGroup.Name, server.Name, database.Name, extendedDatabasePolicy);

                VerifyExtendedDatabaseBlobAuditingPolicy(extendedDatabasePolicy, extendedDatabaseResultPolicy);
                extendedDatabaseResultPolicy = await client.ExtendedDatabaseBlobAuditingPolicies.GetAsync(resourceGroup.Name, server.Name, database.Name);

                VerifyExtendedDatabaseBlobAuditingPolicy(extendedDatabasePolicy, extendedDatabaseResultPolicy);

                await client.Databases.DeleteAsync(resourceGroup.Name, server.Name, database.Name);

                await client.Servers.DeleteAsync(resourceGroup.Name, server.Name);
                await DeleteStorageAccountAsync(context, resourceGroup.Name, storageAccountInformation.Name);
            }
        }
        public VirtualNetwork CreateVirtualNetwork(SqlManagementTestContext context, ResourceGroup resourceGroup, string location, int subnetCount = 1)
        {
            NetworkManagementClient networkClient = context.GetClient <NetworkManagementClient>();

            // Create vnet andinitialize subnets
            string vnetName = SqlManagementTestUtilities.GenerateName();

            List <ServiceEndpointPropertiesFormat> SqlPrivateAccess = new List <ServiceEndpointPropertiesFormat>()
            {
                new ServiceEndpointPropertiesFormat("Microsoft.Sql")
            };

            List <Subnet> subnetList = new List <Subnet>();

            for (int i = 0; i < subnetCount; i++)
            {
                string subnetName    = SqlManagementTestUtilities.GenerateName();
                String addressPrefix = "10.0." + (i + 1) + ".0/24";
                Subnet subnet        = new Subnet()
                {
                    Name             = subnetName,
                    AddressPrefix    = addressPrefix,
                    ServiceEndpoints = SqlPrivateAccess,
                };
                subnetList.Add(subnet);
            }

            var vnet = new VirtualNetwork()
            {
                Location = location,

                AddressSpace = new AddressSpace()
                {
                    AddressPrefixes = new List <string>()
                    {
                        "10.0.0.0/16",
                    }
                },
                DhcpOptions = new DhcpOptions()
                {
                    DnsServers = new List <string>()
                    {
                        "10.1.1.1",
                        "10.1.2.4"
                    }
                },
                Subnets = subnetList
            };

            // Put Vnet
            var putVnetResponse = networkClient.VirtualNetworks.CreateOrUpdate(resourceGroup.Name, vnetName, vnet);

            Assert.Equal("Succeeded", putVnetResponse.ProvisioningState);

            // Get Vnet
            var getVnetResponse = networkClient.VirtualNetworks.Get(resourceGroup.Name, vnetName);

            return(getVnetResponse);
        }
示例#29
0
 private void createManagedInstances(SqlManagementTestContext context, ResourceGroup resourceGroup, IList <string> managedInstanceNames)
 {
     foreach (string miName in managedInstanceNames)
     {
         ManagedInstance managedInstance = context.CreateManagedInstance(resourceGroup, miName);
         Assert.NotNull(managedInstance);
     }
 }
        public void TestGetAndListVirtualNetworkRule()
        {
            string testPrefix = "virtualnetworkrulescrudtest-";

            using (SqlManagementTestContext context = new SqlManagementTestContext(this))
            {
                // Basic setup
                var            location        = TestEnvironmentUtilities.DefaultEuapPrimaryLocationId;
                ResourceGroup  resourceGroup   = context.CreateResourceGroup(location);
                VirtualNetwork getVnetResponse = CreateVirtualNetwork(context, resourceGroup, location: location, subnetCount: 2);

                Server server = context.CreateServer(resourceGroup, location);
                SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>();

                // create virtual network rules
                Dictionary <string, VirtualNetworkRule> rules = new Dictionary <string, VirtualNetworkRule>();

                //rule 1
                string vnetfirewallRuleName1 = SqlManagementTestUtilities.GenerateName(testPrefix);

                VirtualNetworkRule rule1 = new VirtualNetworkRule()
                {
                    VirtualNetworkSubnetId           = getVnetResponse.Subnets[0].Id.ToString(),
                    IgnoreMissingVnetServiceEndpoint = false
                };
                sqlClient.VirtualNetworkRules.CreateOrUpdate(resourceGroup.Name, server.Name, vnetfirewallRuleName1, rule1);
                rules.Add(vnetfirewallRuleName1, rule1);

                //rule 2
                string             vnetfirewallRuleName2 = SqlManagementTestUtilities.GenerateName(testPrefix);
                VirtualNetworkRule rule2 = new VirtualNetworkRule()
                {
                    VirtualNetworkSubnetId           = getVnetResponse.Subnets[1].Id.ToString(),
                    IgnoreMissingVnetServiceEndpoint = false
                };
                sqlClient.VirtualNetworkRules.CreateOrUpdate(resourceGroup.Name, server.Name, vnetfirewallRuleName2, rule2);
                rules.Add(vnetfirewallRuleName2, rule2);

                foreach (var rul in rules)
                {
                    VirtualNetworkRule response = sqlClient.VirtualNetworkRules.Get(resourceGroup.Name, server.Name, rul.Key);
                    SqlManagementTestUtilities.ValidateVirtualNetworkRule(rul.Value, response, rul.Key);
                }

                var listResponse = sqlClient.VirtualNetworkRules.ListByServer(resourceGroup.Name, server.Name);
                Assert.Equal(rules.Count(), listResponse.Count());

                foreach (var rul in listResponse)
                {
                    SqlManagementTestUtilities.ValidateVirtualNetworkRule(rules[rul.Name], rul, rul.Name);
                }

                foreach (var rul in rules)
                {
                    SqlManagementTestUtilities.ValidateVirtualNetworkRule(rul.Value, listResponse.Single(r => r.Name == rul.Key), rul.Key);
                }
            }
        }