Task 05: Security & Compliance Validation
DOCUMENT CATEGORY: Runbook
SCOPE: Security and compliance validation
PURPOSE: Validate security posture and compliance configuration
MASTER REFERENCE: Microsoft Learn - Security for Azure Local
Status: Active
Overview
This step validates the security configuration of the Azure Local cluster including Defender for Cloud integration, RBAC assignments, encryption settings, and compliance with security policies.
Prerequisites
- Infrastructure health validation completed (Step 1)
- Azure CLI installed and authenticated
- Access to Azure portal with Security Reader role
- Local administrator access to cluster nodes
Report Output
All validation results are saved to:
\\<ClusterName>\ClusterStorage$\Collect\validation-reports\05-security-compliance-report-YYYYMMDD.txt
Values from infrastructure.yml
The values for this task come from infrastructure.yml (schema 5). Every key, with its type, default and example, is in the variables reference.
Part 1: Initialize Validation
1.1 Setup Environment
# Initialize variables
$ClusterName = (Get-Cluster).Name
$DateStamp = Get-Date -Format "yyyyMMdd"
$ReportPath = "C:\ClusterStorage\Collect\validation-reports"
$ReportFile = "$ReportPath\05-security-compliance-report-$DateStamp.txt"
# Azure context
$SubscriptionId = (az account show --query id -o tsv)
$ResourceGroup = "<ResourceGroupName>" # Replace with actual RG
# Initialize report
$ReportHeader = @"
================================================================================
SECURITY & COMPLIANCE VALIDATION REPORT
================================================================================
Cluster: $ClusterName
Subscription: $SubscriptionId
Date: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")
Generated By: $(whoami)
================================================================================
"@
$ReportHeader | Out-File -FilePath $ReportFile -Encoding UTF8
Part 2: Defender for Cloud Validation
2.1 Check Defender for Cloud Status
"`n" + "="*80 | Add-Content $ReportFile
"MICROSOFT DEFENDER FOR CLOUD" | Add-Content $ReportFile
"="*80 | Add-Content $ReportFile
# The free level Azure Local needs: Foundational CSPM (the Microsoft.Security provider is registered)
# and the Microsoft cloud security benchmark assigned to the subscription. No paid plan is expected.
$SecurityProvider = az provider show --namespace Microsoft.Security --query "registrationState" -o tsv
$BenchmarkId = "/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"
$Benchmark = az policy assignment list --query "[?policyDefinitionId=='$BenchmarkId'].name" -o tsv
"Defender for Cloud (free level):" | Add-Content $ReportFile
" Foundational CSPM: $(if ($SecurityProvider -eq 'Registered') { 'On' } else { 'Off' })" | Add-Content $ReportFile
" Microsoft cloud security benchmark: $(if ($Benchmark) { 'Assigned' } else { 'Not assigned' })" | Add-Content $ReportFile
2.2 Get Secure Score
# Get secure score for subscription
$SecureScore = az security secure-score list --query "[0]" -o json | ConvertFrom-Json
"`nSecure Score:" | Add-Content $ReportFile
" Current Score: $($SecureScore.current)" | Add-Content $ReportFile
" Maximum Score: $($SecureScore.max)" | Add-Content $ReportFile
" Percentage: $([math]::Round(($SecureScore.current / $SecureScore.max) * 100, 1))%" | Add-Content $ReportFile
$ScoreStatus = if ($SecureScore.current / $SecureScore.max -ge 0.8) { "PASS" } else { "NEEDS IMPROVEMENT" }
" Status: $ScoreStatus" | Add-Content $ReportFile
2.3 Get Security Recommendations
# Get high-severity recommendations
$Recommendations = az security assessment list --query "[?status.code=='Unhealthy' && metadata.severity=='High']" -o json | ConvertFrom-Json
"`nHigh-Severity Security Recommendations:" | Add-Content $ReportFile
if ($Recommendations.Count -eq 0) {
" No high-severity recommendations - EXCELLENT" | Add-Content $ReportFile
} else {
foreach ($Rec in $Recommendations | Select-Object -First 10) {
" - $($Rec.displayName)" | Add-Content $ReportFile
" Status: $($Rec.status.code)" | Add-Content $ReportFile
}
" Total High-Severity: $($Recommendations.Count)" | Add-Content $ReportFile
}
# Get medium-severity count
$MediumRecs = az security assessment list --query "[?status.code=='Unhealthy' && metadata.severity=='Medium']" -o json | ConvertFrom-Json
" Medium-Severity Count: $($MediumRecs.Count)" | Add-Content $ReportFile
Part 3: RBAC Validation
3.1 Verify Cluster RBAC Assignments
"`n" + "="*80 | Add-Content $ReportFile
"ROLE-BASED ACCESS CONTROL (RBAC)" | Add-Content $ReportFile
"="*80 | Add-Content $ReportFile
# Get Azure Local resource ID
$ClusterResource = az resource list --resource-type "Microsoft.AzureStackHCI/clusters" --query "[?name=='$ClusterName']" -o json | ConvertFrom-Json
$ClusterResourceId = $ClusterResource.id
# List role assignments on cluster
$RoleAssignments = az role assignment list --scope $ClusterResourceId -o json | ConvertFrom-Json
"`nRole Assignments on Cluster:" | Add-Content $ReportFile
$RoleAssignments | ForEach-Object {
" Principal: $($_.principalName)" | Add-Content $ReportFile
" Role: $($_.roleDefinitionName)" | Add-Content $ReportFile
" Scope: $($_.scope)" | Add-Content $ReportFile
" ---" | Add-Content $ReportFile
}
3.2 Verify Required Roles
# Define required roles for Azure Local Cloud operations
$RequiredRoles = @(
@{Role="Owner"; PrincipalType="Group"; Description="Azure Local Cloud Admin Group"},
@{Role="Contributor"; PrincipalType="ServicePrincipal"; Description="Deployment SPN"},
@{Role="Reader"; PrincipalType="Group"; Description="Azure Local Cloud Operations Group"}
)
"`nRequired Role Verification:" | Add-Content $ReportFile
foreach ($Required in $RequiredRoles) {
$Found = $RoleAssignments | Where-Object { $_.roleDefinitionName -eq $Required.Role }
$Status = if ($Found) { "CONFIGURED" } else { "MISSING" }
" $($Required.Role) ($($Required.Description)): $Status" | Add-Content $ReportFile
}
3.3 Verify Local Administrator Groups
"`nLocal Administrator Groups on Nodes:" | Add-Content $ReportFile
foreach ($Node in $Nodes) {
$LocalAdmins = Invoke-Command -ComputerName $Node -ScriptBlock {
Get-LocalGroupMember -Group "Administrators" |
Select-Object Name, ObjectClass, PrincipalSource
}
"`n$Node Administrators:" | Add-Content $ReportFile
$LocalAdmins | ForEach-Object {
" - $($_.Name) ($($_.ObjectClass))" | Add-Content $ReportFile
}
}
Part 4: Encryption Validation
4.1 BitLocker Status
"`n" + "="*80 | Add-Content $ReportFile
"ENCRYPTION CONFIGURATION" | Add-Content $ReportFile
"="*80 | Add-Content $ReportFile
"`nBitLocker Status on Cluster Nodes:" | Add-Content $ReportFile
foreach ($Node in $Nodes) {
$BitLockerStatus = Invoke-Command -ComputerName $Node -ScriptBlock {
Get-BitLockerVolume | Select-Object MountPoint, VolumeStatus, ProtectionStatus, EncryptionPercentage
}
"`n$Node :" | Add-Content $ReportFile
$BitLockerStatus | ForEach-Object {
" $($_.MountPoint): $($_.VolumeStatus) - Protection: $($_.ProtectionStatus) ($($_.EncryptionPercentage)%)" | Add-Content $ReportFile
}
}
4.2 SMB Encryption
"`nSMB Encryption Settings:" | Add-Content $ReportFile
$SmbConfig = Get-SmbServerConfiguration | Select-Object EncryptData, RejectUnencryptedAccess
" Encrypt Data: $($SmbConfig.EncryptData)" | Add-Content $ReportFile
" Reject Unencrypted: $($SmbConfig.RejectUnencryptedAccess)" | Add-Content $ReportFile
# Check SMB share encryption
$SmbShares = Get-SmbShare | Where-Object { $_.Name -notlike "*$" } | Select-Object Name, EncryptData
"`nSMB Share Encryption:" | Add-Content $ReportFile
$SmbShares | ForEach-Object {
" $($_.Name): EncryptData = $($_.EncryptData)" | Add-Content $ReportFile
}
4.3 TLS Configuration
"`nTLS Configuration:" | Add-Content $ReportFile
foreach ($Node in $Nodes) {
$TLSStatus = Invoke-Command -ComputerName $Node -ScriptBlock {
# Check TLS 1.2 is enabled
$TLS12Client = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" -ErrorAction SilentlyContinue
$TLS12Server = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server" -ErrorAction SilentlyContinue
# Check TLS 1.0/1.1 are disabled
$TLS10 = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server" -ErrorAction SilentlyContinue
$TLS11 = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server" -ErrorAction SilentlyContinue
[PSCustomObject]@{
TLS12Enabled = ($TLS12Server.Enabled -eq 1 -or $TLS12Server.Enabled -eq $null)
TLS10Disabled = ($TLS10.Enabled -eq 0)
TLS11Disabled = ($TLS11.Enabled -eq 0)
}
}
"$Node : TLS 1.2 Enabled = $($TLSStatus.TLS12Enabled)" | Add-Content $ReportFile
}
Part 5: Windows Security Baseline
5.1 Windows Firewall Status
"`n" + "="*80 | Add-Content $ReportFile
"WINDOWS SECURITY BASELINE" | Add-Content $ReportFile
"="*80 | Add-Content $ReportFile
"`nWindows Firewall Status:" | Add-Content $ReportFile
foreach ($Node in $Nodes) {
$FirewallProfiles = Invoke-Command -ComputerName $Node -ScriptBlock {
Get-NetFirewallProfile | Select-Object Name, Enabled
}
"$Node :" | Add-Content $ReportFile
$FirewallProfiles | ForEach-Object {
" $($_.Name) Profile: $(if($_.Enabled){'Enabled'}else{'DISABLED'})" | Add-Content $ReportFile
}
}
5.2 Antivirus Status
"`nWindows Defender Antivirus Status:" | Add-Content $ReportFile
foreach ($Node in $Nodes) {
$AVStatus = Invoke-Command -ComputerName $Node -ScriptBlock {
$MPStatus = Get-MpComputerStatus
[PSCustomObject]@{
AMServiceEnabled = $MPStatus.AMServiceEnabled
RealTimeProtection = $MPStatus.RealTimeProtectionEnabled
SignatureAge = $MPStatus.AntivirusSignatureAge
LastQuickScan = $MPStatus.QuickScanEndTime
}
}
"$Node :" | Add-Content $ReportFile
" Service Enabled: $($AVStatus.AMServiceEnabled)" | Add-Content $ReportFile
" Real-Time Protection: $($AVStatus.RealTimeProtection)" | Add-Content $ReportFile
" Signature Age (days): $($AVStatus.SignatureAge)" | Add-Content $ReportFile
" Last Quick Scan: $($AVStatus.LastQuickScan)" | Add-Content $ReportFile
}
5.3 Audit Policy
"`nSecurity Audit Policy:" | Add-Content $ReportFile
$AuditPolicy = auditpol /get /category:* | Where-Object { $_ -match "Success|Failure" }
$AuditPolicy | Select-Object -First 20 | ForEach-Object {
" $_" | Add-Content $ReportFile
}
Part 6: Azure Policy Compliance
6.1 Check Policy Compliance State
"`n" + "="*80 | Add-Content $ReportFile
"AZURE POLICY COMPLIANCE" | Add-Content $ReportFile
"="*80 | Add-Content $ReportFile
# Get policy compliance state for resource group
$PolicyStates = az policy state list --resource-group $ResourceGroup --query "[?complianceState=='NonCompliant']" -o json | ConvertFrom-Json
"`nNon-Compliant Policy Assignments:" | Add-Content $ReportFile
if ($PolicyStates.Count -eq 0) {
" All policies compliant - EXCELLENT" | Add-Content $ReportFile
} else {
foreach ($State in $PolicyStates | Select-Object -First 10) {
" - Policy: $($State.policyDefinitionName)" | Add-Content $ReportFile
" Resource: $($State.resourceId)" | Add-Content $ReportFile
" Compliance: $($State.complianceState)" | Add-Content $ReportFile
}
" Total Non-Compliant: $($PolicyStates.Count)" | Add-Content $ReportFile
}
6.2 Verify Required Policies
# Check for Azure Local Cloud required policies
$RequiredPolicies = @(
"Azure Local clusters should have encryption at host enabled",
"Azure Local clusters should have secure boot enabled"
)
"`nRequired Policy Status:" | Add-Content $ReportFile
foreach ($Policy in $RequiredPolicies) {
$PolicyState = az policy state list --resource-group $ResourceGroup --filter "policyDefinitionName eq '$Policy'" -o json 2>$null | ConvertFrom-Json
if ($PolicyState) {
$Status = $PolicyState[0].complianceState
" $Policy : $Status" | Add-Content $ReportFile
} else {
" $Policy : NOT ASSIGNED" | Add-Content $ReportFile
}
}
Part 7: Generate Summary
$ScorePercent = [math]::Round(($SecureScore.current / $SecureScore.max) * 100, 1)
$Summary = @"
================================================================================
SECURITY & COMPLIANCE VALIDATION SUMMARY
================================================================================
DEFENDER FOR CLOUD:
Secure Score: $ScorePercent%
High-Severity Issues: $($Recommendations.Count)
Medium-Severity Issues: $($MediumRecs.Count)
Status: $(if($ScorePercent -ge 80){"PASS"}else{"NEEDS IMPROVEMENT"})
RBAC CONFIGURATION:
Role Assignments: $($RoleAssignments.Count)
Status: REVIEW REQUIRED
ENCRYPTION:
BitLocker: Verify in report
SMB Encryption: $($SmbConfig.EncryptData)
TLS 1.2: Enabled
WINDOWS SECURITY:
Firewall: Enabled
Defender AV: Active
Audit Policy: Configured
AZURE POLICY:
Non-Compliant Items: $($PolicyStates.Count)
Status: $(if($PolicyStates.Count -eq 0){"COMPLIANT"}else{"REVIEW REQUIRED"})
OVERALL SECURITY POSTURE: $(if($ScorePercent -ge 80 -and $Recommendations.Count -eq 0){"GOOD"}else{"NEEDS ATTENTION"})
================================================================================
Report saved to: $ReportFile
================================================================================
"@
$Summary | Add-Content $ReportFile
Write-Host $Summary
Validation Checklist
| Category | Requirement | Status |
|---|---|---|
| Defender | Secure score ≥ 80% | ☐ |
| Defender | No high-severity recommendations | ☐ |
| Defender | Foundational CSPM on and Microsoft cloud security benchmark assigned | ☐ |
| RBAC | Required roles assigned | ☐ |
| RBAC | No excessive permissions | ☐ |
| Encryption | BitLocker enabled on OS drives | ☐ |
| Encryption | SMB encryption configured | ☐ |
| Encryption | TLS 1.2 enabled, legacy disabled | ☐ |
| Firewall | All profiles enabled | ☐ |
| Antivirus | Real-time protection active | ☐ |
| Antivirus | Signatures ≤ 7 days old | ☐ |
| Policy | All required policies compliant | ☐ |
Common Remediation Actions
Improve Secure Score
# Apply security recommendations via Azure portal:
# Azure Portal → Defender for Cloud → Recommendations → Apply
Enable BitLocker
# Enable BitLocker on cluster volumes
Enable-BitLocker -MountPoint "C:" -EncryptionMethod XtsAes256 -RecoveryPasswordProtector
Update Antivirus Signatures
# Force signature update
Update-MpSignature -UpdateSource MicrosoftUpdateServer
Troubleshooting
| Issue | Cause | Resolution |
|---|---|---|
| Secure score shows 0% or no data | The free level of Defender for Cloud is not on, or the first evaluation is pending | Do Task 01: Enable Defender for Cloud; wait 24 hours for the first evaluation |
| BitLocker encryption fails | TPM not available or not initialized | Verify TPM: Get-Tpm; initialize if needed: Initialize-Tpm; retry BitLocker enablement |
| Policy compliance shows unknown state | Azure Monitor Agent not reporting or DCR misconfigured | Verify AMA health: az connectedmachine extension list; check DCR associations are correct |
Next Step
Proceed to Task 6: Backup & DR Validation once security validation is complete.
- Manual
- Orchestrated Script
- Azure CLI
When to use: Use this option for manual step-by-step execution.
See procedure steps above for manual execution guidance.
PowerShell
When to use: Run the task with the script below, from the place its help names (a management workstation, or the node itself).
Script
| Script | What it does |
|---|---|
scripts/deploy/06-testing-validation/task-05-security-compliance-validation/powershell/Test-SecurityCompliance.ps1 | Validates security configuration and compliance posture. |
Requires: PowerShell 7; -Module Az.Accounts; -Module Az.Resources.
Run
./Test-SecurityCompliance.ps1 -InfrastructureFile ./infrastructure.yml
Azure CLI
When to use: Check the task from a host that has the Azure CLI and not the Az PowerShell modules. The script is PowerShell 7 that calls
azand only reads Azure.
Script
| Script | What it does |
|---|---|
scripts/deploy/06-testing-validation/task-05-security-compliance-validation/azurecli/Test-SecurityCompliance.azcli.ps1 | Validates the Azure side of the security and compliance posture with the Azure CLI. Read only. |
Requires: PowerShell 7 and the Azure CLI, signed in with az login --tenant <azure.tenant_id>.
It checks the free level of Defender for Cloud (the Microsoft.Security provider and the Microsoft cloud security benchmark assignment), the role assignments on the resource group (a warning when there are more Owner assignments than -MaximumOwnerAssignments, default 3), and the Azure Policy compliance state of the resource group. -OutputPath names a folder for a JSON report. The checks that run on the nodes (BitLocker, Microsoft Defender Antivirus, audit policy) stay with the PowerShell script.
Run
./Test-SecurityCompliance.azcli.ps1 -InfrastructureFile ./infrastructure.yml
Scripts for this task are located in the azurelocal-toolkit repository under scripts/deploy/ in the appropriate task folder.
Alternatives
The procedures in this task use the methods shown in the tabs above. The toolkit is PowerShell 7 only and has no Bash scripts. A few tasks that act on Azure also have an Azure CLI script written in PowerShell. The script status page of the toolkit lists which task has which script.
Navigation
| Previous | Up | Next |
|---|---|---|
| ← Task 4: High Availability Testing | Testing & Validation | Task 6: Backup & DR Validation → |
Version Control
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0.0 | 2026-03-24 | Azure Local Cloud | Initial release |