Skip to content

Commit 023ca93

Browse files
authored
Merge pull request #23 from MicrosoftCloudEssentials-LearningHub/defender
Defender added to the template
2 parents 73110d8 + ae2c49d commit 023ca93

11 files changed

Lines changed: 639 additions & 137 deletions

File tree

.github/dependabot.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 2
2+
3+
# Note: Dependabot schedule only supports: daily | weekly | monthly.
4+
5+
updates:
6+
# Root python dependencies (if used)
7+
- package-ecosystem: "pip"
8+
directory: "/"
9+
schedule:
10+
# interval: "weekly" # higher frequency
11+
interval: "monthly" # lowest supported frequency
12+
open-pull-requests-limit: 5
13+
14+
# App dependencies
15+
- package-ecosystem: "pip"
16+
directory: "/src"
17+
schedule:
18+
# interval: "weekly"
19+
interval: "monthly"
20+
open-pull-requests-limit: 5
21+
22+
# A2A server dependencies
23+
- package-ecosystem: "pip"
24+
directory: "/src/a2a"
25+
schedule:
26+
# interval: "weekly"
27+
interval: "monthly"
28+
open-pull-requests-limit: 5
29+
30+
# Terraform provider updates
31+
- package-ecosystem: "terraform"
32+
directory: "/terraform-infrastructure"
33+
schedule:
34+
# interval: "weekly"
35+
interval: "monthly"
36+
open-pull-requests-limit: 5

.github/workflows/codeql.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
# schedule:
9+
# - cron: "35 2 * * 1" # weekly
10+
11+
permissions:
12+
contents: read
13+
security-events: write
14+
15+
jobs:
16+
analyze:
17+
name: Analyze (Python)
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: ["python"]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v3
31+
with:
32+
languages: ${{ matrix.language }}
33+
34+
- name: Autobuild
35+
uses: github/codeql-action/autobuild@v3
36+
37+
- name: Perform CodeQL Analysis
38+
uses: github/codeql-action/analyze@v3
39+
with:
40+
category: "/language:${{ matrix.language }}"

README.md

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Costa Rica
55
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
66
[brown9804](https://github.com/brown9804)
77

8-
Last updated: 2026-03-13
8+
Last updated: 2026-03-19
99

1010
----------
1111

@@ -16,6 +16,24 @@ Last updated: 2026-03-13
1616
<summary><b>List of References</b> (Click to expand)</summary>
1717

1818
- [Microsoft Foundry SDKs and Endpoints](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/develop/sdk-overview?view=foundry&pivots=programming-language-python)
19+
- Microsoft Defender for Cloud (DevOps security):
20+
- [Connect GitHub to Defender for Cloud](https://learn.microsoft.com/azure/defender-for-cloud/quickstart-onboard-github)
21+
- [Connect Azure DevOps to Defender for Cloud](https://learn.microsoft.com/azure/defender-for-cloud/quickstart-onboard-devops)
22+
- [DevOps security permissions and prerequisites](https://learn.microsoft.com/azure/defender-for-cloud/devops-support)
23+
24+
</details>
25+
26+
<details>
27+
<summary><b>Table of Content</b> (Click to expand)</summary>
28+
29+
- [Deployment Approaches (pick one)](#deployment-approaches-pick-one)
30+
- [Key Features](#key-features)
31+
- [More Security with Microsoft Defender](#more-security-with-microsoft-defender)
32+
- [If the Azure portal blade errors](#if-the-azure-portal-blade-errors)
33+
- [About A2A Protocol](#about-a2a-protocol)
34+
- [Architecture](#architecture)
35+
- [What Happens Under the Hood](#what-happens-under-the-hood)
36+
- [Verification](#verification)
1937

2038
</details>
2139

@@ -28,10 +46,21 @@ Last updated: 2026-03-13
2846
> [!IMPORTANT]
2947
> The deployment process typically takes 15-20 minutes
3048
>
31-
> 1. Adjust [terraform.tfvars](./terraform-infrastructure/terraform.tfvars) values
49+
> 1. Pick a deployment approach (Container Apps or App Service)
50+
> 2. Adjust [terraform.tfvars](./terraform-infrastructure/terraform.tfvars) values
3251
> 2. Initialize terraform with `terraform init`. Click here to [understand more about the deployment process](./terraform-infrastructure/README.md)
3352
> 3. Run `terraform apply`, you can also leverage `terraform apply -auto-approve`.
3453
54+
## Deployment Approaches (pick one)
55+
56+
- **Container Apps (recommended default in this repo)**
57+
- In `terraform-infrastructure/terraform.tfvars`: set `deployment_target = "containerapps"`
58+
- Run: `cd terraform-infrastructure` then `terraform apply -var-file terraform.tfvars`
59+
60+
- **App Service (Linux custom container)**
61+
- In `terraform-infrastructure/terraform.tfvars`: set `deployment_target = "appservice"` and choose `app_service_sku` (e.g. `P0v3`)
62+
- Run: `cd terraform-infrastructure` then `terraform apply -var-file terraform.tfvars`
63+
3564
## Key Features
3665

3766
- **Multi-agent chat orchestration (default runtime)**: WebSocket `/ws` chat app orchestrates multiple agents in a single conversation flow (routing + multi-step handoffs)
@@ -49,11 +78,52 @@ Last updated: 2026-03-13
4978
- **UI-visible diagnostics**: Correlated `error_id` responses and optional tracebacks via `A2A_DEBUG=true` for faster troubleshooting
5079
- **Optional A2A server included**: `src/a2a/` contains an A2A-style server framework, but it is not the default Container Apps entrypoint unless you deploy it explicitly
5180

52-
## About A2A Protocol
81+
> [!NOTE]
82+
> Visibility-first rollout (recommended for demos):
83+
>
84+
> - Onboard **GitHub connector only** first to validate the Defender dashboards/workbooks.
85+
> - Onboard **Azure DevOps connector** only in a **sandbox org/project**.
86+
> - Keep **PR annotations OFF** initially (no write-back to PRs) until you decide to enable them.
87+
88+
## More Security with Microsoft Defender
5389

54-
`A2A (Agent-to-Agent) Protocol is a standardized communication framework that enables multiple AI agents to collaborate and coordinate tasks seamlessly.` Like a communication pattern for coordinating multiple agents through structured messages, delegation, and (optionally) event-driven workflows.
90+
> [!IMPORTANT]
91+
> **Defender is enabled by default in this repo's Terraform defaults.** This can incur Azure costs (Defender plans) and will provision DevOps security connector resources that still require a one-time interactive authorization step for GitHub/Azure DevOps.
92+
> To opt out, explicitly set the related variables to `false` in [terraform-infrastructure/terraform.tfvars](terraform-infrastructure/terraform.tfvars).
93+
94+
This repo supports two complementary “Defender” scenarios:
95+
96+
1. **Microsoft Defender for Cloud (workload protection / cloud posture)**
97+
- This repo includes an opt-in Terraform configuration to enable Defender for Cloud plans at the subscription scope.
98+
- Toggle via `enable_defender_for_cloud` in [terraform-infrastructure/terraform.tfvars](terraform-infrastructure/terraform.tfvars) (or the example `tfvars` files above).
99+
- Note: enabling Defender plans can incur Azure costs.
100+
101+
2. **Defender for Cloud DevOps Security (GHAS / ADO aggregation & reporting)**
102+
- This repo can provision the **connector resources** via Terraform, but onboarding still requires **interactive authorization** to GitHub and/or Azure DevOps in the Azure portal (or providing a one-time OAuth code).
103+
- This is the feature area that provides the “central dashboard” experience for GHAS-like findings (code scanning, dependency, secrets) across **organizations/projects** (not just individual repos).
104+
- It can optionally add **Pull Request annotations** (a write-back action) but only when you explicitly enable/configure that feature.
105+
106+
> [!NOTE]
107+
> Opt out (disable Defender): In [terraform-infrastructure/terraform.tfvars](terraform-infrastructure/terraform.tfvars), set:
108+
>
109+
> - `enable_defender_for_cloud = false`
110+
> - `enable_defender_devops_security = false`
111+
112+
### If the Azure portal blade errors
113+
114+
> If the Azure portal **Defender for Cloud → Environment settings** page fails to load with an error like: `ECS feature flags for project 'Defenders' are not initialized (ErrorAcquiringViewModel)`. Use one of these workarounds:
115+
116+
- **Open the connector resource directly** (bypasses the Environment Settings blade):
117+
- Find the connector resource IDs from Terraform outputs (look for `defender_devops_security_connector_ids`).
118+
- Open in the portal using this pattern:
119+
- `https://portal.azure.com/#resource/<connector-resource-id>/overview`
120+
- Example: `.../providers/Microsoft.Security/securityConnectors/github-connector`
121+
- **List the connector IDs via CLI** (then open them with the URL above): `az resource list -g <rg-name> --resource-type Microsoft.Security/securityConnectors -o table`
122+
- **Browser reset**: try InPrivate/Incognito, disable extensions (ad blockers), and sign out/in.
123+
124+
## About A2A Protocol
55125

56-
This repo contains **two multi-agent implementations**:
126+
`A2A (Agent-to-Agent) Protocol is a standardized communication framework that enables multiple AI agents to collaborate and coordinate tasks seamlessly.` Like a communication pattern for coordinating multiple agents through structured messages, delegation, and (optionally) event-driven workflows. This repo contains **two multi-agent implementations**:
57127

58128
- **Default deployed chat runtime (what the Dockerfile runs)**: WebSocket `/ws` in `src/chat_app_multi_agent.py`, which routes requests and orchestrates **real Azure AI Foundry Agents** in a multi-step handoff sequence.
59129
- **Optional A2A server implementation**: an A2A-style server under `src/a2a/` (routers, coordinator, event/task framework). Use this only if you deploy/run that entrypoint.
@@ -87,7 +157,7 @@ This repo contains **two multi-agent implementations**:
87157
- **Product catalog helper/plugin (if used)**: `src/app/agents/product_information_plugin.py`
88158

89159
> [!IMPORTANT]
90-
> A2A vs the default deployed chat runtime
160+
> A2A vs the default deployed chat runtime:
91161
>
92162
> - **A2A server path**: event/task oriented framework under `src/a2a/` (only available if you deploy/run that server)
93163
> - **Default path**: `/ws` WebSocket chat + routing + sequential handoffs to real Foundry agents (no event queue required for the default flow)
@@ -229,7 +299,7 @@ graph TD
229299
230300
<!-- START BADGE -->
231301
<div align="center">
232-
<img src="https://img.shields.io/badge/Total%20views-1314-limegreen" alt="Total views">
233-
<p>Refresh Date: 2026-03-13</p>
302+
<img src="https://img.shields.io/badge/Total%20views-1343-limegreen" alt="Total views">
303+
<p>Refresh Date: 2026-03-19</p>
234304
</div>
235305
<!-- END BADGE -->

TROUBLESHOOTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ terraform apply
353353

354354
<!-- START BADGE -->
355355
<div align="center">
356-
<img src="https://img.shields.io/badge/Total%20views-1314-limegreen" alt="Total views">
357-
<p>Refresh Date: 2026-03-13</p>
356+
<img src="https://img.shields.io/badge/Total%20views-1343-limegreen" alt="Total views">
357+
<p>Refresh Date: 2026-03-19</p>
358358
</div>
359359
<!-- END BADGE -->

src/a2a/status_automation.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if () {
1111

1212
# Check automation endpoint
1313
try {
14-
= Invoke-RestMethod -Uri "https://zava-6a7d57fb-app.azurewebsites.net/a2a/automation/status" -TimeoutSec 5
14+
= Invoke-RestMethod -Uri "https://zava-9e4d78b5-app.azurewebsites.net/a2a/automation/status" -TimeoutSec 5
1515
Write-Host "Automation Status: "
1616
} catch {
1717
Write-Host "Automation endpoint not accessible"

terraform-infrastructure/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ Templates structure:
5555
- terraform.tfvars `(Variable values)`: This file contains the actual values for the variables defined in `variables.tf`. By separating variable definitions and values, you can easily switch between different sets of values for different environments (e.g., development, staging, production) without changing the main configuration files.
5656
- outputs.tf `(Output values)`: This file defines the output values that Terraform should return after applying the configuration. Outputs are useful for displaying information about the resources created, such as IP addresses, resource IDs, and other important details. They can also be used as inputs for other Terraform configurations or scripts.
5757

58+
## Optional: Microsoft Defender for Cloud
59+
60+
This Terraform setup includes an opt-in configuration to enable **Microsoft Defender for Cloud** plans at the subscription scope.
61+
62+
> [!IMPORTANT]
63+
> Enabling Defender plans can incur additional costs in your Azure subscription.
64+
65+
- To enable, set `enable_defender_for_cloud = true` in `terraform.tfvars` and optionally adjust `defender_for_cloud_plans`.
66+
5867
## How to execute it
5968

6069
```mermaid
@@ -127,7 +136,7 @@ graph TD;
127136

128137
<!-- START BADGE -->
129138
<div align="center">
130-
<img src="https://img.shields.io/badge/Total%20views-1314-limegreen" alt="Total views">
131-
<p>Refresh Date: 2026-03-13</p>
139+
<img src="https://img.shields.io/badge/Total%20views-1343-limegreen" alt="Total views">
140+
<p>Refresh Date: 2026-03-19</p>
132141
</div>
133142
<!-- END BADGE -->

0 commit comments

Comments
 (0)