Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

An [Agent Framework](https://github.com/microsoft/agent-framework) C# agent for testing **managed egress proxy policies** on Microsoft Foundry hosted agents. It is the .NET counterpart to the [Python egress-control sample](../../../../../python/hosted-agents/agent-framework/responses/18-egress-control/README.md).

## Administrator policy authoring (control plane)

To restrict **which RAI egress policies developers may save**, use the
[control-plane Azure Policy walkthrough](control-plane/README.md). It includes
a small exact-host policy definition, assignment parameters, and allowed/denied RAI
requests. No published built-in, model deployment, or running agent is required.
The walkthrough demonstrates an ARM policy denial, not APES or runtime traffic
enforcement. Run it on a disposable account separately from the runtime scenarios
below; the administrator restrictions intentionally reject some scenario policies.

## How it works

The agent registers an async C# `EgressTest` function tool with Agent Framework and hosts it through the Responses protocol. The tool uses `HttpClient` to make outbound requests and returns the status, response headers, and up to 4,000 characters of the body. Each request includes `X-Test-Marker` and a distinct `User-Agent`, allowing egress policies to demonstrate Allow, Deny, Transform, and Rewrite behavior.
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"approvedHosts": {
"value": [
"httpbin.org"
]
},
"effect": {
"value": "Deny"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"properties": {
"displayName": "Sample: RAI egress allows only approved hosts",
"description": "Teaching example for control-plane governance. When egress is present, require Enforced mode, default Deny, and Fqdn rules using only Allow or Deny. Allow rules must name an approved exact host. Does not govern paths, support Transform/Rewrite, or require egress on every RAI policy.",
"mode": "All",
"parameters": {
"approvedHosts": {
"type": "Array",
"metadata": {
"displayName": "Approved exact hostnames",
"description": "Exact hostnames such as httpbin.org. No wildcards, schemes, ports or paths. An empty list permits no Allow rules."
}
},
"effect": {
"type": "String",
"allowedValues": ["Audit", "Deny", "Disabled"],
"defaultValue": "Audit",
"metadata": {
"displayName": "Effect",
"description": "Deny blocks noncompliant RAI writes; Audit reports without blocking; Disabled turns off these checks."
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.CognitiveServices/accounts/raiPolicies"
},
{
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy",
"exists": "true"
},
{
"anyOf": [
{
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy.mode",
"notEquals": "Enforced"
},
{
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy.defaultAction",
"notEquals": "Deny"
},
{
"count": {
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy.rules[*]",
"where": {
"anyOf": [
{
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy.rules[*].ruleType",
"notEquals": "Fqdn"
},
{
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy.rules[*].action.actionType",
"notIn": ["Allow", "Deny"]
},
{
"allOf": [
{
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy.rules[*].action.actionType",
"equals": "Allow"
},
{
"anyOf": [
{
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy.rules[*].match.host",
"notIn": "[parameters('approvedHosts')]"
},
{
"field": "Microsoft.CognitiveServices/accounts/raiPolicies/egressPolicy.rules[*].match.host",
"contains": "*"
}
]
}
]
}
]
}
},
"greater": 0
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"properties": {
"basePolicyName": "Microsoft.Default",
"contentFilters": [],
"egressPolicy": {
"mode": "Enforced",
"defaultAction": "Deny",
"rules": [
{
"name": "allow-httpbin-get",
"ruleType": "Fqdn",
"match": {
"host": "httpbin.org",
"path": "/get"
},
"action": {
"actionType": "Allow"
}
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"properties": {
"basePolicyName": "Microsoft.Default",
"contentFilters": [],
"egressPolicy": {
"mode": "Enforced",
"defaultAction": "Deny",
"rules": [
{
"name": "allow-httpbin-get",
"ruleType": "Fqdn",
"match": {
"host": "example.com",
"path": "/get"
},
"action": {
"actionType": "Allow"
}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

An [Agent Framework](https://github.com/microsoft/agent-framework) agent for testing **managed egress proxy policies** on Azure AI Foundry hosted agents. The agent accepts text commands, makes outbound HTTP requests through the egress proxy, and returns the full response — enabling validation of Allow, Deny, Transform, and Rewrite rules defined via [RAI egress policies](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/egress).

## Administrator policy authoring (control plane)

To restrict **which RAI egress policies developers may save**, use the
[control-plane Azure Policy walkthrough](control-plane/README.md). It includes
a small exact-host policy definition, assignment parameters, and allowed/denied RAI
requests. No published built-in, model deployment, or running agent is required.
The walkthrough demonstrates an ARM policy denial, not APES or runtime traffic
enforcement. Run it on a disposable account separately from the runtime scenarios
below; the administrator restrictions intentionally reject some scenario policies.

## How it works

The agent uses the Agent Framework with `FoundryChatClient` and exposes an `egress_test` tool. When you send a command, the LLM routes it to the tool, which makes outbound HTTP requests via `aiohttp` and returns the result (status code, headers, body). Every outbound request includes marker headers (`X-Test-Marker`, `User-Agent`) that are useful for verifying Transform operations.
Expand Down
Loading
Loading