Skip to content

Commit 212be5d

Browse files
authored
Developer journey tutorial: Stage 3 - Production to adoption (#343)
1 parent c3681f6 commit 212be5d

File tree

31 files changed

+5513
-0
lines changed

31 files changed

+5513
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Azure AI Foundry Configuration
2+
PROJECT_ENDPOINT=https://your-project.eastus.api.azureml.ms
3+
AGENT_ID=your-agent-id
4+
5+
# Application Insights Configuration
6+
APPINSIGHTS_INSTRUMENTATION_KEY=your-instrumentation-key
7+
APPINSIGHTS_CONNECTION_STRING=InstrumentationKey=your-key;IngestionEndpoint=https://eastus-0.in.applicationinsights.azure.com/
8+
9+
# API Management Configuration
10+
APIM_ENDPOINT=https://your-apim.azure-api.net
11+
12+
# Model Configuration
13+
MODEL_DEPLOYMENT_NAME=gpt-4o-mini
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Azure.AI.Projects;
4+
5+
namespace Microsoft.Azure.Samples.ProductionToAdoption
6+
{
7+
public class EvaluationInsights
8+
{
9+
private readonly AIProjectClient? _projectClient;
10+
private readonly string _agentId;
11+
12+
public EvaluationInsights(AIProjectClient? projectClient, string agentId)
13+
{
14+
_projectClient = projectClient;
15+
_agentId = agentId;
16+
}
17+
18+
// <insight_generation>
19+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
20+
public Dictionary<string, object> AnalyzeEvaluationResults()
21+
{
22+
Helpers.PrintInfo("Analyzing evaluation patterns...");
23+
var random = new Random();
24+
var insights = new Dictionary<string, object>
25+
{
26+
["failure_patterns"] = new List<Dictionary<string, object>>
27+
{
28+
new() { ["pattern"] = "SharePoint connection timeout", ["frequency"] = random.Next(15, 25) }
29+
},
30+
["quality_trends"] = new Dictionary<string, object>
31+
{
32+
["current_month"] = random.NextDouble() * 0.2 + 0.8,
33+
["last_month"] = random.NextDouble() * 0.2 + 0.7
34+
},
35+
["recommendations"] = new List<string> { "Address high-impact failure patterns first" }
36+
};
37+
return insights;
38+
}
39+
// </insight_generation>
40+
41+
public Dictionary<string, object> Run()
42+
{
43+
Helpers.PrintHeader("Evaluation Insights Analysis");
44+
var insights = AnalyzeEvaluationResults();
45+
Helpers.PrintEvaluationInsights(insights);
46+
Helpers.SaveJson(insights, "evaluation_insights.json");
47+
return insights;
48+
}
49+
}
50+
51+
public class GatewayIntegration
52+
{
53+
private readonly AIProjectClient? _projectClient;
54+
private readonly string _agentId;
55+
56+
public GatewayIntegration(AIProjectClient? projectClient, string agentId)
57+
{
58+
_projectClient = projectClient;
59+
_agentId = agentId;
60+
}
61+
62+
// <apim_policies>
63+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
64+
public Dictionary<string, object> ConfigureGatewayPolicies()
65+
{
66+
Helpers.PrintInfo("Configuring API Management policies...");
67+
var config = new Dictionary<string, object>
68+
{
69+
["configuration"] = new Dictionary<string, object>
70+
{
71+
["endpoint"] = "https://your-apim.azure-api.net/agents/workplace",
72+
["rate_limit"] = "100 requests per minute per user",
73+
["caching_enabled"] = true
74+
}
75+
};
76+
return config;
77+
}
78+
// </apim_policies>
79+
80+
public Dictionary<string, object> Run()
81+
{
82+
Helpers.PrintHeader("AI Gateway Integration");
83+
var config = ConfigureGatewayPolicies();
84+
Helpers.PrintGatewaySummary(config);
85+
Helpers.SaveJson(config, "gateway_config.json");
86+
return config;
87+
}
88+
}
89+
90+
public class ContinuousMonitoring
91+
{
92+
private readonly AIProjectClient? _projectClient;
93+
private readonly string _agentId;
94+
95+
public ContinuousMonitoring(AIProjectClient? projectClient, string agentId)
96+
{
97+
_projectClient = projectClient;
98+
_agentId = agentId;
99+
}
100+
101+
// <quality_monitoring>
102+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
103+
public Dictionary<string, object> SetupMonitoringSchedule()
104+
{
105+
Helpers.PrintInfo("Configuring monitoring schedule...");
106+
var config = new Dictionary<string, object>
107+
{
108+
["schedule"] = new Dictionary<string, object>
109+
{
110+
["hourly_checks"] = new Dictionary<string, object> { ["enabled"] = true },
111+
["daily_reports"] = new Dictionary<string, object> { ["enabled"] = true }
112+
},
113+
["alerts"] = new List<Dictionary<string, object>>
114+
{
115+
new() { ["name"] = "Quality Degradation", ["severity"] = "high" }
116+
}
117+
};
118+
return config;
119+
}
120+
// </quality_monitoring>
121+
122+
public Dictionary<string, object> Run()
123+
{
124+
Helpers.PrintHeader("Continuous Monitoring Setup");
125+
var config = SetupMonitoringSchedule();
126+
Helpers.PrintMonitoringSummary(config);
127+
Helpers.SaveJson(config, "monitoring_schedule.json");
128+
return config;
129+
}
130+
}
131+
132+
public class FleetGovernance
133+
{
134+
private readonly AIProjectClient? _projectClient;
135+
private readonly string _agentId;
136+
137+
public FleetGovernance(AIProjectClient? projectClient, string agentId)
138+
{
139+
_projectClient = projectClient;
140+
_agentId = agentId;
141+
}
142+
143+
// <compliance_reporting>
144+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
145+
public Dictionary<string, object> GenerateGovernanceReport()
146+
{
147+
Helpers.PrintInfo("Generating fleet governance report...");
148+
var random = new Random();
149+
var report = new Dictionary<string, object>
150+
{
151+
["statistics"] = new Dictionary<string, object>
152+
{
153+
["total_agents"] = random.Next(12, 18),
154+
["active_users"] = random.Next(120, 180),
155+
["compliance_rate"] = random.NextDouble() * 0.05 + 0.95
156+
},
157+
["recommendations"] = new List<string> { "All agents meet compliance standards" }
158+
};
159+
return report;
160+
}
161+
// </compliance_reporting>
162+
163+
public Dictionary<string, object> Run()
164+
{
165+
Helpers.PrintHeader("Fleet-Wide Governance");
166+
var report = GenerateGovernanceReport();
167+
Helpers.PrintGovernanceSummary(report);
168+
Helpers.SaveJson(report, "governance_report.json");
169+
return report;
170+
}
171+
}
172+
173+
public class CostOptimization
174+
{
175+
private readonly AIProjectClient? _projectClient;
176+
private readonly string _agentId;
177+
178+
public CostOptimization(AIProjectClient? projectClient, string agentId)
179+
{
180+
_projectClient = projectClient;
181+
_agentId = agentId;
182+
}
183+
184+
// <cost_analysis>
185+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
186+
public Dictionary<string, object> AnalyzeCosts()
187+
{
188+
Helpers.PrintInfo("Analyzing agent costs...");
189+
var random = new Random();
190+
var totalCost = random.NextDouble() * 700 + 2800;
191+
var report = new Dictionary<string, object>
192+
{
193+
["totals"] = new Dictionary<string, object>
194+
{
195+
["total_cost"] = totalCost,
196+
["period"] = "Last 30 days"
197+
},
198+
["projected_savings"] = totalCost * 0.3
199+
};
200+
return report;
201+
}
202+
// </cost_analysis>
203+
204+
public Dictionary<string, object> Run()
205+
{
206+
Helpers.PrintHeader("Cost Monitoring & Optimization");
207+
var report = AnalyzeCosts();
208+
Helpers.PrintCostSummary(report);
209+
Helpers.SaveJson(report, "cost_report.json");
210+
return report;
211+
}
212+
}
213+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using Azure.AI.Projects;
6+
7+
namespace Microsoft.Azure.Samples.ProductionToAdoption
8+
{
9+
public class FeedbackCollection
10+
{
11+
private readonly AIProjectClient? _projectClient;
12+
private readonly string _agentId;
13+
14+
public FeedbackCollection(AIProjectClient? projectClient, string agentId)
15+
{
16+
_projectClient = projectClient;
17+
_agentId = agentId;
18+
}
19+
20+
// <feedback_api>
21+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
22+
public List<Dictionary<string, object>> CollectFeedbackFromProduction(int days = 30)
23+
{
24+
Helpers.PrintInfo($"Collecting user feedback from last {days} days...");
25+
26+
var random = new Random();
27+
var numFeedback = random.Next(700, 900);
28+
var feedbackList = new List<Dictionary<string, object>>();
29+
30+
for (int i = 0; i < numFeedback; i++)
31+
{
32+
var rating = random.Next(100) < 87 ? "positive" : "negative";
33+
feedbackList.Add(new Dictionary<string, object>
34+
{
35+
["feedback_id"] = $"fb-{i:D6}",
36+
["conversation_id"] = $"conv-{random.Next(1000, 9999)}",
37+
["timestamp"] = DateTime.UtcNow.AddDays(-random.Next(0, days)).ToString("o"),
38+
["rating"] = rating,
39+
["feedback_text"] = rating == "positive" ? "Great response!" : "Could be better",
40+
["user_id"] = $"user{random.Next(1, 50)}@company.com"
41+
});
42+
}
43+
44+
Helpers.PrintSuccess($"Collected {feedbackList.Count} feedback items");
45+
return feedbackList;
46+
}
47+
// </feedback_api>
48+
49+
// <feedback_analysis>
50+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
51+
public Dictionary<string, object> AnalyzeFeedback(List<Dictionary<string, object>> feedbackList)
52+
{
53+
Helpers.PrintInfo("Analyzing user feedback...");
54+
55+
var total = feedbackList.Count;
56+
var positive = feedbackList.Count(f => (string)f["rating"] == "positive");
57+
var negative = total - positive;
58+
59+
var analysis = new Dictionary<string, object>
60+
{
61+
["statistics"] = new Dictionary<string, object>
62+
{
63+
["total_feedback"] = total,
64+
["positive_count"] = positive,
65+
["negative_count"] = negative,
66+
["satisfaction_rate"] = (double)positive / total
67+
},
68+
["recommendations"] = new List<string>
69+
{
70+
positive > negative ? "Maintain current quality" : "Address user concerns"
71+
}
72+
};
73+
74+
return analysis;
75+
}
76+
// </feedback_analysis>
77+
78+
public Dictionary<string, object> Run()
79+
{
80+
Helpers.PrintHeader("Human Feedback Collection & Analysis");
81+
var feedback = CollectFeedbackFromProduction();
82+
var analysis = AnalyzeFeedback(feedback);
83+
Helpers.PrintFeedbackSummary(analysis);
84+
Helpers.SaveJson(analysis, "feedback_summary.json");
85+
return analysis;
86+
}
87+
}
88+
}

0 commit comments

Comments
 (0)