How do I configure Azure Security Center Policies with the Azure Portal or Powershell?

To configure Azure Security Center policies, you can use either the Azure portal or Azure PowerShell. Here are the general steps:

Using Azure Portal:

  1. Sign in to the Azure portal and navigate to the Security Center.
  2. Select the “Security policy” blade.
  3. Click on “Add” to create a new policy or select an existing policy to edit.
  4. Choose a scope for the policy, which can be a subscription, a resource group, or a specific resource.
  5. Select the controls that you want to enforce for the policy, such as malware protection, network security, and vulnerability assessments.
  6. Configure the settings for each control, such as the severity level and the action to take if a violation is detected.
  7. Save the policy.

Using Azure PowerShell:

  1. Open Azure PowerShell and connect to your Azure account using the “Connect-AzAccount” cmdlet.
  2. Select the subscription that you want to configure the policy for using the “Select-AzSubscription” cmdlet.
  3. Create a new policy or get an existing policy using the “New-AzSecurityPolicy” or “Get-AzSecurityPolicy” cmdlets.
  4. Set the scope of the policy using the “Set-AzSecurityPolicy” cmdlet.
  5. Configure the controls for the policy using the “Set-AzSecurityPolicyRule” cmdlet.
  6. Set the severity level and the action to take if a violation is detected for each control using the “Set-AzSecurityPolicyRule” cmdlet.
  7. Save the policy using the “Set-AzSecurityPolicy” cmdlet.

Here is an example of using Azure PowerShell to configure a security policy:





# Connect to Azure
Connect-AzAccount

# Select the subscription
Select-AzSubscription -SubscriptionName "My Subscription"

# Create a new policy
$policy = New-AzSecurityPolicy -Name "My Policy" -Mode Default

# Set the scope of the policy
Set-AzSecurityPolicy -Policy $policy -Scope "/subscriptions/MySubscription/resourceGroups/MyResourceGroup"

# Configure the controls for the policy
Set-AzSecurityPolicyRule -Policy $policy -Name "MalwareProtection" -Severity High -Enabled $true -Action "Alert"
Set-AzSecurityPolicyRule -Policy $policy -Name "NetworkSecurity" -Severity Medium -Enabled $true -Action "Alert"
Set-AzSecurityPolicyRule -Policy $policy -Name "VulnerabilityAssessment" -Severity High -Enabled $true -Action "Alert"

# Save the policy
Set-AzSecurityPolicy -Policy $policy
Author: tonyhughes