/// <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) { model.IsEnabled = true; if (DoNotConfigureVulnerabilityAssessment) { ModelAdapter.SetManagedInstanceAdvancedDataSecurity(model); } else { // 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.EnableInstanceAdsWithVa(ResourceGroupName, InstanceName, instanceModel.Location, DeploymentName); } else { ModelAdapter.SetManagedInstanceAdvancedDataSecurity(model); } } return(model); }