/// <summary>
        /// Gets the Location of the managed instance.
        /// </summary>
        /// <param name="resourceGroupName">The resource group the managed instance is in</param>
        /// <param name="managedInstanceName">The name of the managed instance</param>
        /// <returns></returns>
        public string GetManagedInstanceLocation(string resourceGroupName, string managedInstanceName)
        {
            AzureSqlManagedInstanceAdapter managedInstanceAdapter = new AzureSqlManagedInstanceAdapter(Context);
            var managedInstance = managedInstanceAdapter.GetManagedInstance(resourceGroupName, managedInstanceName);

            return(managedInstance.Location);
        }
Beispiel #2
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)
        {
            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);
        }