/// <summary> /// Takes the cmdlets model object and transform it to the policy as expected by the endpoint /// </summary> private Management.Sql.Models.ServerSecurityAlertPolicy PolicizeServerSecurityAlertModel(BaseThreatDetectionPolicyModel model, string storageEndpointSuffix) { var policy = new Management.Sql.Models.ServerSecurityAlertPolicy() { State = model.ThreatDetectionState == ThreatDetectionStateType.Enabled ? SecurityAlertsPolicyState.Enabled : SecurityAlertsPolicyState.Disabled, DisabledAlerts = ExtractExcludedDetectionType(model), EmailAddresses = model.NotificationRecipientsEmails.Split(';').Where(mail => !string.IsNullOrEmpty(mail)).ToList(), EmailAccountAdmins = model.EmailAdmins, RetentionDays = Convert.ToInt32(model.RetentionInDays), }; if (string.IsNullOrEmpty(model.StorageAccountName)) { policy.StorageEndpoint = null; policy.StorageAccountAccessKey = null; } else { BaseSecurityAlertPolicyProperties legacyProperties = new BaseSecurityAlertPolicyProperties(); PopulateStoragePropertiesInPolicy(model, legacyProperties, storageEndpointSuffix); policy.StorageEndpoint = legacyProperties.StorageEndpoint; policy.StorageAccountAccessKey = legacyProperties.StorageAccountAccessKey; } return(policy); }
/// <summary> /// Calls the set security alert APIs for the server security alert policy in the given resource group /// </summary> public void SetServerSecurityAlertPolicy(string resourceGroupName, string serverName, Management.Sql.Models.ServerSecurityAlertPolicy policyToSet) { GetCurrentSqlClient().ServerSecurityAlertPolicies.CreateOrUpdate(resourceGroupName, serverName, policyToSet); }