implementing-azure-defender-for-cloud
实施 Microsoft Defender for Cloud,为虚拟机、容器、数据库和存储启用云安全态势管理和工作负载保护,配置安全建议,并通过自动修复设置自适应安全控制。
Best use case
implementing-azure-defender-for-cloud is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
实施 Microsoft Defender for Cloud,为虚拟机、容器、数据库和存储启用云安全态势管理和工作负载保护,配置安全建议,并通过自动修复设置自适应安全控制。
Teams using implementing-azure-defender-for-cloud should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/implementing-azure-defender-for-cloud/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How implementing-azure-defender-for-cloud Compares
| Feature / Agent | implementing-azure-defender-for-cloud | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
实施 Microsoft Defender for Cloud,为虚拟机、容器、数据库和存储启用云安全态势管理和工作负载保护,配置安全建议,并通过自动修复设置自适应安全控制。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 实施 Azure Defender for Cloud
## 适用场景
- 跨 Azure 订阅启用全面安全监控时
- 为虚拟机(VM)、容器、SQL、存储和 Key Vault 实施云工作负载保护时
- 合规要求需要针对监管框架进行持续评估时
- 构建响应检测到的威胁的自适应安全控制时
- 集中来自 Azure 原生和混合工作负载的安全发现结果时
**不适用于**:仅针对非 Azure 工作负载的保护(使用 AWS Security Hub 或 GCP SCC)、应用级安全测试(使用 Azure DevOps DAST/SAST),或特定于身份的保护(使用 Microsoft Defender for Identity)。
## 前置条件
- 具有参与者(Contributor)或安全管理员(Security Admin)角色的 Azure 订阅
- 已启用 Azure Policy 用于合规评估
- 用于诊断数据收集的 Log Analytics 工作区
- 已通过 Azure Arc 连接混合服务器用于混合服务器保护
- Defender 计划的定价层已设置为标准版(Standard),免费版仅提供 CSPM)
## 工作流程
### 步骤 1:启用 Defender for Cloud 计划
为需要保护的每种工作负载类型启用相应的 Defender 计划。
```bash
# 启用 Defender for Cloud CSPM(基础态势管理)
az security pricing create --name CloudPosture --tier standard
# 启用 Defender for Servers
az security pricing create --name VirtualMachines --tier standard \
--subplan P2
# 启用 Defender for Containers
az security pricing create --name Containers --tier standard
# 启用 Defender for Storage
az security pricing create --name StorageAccounts --tier standard \
--subplan PerStorageAccount
# 启用 Defender for SQL
az security pricing create --name SqlServers --tier standard
# 启用 Defender for Key Vault
az security pricing create --name KeyVaults --tier standard
# 启用 Defender for App Service
az security pricing create --name AppServices --tier standard
# 验证所有已启用的计划
az security pricing list \
--query "[].{Plan:name, Tier:pricingTier, SubPlan:subPlan}" -o table
```
### 步骤 2:配置安全代理自动预置
启用监控代理到 VM 和容器的自动部署。
```bash
# 启用 Log Analytics 代理的自动预置
az security auto-provisioning-setting update \
--name default --auto-provision on
# 配置用于数据收集的 Log Analytics 工作区
az security workspace-setting create \
--name default \
--target-workspace "/subscriptions/SUB_ID/resourceGroups/RG/providers/Microsoft.OperationalInsights/workspaces/SecurityWorkspace"
# 启用 Defender for Containers 自动预置组件
az security setting update \
--name Sentinel \
--setting-kind DataExportSettings
# 验证自动预置状态
az security auto-provisioning-setting list -o table
```
### 步骤 3:审查并优先处理安全建议
获取安全建议,并根据安全评分影响确定修复优先级。
```bash
# 获取当前安全评分
az security secure-score list \
--query "[].{Name:displayName, Current:current, Max:max, Percentage:percentage}" -o table
# 列出所有活跃的安全建议
az security assessment list \
--query "[?status.code=='Unhealthy'].{Name:displayName, Severity:metadata.severity, Category:metadata.category, ResourceCount:status.cause}" \
-o table
# 按严重程度排序获取建议
az security assessment list \
--query "[?status.code=='Unhealthy'] | sort_by(@, &metadata.severity)" \
-o table
# 获取包含修复步骤的详细建议
az security assessment show \
--name ASSESSMENT_ID \
--query "{Name:displayName, Description:metadata.description, Severity:metadata.severity, Remediation:metadata.remediationDescription}"
# 按控制项列出建议
az security secure-score-controls list \
--query "[].{Control:displayName, CurrentScore:current, MaxScore:max, NotHealthy:notHealthyResourceCount}" \
-o table
```
### 步骤 4:配置合规仪表盘
启用合规标准并监控跨订阅的遵从情况。
```bash
# 列出可用的监管合规标准
az security regulatory-compliance-standards list \
--query "[].{Standard:name, State:state}" -o table
# 启用特定合规标准
az security regulatory-compliance-standards update \
--name "CIS-Azure-2.0" --state "Enabled"
az security regulatory-compliance-standards update \
--name "PCI-DSS-4.0" --state "Enabled"
az security regulatory-compliance-standards update \
--name "NIST-SP-800-53-R5" --state "Enabled"
# 获取特定标准的合规状态
az security regulatory-compliance-controls list \
--standard-name "CIS-Azure-2.0" \
--query "[].{Control:id, Description:displayName, State:state, PassedResources:passedResources, FailedResources:failedResources}" \
-o table
# 获取控制项的失败评估
az security regulatory-compliance-assessments list \
--standard-name "CIS-Azure-2.0" \
--control-name "2.1" \
--query "[?state=='Failed'].{Assessment:id, State:state}" -o table
```
### 步骤 5:设置安全告警和自动化
配置告警通知和自动响应工作流。
```bash
# 为告警通知创建安全联系人
az security contact create \
--name "SecurityTeam" \
--email "security-ops@company.com" \
--phone "+1-555-0199" \
--alert-notifications on \
--alerts-to-admins on
# 列出活跃安全告警
az security alert list \
--query "[?status=='Active'].{Name:alertDisplayName, Severity:severity, Time:timeGeneratedUtc, Status:status}" \
-o table
# 为高严重性告警创建工作流自动化(Logic App 触发器)
az security automation create \
--name "high-severity-alert-response" \
--resource-group "security-rg" \
--scopes "[{\"description\":\"完整订阅\",\"scopePath\":\"/subscriptions/SUB_ID\"}]" \
--sources "[{
\"eventSource\":\"Alerts\",
\"ruleSets\":[{
\"rules\":[{
\"propertyJPath\":\"Severity\",
\"propertyType\":\"String\",
\"expectedValue\":\"High\",
\"operator\":\"Equals\"
}]
}]
}]" \
--actions "[{
\"logicAppResourceId\":\"/subscriptions/SUB_ID/resourceGroups/security-rg/providers/Microsoft.Logic/workflows/alert-response\",
\"actionType\":\"LogicApp\"
}]"
```
### 步骤 6:实施自适应应用控制和 JIT 虚拟机访问
配置用于运行时安全的高级工作负载保护功能。
```bash
# 启用 Just-In-Time 虚拟机访问
az security jit-policy create \
--resource-group "production-rg" \
--name "jit-policy" \
--virtual-machines "[{
\"id\":\"/subscriptions/SUB_ID/resourceGroups/production-rg/providers/Microsoft.Compute/virtualMachines/web-server-01\",
\"ports\":[
{\"number\":22,\"protocol\":\"TCP\",\"allowedSourceAddressPrefix\":\"*\",\"maxRequestAccessDuration\":\"PT3H\"},
{\"number\":3389,\"protocol\":\"TCP\",\"allowedSourceAddressPrefix\":\"*\",\"maxRequestAccessDuration\":\"PT3H\"}
]
}]"
# 需要时申请 JIT 访问
az security jit-policy initiate \
--resource-group "production-rg" \
--name "jit-policy" \
--virtual-machines "[{
\"id\":\"VM_ID\",
\"ports\":[{\"number\":22,\"endTimeUtc\":\"2026-02-23T15:00:00Z\",\"allowedSourceAddressPrefix\":\"10.0.1.50\"}]
}]"
# 审查自适应应用控制建议
az security adaptive-application-controls list \
--query "[].{Group:displayName, Recommendation:recommendationAction, VMCount:vmRecommendations|length(@)}" \
-o table
```
## 核心概念
| 术语 | 定义 |
|------|------|
| Microsoft Defender for Cloud | Azure 原生安全平台,在 Azure、混合和多云环境中提供 CSPM(云安全态势管理)和 CWP(云工作负载保护) |
| 安全评分(Secure Score) | 基于已实施安全建议百分比的组织安全态势数值衡量指标 |
| 安全建议(Security Recommendation) | Defender for Cloud 提供的可操作指导,用于改善安全态势,按严重程度和安全评分影响排列优先级 |
| Defender 计划(Defender Plan) | 针对特定资源类型启用高级威胁检测的工作负载专用保护层(服务器、容器、SQL、存储等) |
| 实时虚拟机访问(Just-In-Time VM Access) | 默认阻止管理端口(SSH/RDP)并按需授予限时访问权限的功能,可降低攻击面 |
| 自适应应用控制(Adaptive Application Controls) | 基于机器学习的白名单机制,推荐哪些应用程序应允许在 VM 上运行 |
## 工具与系统
- **Microsoft Defender for Cloud**:具备 CSPM、CWP 和合规能力的中央安全平台
- **Azure Policy**:Defender for Cloud 用于评估和强制执行安全配置的治理服务
- **Log Analytics 工作区**:Defender 代理收集的安全遥测数据的后端数据存储
- **Azure Logic Apps**:由 Defender 告警触发的事件响应工作流自动化
- **Azure Arc**:将 Defender for Cloud 保护扩展到混合和多云服务器及 Kubernetes 集群
## 常见场景
### 场景:跨多订阅企业推广 Defender for Cloud
**场景背景**:一家拥有 20 个 Azure 订阅的企业需要启用具有服务器、容器和 SQL 保护的 Defender for Cloud,同时针对 CIS Azure 2.0 建立合规基线。
**方法**:
1. 使用 Azure Policy 计划在所有订阅中启用 CSPM 计划(CloudPosture)
2. 在生产订阅上启用 Defender for Servers P2、Containers 和 SQL
3. 配置自动预置,将 Log Analytics 代理部署到所有虚拟机
4. 启用 CIS Azure 2.0 和 PCI DSS 4.0 合规标准
5. 创建安全联系人,配置告警通知到 SOC 团队
6. 通过 Logic Apps 为高严重性告警设置工作流自动化
7. 为所有生产服务器启用 JIT 虚拟机访问,消除持久化 SSH/RDP 暴露
8. 为管理层创建每周安全评分报告
**常见陷阱**:Defender for Servers P2 按服务器每小时计费。对于拥有大量虚拟机的环境,成本可能快速增加。开发订阅使用 Defender for Servers P1,仅在生产环境使用 P2。代理自动预置可能与 SCCM 或其他工具管理的现有代理部署产生冲突。
## 输出格式
```
Microsoft Defender for Cloud 部署报告
=================================================
组织: Acme Corp
订阅数量: 20(12 个生产,8 个非生产)
部署日期: 2026-02-23
已启用的 DEFENDER 计划:
CloudPosture (CSPM): 20 / 20 个订阅
Servers P2: 12 / 20(仅生产)
Containers: 12 / 20(仅生产)
SQL: 12 / 20(仅生产)
Storage: 20 / 20 所有订阅
Key Vault: 20 / 20 所有订阅
安全评分:
当前: 62%(基线)
目标: 90 天内达到 80%
合规状态(CIS Azure 2.0):
合规控制项: 78 / 142(55%)
不合规控制项: 52 / 142
不适用: 12 / 142
建议:
严重: 8 条建议影响 34 个资源
高: 24 条建议影响 89 个资源
中: 56 条建议影响 234 个资源
低: 34 条建议影响 112 个资源
安全告警(过去 7 天):
高严重性: 3
中严重性: 12
低严重性: 28
```Related Skills
securing-kubernetes-on-cloud
本技能涵盖通过实施 Pod 安全标准(Pod Security Standards)、网络策略、工作负载身份、RBAC 权限控制、镜像准入控制和运行时安全监控,对 EKS、AKS 和 GKE 上的托管 Kubernetes 集群进行加固。涉及云平台特定安全功能,包括 EKS 的 IRSA、GKE 的工作负载身份(Workload Identity)以及 AKS 的托管身份(Managed Identity)。
performing-cloud-storage-forensic-acquisition
通过收集 API 远程数据和端点设备本地同步客户端制品,对 Google Drive、OneDrive、Dropbox 和 Box 等云存储服务执行取证获取和分析。
performing-cloud-penetration-testing
对 AWS、Azure 和 GCP 云环境执行授权渗透测试,识别 IAM 错误配置、暴露的存储桶、过度宽松的安全组、 无服务器函数漏洞以及从初始访问到账户沦陷的云特定攻击路径。测试人员使用云原生工具及 Pacu、 ScoutSuite 等专用框架枚举并利用云基础设施。适用于云渗透测试、AWS 安全评估、Azure 渗透测试 或云基础设施安全测试等请求场景。
performing-cloud-penetration-testing-with-pacu
使用开源 AWS 利用框架 Pacu 执行已授权的 AWS 渗透测试,枚举 IAM 配置、发现权限提升路径、测试凭据收集,并通过系统化的攻击模拟验证安全控制。
performing-cloud-native-forensics-with-falco
使用 Falco YAML 规则在容器和 Kubernetes 中进行运行时威胁检测,监控系统调用以检测 shell 生成、文件篡改、网络异常和权限提升。通过 Falco gRPC API 管理 Falco 规则并解析 Falco 告警输出。适用于构建容器运行时安全或调查 k8s 集群入侵。
performing-cloud-incident-containment-procedures
在 AWS、Azure 和 GCP 中执行云原生事件遏制,包括隔离受攻陷资源、撤销凭据、保全取证证据,以及应用安全组限制以防止横向移动。
performing-cloud-forensics-with-aws-cloudtrail
使用 CloudTrail 日志对 AWS 环境执行取证调查,重建攻击者活动、识别受损凭据并分析 API 调用模式。
performing-cloud-forensics-investigation
通过收集和分析来自 AWS、Azure 和 GCP 服务的日志、快照和元数据,在云环境中开展取证调查。
performing-cloud-asset-inventory-with-cartography
使用 Cartography 执行全面的云资产清单和关系映射,在 AWS、GCP 和 Azure 中构建包含基础设施资产、IAM 权限和攻击路径的 Neo4j 安全图谱。
managing-cloud-identity-with-okta
本技能涵盖将 Okta 部署为云环境集中身份提供商,配置与 AWS、Azure 和 GCP 的 SSO 集成,使用 Okta FastPass 部署抗钓鱼 MFA,管理用户预配置和取消配置的生命周期自动化,以及基于设备态势和风险信号实施自适应访问策略。
implementing-zero-trust-with-hashicorp-boundary
使用 HashiCorp Boundary 实现具备动态凭据代理、会话录制和 Vault 集成的身份感知零信任基础设施访问管理。
implementing-zero-trust-with-beyondcorp
使用身份感知代理(IAP,Identity-Aware Proxy)、上下文感知访问策略、设备信任验证和 Access Context Manager,部署 Google BeyondCorp Enterprise 零信任访问控制,对 GCP 资源和内部应用强制执行基于身份和安全态势的访问。