Sample .NET console applications for Microsoft Agent Governance scenarios.
This repository includes eight focused examples that cover policy evaluation, agent identity and trust, Microsoft Agent Framework (MAF) integration, Agent Framework Harness file access, and audit/telemetry export.
| Project | Focus | Target Framework |
|---|---|---|
AGTPolicyApp01 |
Basic policy-driven tool call evaluation with a local YAML policy | net10.0 |
AGTOpaPolicyApp01 |
OPA/Rego policy evaluation for tool call governance | net10.0 |
AGTCedarPolicyApp01 |
Cedar policy evaluation for tool call governance | net10.0 |
AGTPolicyWithMAFApp02 |
MAF + Azure OpenAI with governance middleware and tool blocking | net10.0 |
AGTIdentityApp01 |
Agent identity (DID/public key) and trust score basics | net10.0 |
AGTIdentityWithMAFApp02 |
Trust-score-aware tool execution in a MAF agent flow | net10.0 |
AGTAuditBlobTelemetryApp01 |
Governance audit to Azure Blob + telemetry to Application Insights | net10.0 |
AGTPolicywithMAFApp03 |
Agent Framework Harness file access with governed read-only operations | net10.0 |
MyAGTSamples.slncontains all eight projects above.- Policy files are under each project's
policies/folder where applicable. AGTAuditBlobTelemetryApp01also includesBlobAuditSink.csand a project-level README with deep details.
- .NET SDKs:
- .NET 10 SDK
- Azure CLI (
az) signed in when running MAF/OpenAI samples that useAzureCliCredential. - Access to Azure OpenAI (for MAF/OpenAI-based projects).
Check installed SDKs:
dotnet --list-sdksFrom repository root:
dotnet restore
dotnet build MyAGTSamples.slnFrom repository root:
dotnet run --project AGTPolicyApp01/AGTPolicyApp01.csprojBehavior:
- Loads
AGTPolicyApp01/policies/default.yaml - Evaluates sample tool calls (for example
file_write,http_request) - Prints allow/deny results
dotnet run --project AGTOpaPolicyApp01/AGTOpaPolicyApp01.csprojBehavior:
- Loads OPA/Rego policy from
AGTOpaPolicyApp01/policies/toolcall.rego - Evaluates sample tool calls (
http_request,execute_shell,file_read) - Demonstrates blocking
execute_shelltool via Rego policy - Prints allow/deny results
dotnet run --project AGTCedarPolicyApp01/AGTCedarPolicyApp01.csprojBehavior:
- Loads Cedar policy (inline in code)
- Evaluates sample tool calls (
http_request,execute_shell,file_read) - Demonstrates basic Cedar policy syntax with
PolicyEngine.LoadCedar() - Prints allow/deny results
- Note: For tool-specific filtering, YAML or OPA policies offer richer support
Required environment variables:
AZURE_OPENAI_ENDPOINTAZURE_OPENAI_DEPLOYMENT_NAME(optional, default in code:gpt-5-mini)
Run:
dotnet run --project AGTPolicyWithMAFApp02/AGTPolicyWithMAFApp02.csprojBehavior:
- Uses governance middleware with MAF tools
- Applies policy from
AGTPolicyWithMAFApp02/policies/default.yaml - Demonstrates a blocked
GetWeathercall and a normal non-tool response
dotnet run --project AGTIdentityApp01/AGTIdentityApp01.csprojBehavior:
- Creates an agent identity
- Prints DID/public key/status
- Loads trust score from a local file trust store
Required environment variables:
AZURE_OPENAI_ENDPOINTAZURE_OPENAI_DEPLOYMENT_NAME(optional, default in code:gpt-5-mini)
Run:
dotnet run --project AGTPolicywithMAFApp03/AGTPolicywithMAFApp03.csprojBehavior:
- Uses Agent Framework Harness
FileAccessProvidertools for the sample files - Allows listing, reading, and searching files
- Blocks writing, replacing, and deleting files through an Agent Governance Toolkit policy
- Uses separate Harness
Nameand governanceDefaultAgentIdvalues; see the project README for details
Required environment variables:
AZURE_OPENAI_ENDPOINTAZURE_OPENAI_DEPLOYMENT_NAME(optional, default in code:gpt-5-mini)
Run:
dotnet run --project AGTIdentityWithMAFApp02/AGTIdentityWithMAFApp02.csprojBehavior:
- Uses trust-based policy from
AGTIdentityWithMAFApp02/policies/trust-based.yaml - Starts at trust score 500, then applies a penalty
- Shows first tool call allowed and second tool call blocked
Required environment variables:
AZURE_OPENAI_ENDPOINTAZURE_OPENAI_DEPLOYMENT(optional, default in code:gpt-5-mini)APPLICATIONINSIGHTS_CONNECTION_STRINGAZURE_STORAGE_ACCOUNT_NAME
Optional:
AZURE_TENANT_IDAUDIT_STORAGE_CONTAINER(default:agt-audit)
Run:
dotnet run --project AGTAuditBlobTelemetryApp01/AGTAuditBlobTelemetryApp01.csprojBehavior:
- Writes governance events to an Azure Blob append blob (JSONL)
- Exports logs/metrics/traces via Azure Monitor OpenTelemetry exporter
- Demonstrates allow/deny policy decisions and direct governance evaluation
| File | Default action | Notable rule |
|---|---|---|
AGTPolicyApp01/policies/default.yaml |
deny |
Rate limits http_request at 100/minute |
AGTOpaPolicyApp01/policies/toolcall.rego |
deny |
Allows all tools except execute_shell |
AGTCedarPolicyApp01/policies/toolcall.cedar |
N/A (inline in code) | Basic permit policy for demonstration |
AGTPolicyWithMAFApp02/policies/default.yaml |
allow |
Denies GetWeather |
AGTPolicywithMAFApp03/policies/default.yaml |
allow |
Allows read-only file access and denies writes/deletes |
AGTIdentityWithMAFApp02/policies/trust-based.yaml |
allow |
Denies calls when trust_score < 500 |
AGTAuditBlobTelemetryApp01/policies/default.yaml |
deny |
Allows specific tools and denies execute_shell |
- Build fails due to SDK mismatch:
- Install the .NET 10 SDK, then re-run
dotnet build.
- Install the .NET 10 SDK, then re-run
- Azure auth errors:
- Run
az loginand verify the active subscription/tenant.
- Run
- Environment variable errors:
- Confirm required variables are set for the project you run.
- Policy file not found:
- Build first so policy files are copied to output directories.
- This repository intentionally mixes simple local-only samples and Azure-connected samples.
- For deeper audit/telemetry details, see
AGTAuditBlobTelemetryApp01/README.md.