コード例 #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 ManagedInstanceAdvancedDataSecurityPolicyModel PersistChanges(ManagedInstanceAdvancedDataSecurityPolicyModel model)
        {
            // Enable ADS
            model.IsEnabled = true;
            ModelAdapter.SetManagedInstanceAdvancedDataSecurity(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, InstanceName, "", ApplyToType.ManagedInstance);

                if (string.IsNullOrEmpty(vaModel.StorageAccountName))
                {
                    var instanceAdapter = new AzureSqlManagedInstanceAdapter(DefaultContext);
                    var instanceModel   = instanceAdapter.GetManagedInstance(ResourceGroupName, InstanceName);
                    ModelAdapter.AutoEnableInstanceVa(ResourceGroupName, InstanceName, instanceModel.Location, DeploymentName);
                }
            }

            return(model);
        }