public override void ExecuteCmdlet() { if (this.IsParameterBound(c => c.InputObject)) { var resourceIdentifier = new ResourceIdentifier(this.InputObject.Id); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.WorkspaceName = this.InputObject.Name; } if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.WorkspaceName = resourceIdentifier.ResourceName; } if (string.IsNullOrEmpty(this.ResourceGroupName)) { this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName); } var policy = SynapseAnalyticsClient.GetWorkspaceThreatDetectionPolicy(this.ResourceGroupName, this.WorkspaceName); var result = new WorkspaceAdvancedDataSecurityPolicy { ResourceGroupName = this.ResourceGroupName, WorkspaceName = this.WorkspaceName, IsEnabled = policy.State == SecurityAlertPolicyState.Enabled }; WriteObject(result); }
public override void ExecuteCmdlet() { if (this.IsParameterBound(c => c.InputObject)) { var resourceIdentifier = new ResourceIdentifier(this.InputObject.Id); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.WorkspaceName = this.InputObject.Name; } if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.WorkspaceName = resourceIdentifier.ResourceName; } if (string.IsNullOrEmpty(this.ResourceGroupName)) { this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName); } if (this.ShouldProcess(this.WorkspaceName, string.Format(Resources.EnablingAdvancedDataSecurity, this.WorkspaceName))) { var policy = SynapseAnalyticsClient.GetWorkspaceThreatDetectionPolicy(this.ResourceGroupName, this.WorkspaceName); policy.State = SecurityAlertPolicyState.Enabled; if (!string.IsNullOrEmpty(policy.StorageEndpoint)) { policy.StorageAccountAccessKey = SynapseAnalyticsClient.GetStorageKeys(policy.StorageEndpoint)[StorageKeyKind.Primary]; } else { policy.StorageEndpoint = null; } SynapseAnalyticsClient.SetWorkspaceThreatDetectionPolicy(this.ResourceGroupName, this.WorkspaceName, policy); if (!DoNotConfigureVulnerabilityAssessment) { // Deploy arm template to enable VA - only if VA at server level is not defined var workspaceVa = SynapseAnalyticsClient.GetWorkspaceVulnerabilityAssessmentSettings(this.ResourceGroupName, this.WorkspaceName); if (string.IsNullOrEmpty(workspaceVa.StorageContainerPath)) { if (this.IsParameterBound(c => c.InputObject)) { SynapseAnalyticsClient.EnableWorkspaceVa(this.ResourceGroupName, this.WorkspaceName, this.InputObject.Location, this.DeploymentName); } else { var workspace = SynapseAnalyticsClient.GetWorkspace(this.ResourceGroupName, this.WorkspaceName); SynapseAnalyticsClient.EnableWorkspaceVa(this.ResourceGroupName, this.WorkspaceName, workspace.Location, this.DeploymentName); } } } var result = new WorkspaceAdvancedDataSecurityPolicy() { ResourceGroupName = this.ResourceGroupName, WorkspaceName = this.WorkspaceName, IsEnabled = true }; WriteObject(result); } }