コード例 #1
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));
        }
        private async Task <ServerVulnerabilityAssessment> SetPolicy(SqlManagementTestContext context, SqlManagementClient sqlClient, ResourceGroup resourceGroup,
                                                                     Server server)
        {
            VulnerabilityAssessmentTestUtilities.StorageContainerInfo StorageContainerInfo = await VulnerabilityAssessmentTestUtilities.CreateStorageContainer(context, resourceGroup);

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

            return(sqlClient.ServerVulnerabilityAssessments.CreateOrUpdate(resourceGroup.Name, server.Name, policy));
        }