← Back to Tutorials

7. Production & Governance

Observability

Monitor your agents in production with Azure Monitor, Application Insights, and MAF's built-in telemetry.

import { TelemetryMiddleware } from "@microsoft/agents";

const agent = new Agent({
  name: "ObservableAgent",
  middlewares: [
    new TelemetryMiddleware({
      connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING,
      trackConversations: true,
      trackToolCalls: true,
    })
  ]
});

Metrics to Track

Guardrails

Guardrails enforce safety and compliance policies on agent inputs and outputs.

import { Guardrail, ContentSafetyPolicy } from "@microsoft/agents";

const agent = new Agent({
  name: "SafeAgent",
  guardrails: [
    new ContentSafetyPolicy({
      blockHateSpeech: true,
      blockPersonalInfo: true,
      maxInputLength: 4096,
    })
  ]
});

Security Best Practices

PracticeDescription
Managed IdentityUse Azure Managed Identity instead of connection strings
Tool AuthValidate authentication and authorization in every tool handler
Rate LimitingPrevent abuse with per-user rate limits
PII RedactionConfigure guardrails to detect and redact PII
Audit LoggingLog all agent decisions and tool calls for audit

Deployment Options

📘 Best Practice: Always use Azure RBAC to control which identities can create, update, invoke, or delete agents. Apply least-privilege principles.
✏️ Exercise: Deploy your agent to Azure Container Apps. Configure Application Insights telemetry and verify you can see conversation traces. Set up a guardrail that blocks personally identifiable information (PII) from being shared.