示例#1
0
        /// <summary>
        /// This method is responsible to call the right API in the communication layer that will eventually send the information in the
        /// object to the REST endpoint
        /// </summary>
        /// <param name="model">The model object with the data to be sent to the REST endpoints</param>
        protected override ServerAdvancedDataSecurityPolicyModel PersistChanges(ServerAdvancedDataSecurityPolicyModel model)
        {
            // Enable ADS
            model.IsEnabled = true;
            ModelAdapter.SetServerAdvancedDataSecurity(model, DefaultContext.Environment.GetEndpoint(AzureEnvironment.Endpoint.StorageEndpointSuffix));

            if (!DoNotConfigureVulnerabilityAssessment)
            {
                // Deploy arm template to enable VA - only if VA at server level is not defined
                var vaAdapter = new SqlVulnerabilityAssessmentAdapter(DefaultContext);
                var vaModel   = vaAdapter.GetVulnerabilityAssessmentSettings(ResourceGroupName, ServerName, "", ApplyToType.Server);

                if (string.IsNullOrEmpty(vaModel.StorageAccountName))
                {
                    var serverAdapter = new AzureSqlServerAdapter(DefaultContext);
                    AzureSqlServerModel serverModel = serverAdapter.GetServer(ResourceGroupName, ServerName);
                    ModelAdapter.AutoEnableServerVa(ResourceGroupName, ServerName, serverModel.Location, DeploymentName);
                }
            }

            return(model);
        }