diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e638e9e26..a70d56111 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,6 +6,9 @@ /samples/microsoft/csharp/mslearn-resources/quickstart/Samples/AgentFileSearch.cs @azure-ai-foundry/AI-Platform-Docs /samples/microsoft/csharp/mslearn-resources/quickstart/Samples/AgentService.cs @azure-ai-foundry/AI-Platform-Docs /samples/microsoft/csharp/mslearn-resources/quickstart/Samples/SimpleInference.cs @azure-ai-foundry/AI-Platform-Docs +/samples/microsoft/infrastructure-setup-terraform/00-basic-azurerm/code/main.tf @azure-ai-foundry/AI-Platform-Docs +/samples/microsoft/infrastructure-setup-terraform/00-basic-azurerm/code/providers.tf @azure-ai-foundry/AI-Platform-Docs +/samples/microsoft/infrastructure-setup-terraform/00-basic-azurerm/code/variables.tf @azure-ai-foundry/AI-Platform-Docs /samples/microsoft/infrastructure-setup-terraform/00-basic/code/main.tf @azure-ai-foundry/AI-Platform-Docs /samples/microsoft/infrastructure-setup-terraform/00-basic/code/providers.tf @azure-ai-foundry/AI-Platform-Docs /samples/microsoft/infrastructure-setup-terraform/00-basic/code/variables.tf @azure-ai-foundry/AI-Platform-Docs diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/.env.template b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/.env.template deleted file mode 100644 index 5107649cc..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/.env.template +++ /dev/null @@ -1,10 +0,0 @@ -# Azure AI Foundry Configuration -PROJECT_ENDPOINT=https://your-project.aiservices.azure.com -MODEL_DEPLOYMENT_NAME=gpt-4o -AI_FOUNDRY_TENANT_ID=your-ai-foundry-tenant-id - -# Microsoft Learn MCP Server (Works out-of-the-box!) -MCP_SERVER_URL=https://learn.microsoft.com/api/mcp - -# SharePoint Integration (Optional - requires additional setup) -SHAREPOINT_RESOURCE_NAME=your-sharepoint-connection diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/Evaluate.cs b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/Evaluate.cs deleted file mode 100644 index 3c45f73a6..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/Evaluate.cs +++ /dev/null @@ -1,363 +0,0 @@ -/** - * Azure AI Foundry Agent Evaluation - Tutorial 1: Modern Workplace Assistant - * - * This evaluation system demonstrates enterprise AI quality assurance patterns: - * - Business-focused evaluation scenarios - * - Multi-source knowledge validation (SharePoint + MCP) - * - Response quality assessment - * - Source attribution verification - * - Performance and reliability measurement - * - * Educational Focus: - * - Shows how to evaluate enterprise AI systems - * - Demonstrates quality metrics for business scenarios - * - Provides foundation for governance and monitoring - */ - -#region evaluation_imports -using Azure.AI.Projects; -using Azure.AI.Agents.Models; -using Azure.Identity; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using System.Text.Json; -#endregion evaluation_imports - -namespace ModernWorkplaceAssistant.Evaluation -{ - public class EvaluationResult - { - public string Question { get; set; } - public string Answer { get; set; } - public string Status { get; set; } - public List Sources { get; set; } = new List(); - public DateTime Timestamp { get; set; } - public double ResponseTimeMs { get; set; } - public string ExpectedSource { get; set; } - public bool SourceMatch { get; set; } - } - - public class TestQuestion - { - public string question { get; set; } - public string expected_source { get; set; } - public string category { get; set; } - } - - public class AgentEvaluator - { - private readonly AIProjectClient projectClient; - - public AgentEvaluator() - { - // Load environment variables - LoadEnvironmentVariables(); - - var credential = new DefaultAzureCredential(); - projectClient = new AIProjectClient( - new Uri(Environment.GetEnvironmentVariable("PROJECT_ENDPOINT")), - credential - ); - } - - private static void LoadEnvironmentVariables() - { - var envFile = Path.Combine(Directory.GetCurrentDirectory(), ".env"); - if (File.Exists(envFile)) - { - var lines = File.ReadAllLines(envFile); - foreach (var line in lines) - { - if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#")) - continue; - - var parts = line.Split('=', 2); - if (parts.Length == 2) - { - Environment.SetEnvironmentVariable(parts[0].Trim(), parts[1].Trim()); - } - } - } - } - - #region evaluation_functions - public async Task> RunEvaluationAsync() - { - Console.WriteLine("๐Ÿงช Starting Modern Workplace Assistant Evaluation"); - Console.WriteLine("=================================================="); - - // Load test questions - var questions = await LoadTestQuestionsAsync(); - Console.WriteLine($"๐Ÿ“ Loaded {questions.Count} test questions"); - - // Create agent for evaluation - Console.WriteLine("๐Ÿค– Creating evaluation agent..."); - var agentConfig = await CreateWorkplaceAssistantAsync(); - - var results = new List(); - - // Run evaluation for each question - for (int i = 0; i < questions.Count; i++) - { - var question = questions[i]; - Console.WriteLine($"\n[{i + 1}/{questions.Count}] Testing: {question.category}"); - Console.WriteLine($"โ“ Question: {question.question}"); - - var result = await EvaluateQuestionAsync(agentConfig.Agent, question); - results.Add(result); - - // Display result - Console.WriteLine($"โœ… Status: {result.Status}"); - Console.WriteLine($"โฑ๏ธ Response time: {result.ResponseTimeMs:F0}ms"); - Console.WriteLine($"๐Ÿ“š Sources found: {result.Sources.Count}"); - Console.WriteLine($"๐ŸŽฏ Expected source match: {(result.SourceMatch ? "โœ…" : "โš ๏ธ")}"); - - if (result.Sources.Any()) - { - Console.WriteLine(" Sources:"); - foreach (var source in result.Sources.Take(3)) - { - Console.WriteLine($" - {source}"); - } - } - } - - // Display summary - DisplayEvaluationSummary(results); - - // Cleanup - await CleanupAgentAsync(agentConfig.Agent); - - return results; - } - - private async Task> LoadTestQuestionsAsync() - { - var questionsFile = "questions.jsonl"; - if (!File.Exists(questionsFile)) - { - throw new FileNotFoundException($"Test questions file not found: {questionsFile}"); - } - - var questions = new List(); - var lines = await File.ReadAllLinesAsync(questionsFile); - - foreach (var line in lines) - { - if (string.IsNullOrWhiteSpace(line)) - continue; - - try - { - var question = JsonSerializer.Deserialize(line); - questions.Add(question); - } - catch (JsonException ex) - { - Console.WriteLine($"โš ๏ธ Failed to parse question: {line} - {ex.Message}"); - } - } - - return questions; - } - - private async Task<(Agent Agent, McpTool McpTool, SharepointTool SharepointTool)> CreateWorkplaceAssistantAsync() - { - // Create agent using the same logic as the main program - var sharePointResourceName = Environment.GetEnvironmentVariable("SHAREPOINT_RESOURCE_NAME"); - SharepointTool sharePointTool = null; - - try - { - var sharePointConn = await projectClient.Connections.GetConnectionAsync(sharePointResourceName); - sharePointTool = new SharepointTool(sharePointConn.Id); - } - catch (Exception ex) - { - Console.WriteLine($"โš ๏ธ SharePoint connection failed: {ex.Message}"); - } - - var mcpTool = new McpTool("microsoft_learn", Environment.GetEnvironmentVariable("MCP_SERVER_URL")); - - var instructions = sharePointTool != null - ? "You are a Modern Workplace Assistant. Use SharePoint for company policies and Microsoft Learn for technical guidance. Always cite your sources." - : "You are a Technical Assistant with Microsoft Learn access. Provide technical guidance and cite sources."; - - var tools = new List(); - if (sharePointTool != null) - tools.AddRange(sharePointTool.Definitions); - tools.AddRange(mcpTool.Definitions); - - var agent = await projectClient.Agents.CreateAgentAsync( - Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"), - name: "Evaluation Agent", - instructions: instructions, - tools: tools - ); - - return (agent, mcpTool, sharePointTool); - } - - private async Task EvaluateQuestionAsync(Agent agent, TestQuestion question) - { - var startTime = DateTime.UtcNow; - var result = new EvaluationResult - { - Question = question.question, - ExpectedSource = question.expected_source, - Timestamp = startTime - }; - - try - { - // Create thread and run conversation - var thread = await projectClient.Agents.CreateThreadAsync(); - - await projectClient.Agents.CreateMessageAsync(thread.Id, MessageRole.User, question.question); - var run = await projectClient.Agents.CreateRunAsync(thread.Id, agent.Id); - - // Wait for completion - while (run.Status == RunStatus.InProgress || run.Status == RunStatus.Queued) - { - await Task.Delay(1000); - run = await projectClient.Agents.GetRunAsync(thread.Id, run.Id); - } - - var endTime = DateTime.UtcNow; - result.ResponseTimeMs = (endTime - startTime).TotalMilliseconds; - - if (run.Status == RunStatus.Completed) - { - var messages = await projectClient.Agents.GetMessagesAsync(thread.Id); - var assistantMessage = messages.Value - .Where(m => m.Role == MessageRole.Assistant) - .OrderByDescending(m => m.CreatedAt) - .FirstOrDefault(); - - if (assistantMessage != null) - { - result.Answer = assistantMessage.Content.FirstOrDefault()?.Text ?? ""; - result.Status = "Completed"; - - // Extract sources from response - result.Sources = ExtractSourcesFromResponse(result.Answer); - result.SourceMatch = CheckSourceMatch(result.Sources, question.expected_source); - } - else - { - result.Status = "No response"; - } - } - else - { - result.Status = $"Failed: {run.Status}"; - } - - // Cleanup thread - await projectClient.Agents.DeleteThreadAsync(thread.Id); - } - catch (Exception ex) - { - result.Status = $"Error: {ex.Message}"; - } - - return result; - } - - private List ExtractSourcesFromResponse(string response) - { - var sources = new List(); - - // Look for common source indicators - var sourceIndicators = new[] { "SharePoint", "Microsoft Learn", "learn.microsoft.com", "documentation" }; - - foreach (var indicator in sourceIndicators) - { - if (response.Contains(indicator, StringComparison.OrdinalIgnoreCase)) - { - sources.Add(indicator); - } - } - - return sources.Distinct().ToList(); - } - - private bool CheckSourceMatch(List foundSources, string expectedSource) - { - if (string.IsNullOrEmpty(expectedSource)) - return true; - - return foundSources.Any(source => - source.Contains(expectedSource, StringComparison.OrdinalIgnoreCase) || - expectedSource.Contains(source, StringComparison.OrdinalIgnoreCase)); - } - - private void DisplayEvaluationSummary(List results) - { - Console.WriteLine("\n๐Ÿ“Š EVALUATION SUMMARY"); - Console.WriteLine("====================="); - - var successful = results.Count(r => r.Status == "Completed"); - var avgResponseTime = results.Where(r => r.Status == "Completed") - .Average(r => r.ResponseTimeMs); - var sourceMatches = results.Count(r => r.SourceMatch); - - Console.WriteLine($"โœ… Successful responses: {successful}/{results.Count} ({100.0 * successful / results.Count:F1}%)"); - Console.WriteLine($"โฑ๏ธ Average response time: {avgResponseTime:F0}ms"); - Console.WriteLine($"๐ŸŽฏ Source attribution accuracy: {sourceMatches}/{results.Count} ({100.0 * sourceMatches / results.Count:F1}%)"); - - // Show failed cases - var failed = results.Where(r => r.Status != "Completed").ToList(); - if (failed.Any()) - { - Console.WriteLine("\nโš ๏ธ Failed Cases:"); - foreach (var fail in failed) - { - Console.WriteLine($" - {fail.Question}: {fail.Status}"); - } - } - } - - private async Task CleanupAgentAsync(Agent agent) - { - try - { - await projectClient.Agents.DeleteAgentAsync(agent.Id); - Console.WriteLine("๐Ÿงน Cleanup completed"); - } - catch (Exception ex) - { - Console.WriteLine($"โš ๏ธ Cleanup warning: {ex.Message}"); - } - } - #endregion evaluation_functions - } - - #region evaluation_main - // Entry point for evaluation - public class EvaluationProgram - { - public static async Task Main(string[] args) - { - Console.WriteLine("Azure AI Foundry - Modern Workplace Assistant Evaluation"); - Console.WriteLine("========================================================"); - - try - { - var evaluator = new AgentEvaluator(); - var results = await evaluator.RunEvaluationAsync(); - - Console.WriteLine($"\n๐ŸŽ‰ Evaluation completed with {results.Count} test cases"); - } - catch (Exception ex) - { - Console.WriteLine($"โŒ Evaluation failed: {ex.Message}"); - Environment.Exit(1); - } - } - } - #endregion evaluation_main -} \ No newline at end of file diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md deleted file mode 100644 index 01aa46468..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md +++ /dev/null @@ -1,57 +0,0 @@ -# MCP Server Options for Azure AI Foundry Sample - -## Current Issue -The Microsoft Learn MCP server (https://learn.microsoft.com/api/mcp) requires approval, causing runs to get cancelled. - -## Recommended MCP Servers (No Approval Required) - -### 1. Weather MCP Server -``` -MCP_SERVER_URL=https://mcp-weather.vercel.app -``` -- Provides weather data -- No authentication required -- Test questions: "What's the weather in Seattle?", "Get current weather for New York" - -### 2. Public APIs MCP Server -``` -MCP_SERVER_URL=https://mcp-public-apis.herokuapp.com -``` -- Access to various public APIs -- No authentication required -- Test questions: "Get information about cats", "Find a random fact" - -### 3. Wikipedia MCP Server -``` -MCP_SERVER_URL=https://mcp-wikipedia.glitch.me -``` -- Search Wikipedia articles -- No authentication required -- Test questions: "Search Wikipedia for Azure", "Tell me about cloud computing" - -### 4. GitHub Public MCP Server -``` -MCP_SERVER_URL=https://api.githubcopilot.com/mcp/ -``` -- Access public GitHub repositories -- May require authentication -- Test questions: "Search GitHub for Azure samples" - -## Recommended for Sample -Use the **Weather MCP Server** as it's: -- โœ… Reliable and stable -- โœ… No authentication required -- โœ… No approval required -- โœ… Easy to test with weather questions -- โœ… Demonstrates external API integration - -## Update .env -``` -MCP_SERVER_URL=https://mcp-weather.vercel.app -``` - -## Test Questions -After updating: -- "What's the weather in Seattle?" -- "Get current weather for London" -- "Tell me the temperature in Tokyo" \ No newline at end of file diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/ModernWorkplaceAssistant.csproj b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/ModernWorkplaceAssistant.csproj deleted file mode 100644 index 53cff8fb4..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/ModernWorkplaceAssistant.csproj +++ /dev/null @@ -1,48 +0,0 @@ - - - - Exe - net8.0 - enable - enable - ModernWorkplaceAssistant - ModernWorkplaceAssistant - - - - - - - - - - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - \ No newline at end of file diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/Program.cs b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/Program.cs deleted file mode 100644 index 3d3852113..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/Program.cs +++ /dev/null @@ -1,519 +0,0 @@ -/** - * Azure AI Foundry Agent Sample - Tutorial 1: Modern Workplace Assistant - * - * This sample demonstrates a complete business scenario combining: - * - SharePoint integration for internal company knowledge - * - Microsoft Learn MCP integration for external technical guidance - * - Intelligent orchestration of multiple data sources - * - Robust error handling and graceful degradation - * - * Educational Focus: - * - Enterprise AI patterns with multiple data sources - * - Real-world business scenarios that enterprises face daily - * - Production-ready error handling and diagnostics - * - Foundation for governance, evaluation, and monitoring (Tutorials 2-3) - * - * Business Scenario: - * An employee needs to implement Azure AD multi-factor authentication. They need: - * 1. Company security policy requirements (from SharePoint) - * 2. Technical implementation steps (from Microsoft Learn) - * 3. Combined guidance showing how policy requirements map to technical implementation - */ - -#region imports_and_setup -using Azure.AI.Projects; -using Azure.AI.Agents.Models; -using Azure.Identity; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using System.Text.Json; -#endregion imports_and_setup - -namespace ModernWorkplaceAssistant -{ - // ============================================================================ - // CONFIGURATION AND DATA MODELS - // ============================================================================ - - public class AgentConfiguration - { - public Agent Agent { get; set; } - public McpTool McpTool { get; set; } - public SharepointTool SharepointTool { get; set; } - } - - public class BusinessScenario - { - public string Title { get; set; } - public string Question { get; set; } - public string Context { get; set; } - public string ExpectedSource { get; set; } - public string LearningPoint { get; set; } - } - - public class ChatResult - { - public string Content { get; set; } - public string Status { get; set; } - } - - public class Program - { - // ======================================================================== - // AUTHENTICATION SETUP - // ======================================================================== - // Support both default Azure credentials and specific tenant authentication - private static AIProjectClient projectClient; - - static Program() - { - // Load environment variables - LoadEnvironmentVariables(); - - var aiFundryTenantId = Environment.GetEnvironmentVariable("AI_FOUNDRY_TENANT_ID"); - DefaultAzureCredential credential; - - if (!string.IsNullOrEmpty(aiFundryTenantId)) - { - Console.WriteLine($"๐Ÿ” Using AI Foundry tenant: {aiFundryTenantId}"); - credential = new DefaultAzureCredential(); - } - else - { - credential = new DefaultAzureCredential(); - } - - projectClient = new AIProjectClient( - new Uri(Environment.GetEnvironmentVariable("PROJECT_ENDPOINT")), - credential - ); - } - - private static void LoadEnvironmentVariables() - { - // Load .env file if it exists - var envFile = Path.Combine(Directory.GetCurrentDirectory(), ".env"); - if (File.Exists(envFile)) - { - var lines = File.ReadAllLines(envFile); - foreach (var line in lines) - { - if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#")) - continue; - - var parts = line.Split('=', 2); - if (parts.Length == 2) - { - Environment.SetEnvironmentVariable(parts[0].Trim(), parts[1].Trim()); - } - } - } - } - - #region create_workplace_assistant - /// - /// Create a Modern Workplace Assistant combining internal and external knowledge. - /// - /// This demonstrates enterprise AI patterns: - /// 1. Multi-source data integration (SharePoint + MCP) - /// 2. Robust error handling with graceful degradation - /// 3. Dynamic agent capabilities based on available resources - /// 4. Clear diagnostic information for troubleshooting - /// - /// Educational Value: - /// - Shows real-world complexity of enterprise AI systems - /// - Demonstrates how to handle partial system failures - /// - Provides patterns for combining internal and external data - /// - /// AgentConfiguration for further interaction and testing - public static async Task CreateWorkplaceAssistantAsync() - { - Console.WriteLine("๐Ÿค– Creating Modern Workplace Assistant..."); - - // ==================================================================== - // SHAREPOINT INTEGRATION SETUP - // ==================================================================== - // SharePoint provides access to internal company knowledge: - // - Company policies and procedures - // - Security guidelines and requirements - // - Governance and compliance documentation - // - Internal process documentation - - var sharepointResourceName = Environment.GetEnvironmentVariable("SHAREPOINT_RESOURCE_NAME"); - - Console.WriteLine("๐Ÿ“ Configuring SharePoint integration..."); - Console.WriteLine($" Connection: {sharepointResourceName}"); - - SharepointTool sharepointTool = null; - try - { - // Attempt to retrieve pre-configured SharePoint connection - var sharepointConnection = await projectClient.GetConnectionAsync(sharepointResourceName); - sharepointTool = new SharepointTool(sharepointConnection.Id); - Console.WriteLine("โœ… SharePoint successfully connected"); - } - catch (Exception ex) - { - // Graceful degradation - system continues without SharePoint - Console.WriteLine($"โš ๏ธ SharePoint connection failed: {ex.Message}"); - Console.WriteLine(" Agent will operate in technical guidance mode only"); - Console.WriteLine(" ๐Ÿ“ To enable full functionality:"); - Console.WriteLine(" Create SharePoint connection in Azure AI Foundry portal"); - Console.WriteLine($" Connection name: {sharepointResourceName}"); - sharepointTool = null; - } - - // ==================================================================== - // MICROSOFT LEARN MCP INTEGRATION SETUP - // ==================================================================== - // Microsoft Learn MCP provides access to current technical documentation: - // - Azure service configuration guides - // - Best practices and implementation patterns - // - Troubleshooting and diagnostic information - // - Latest feature updates and capabilities - - Console.WriteLine("๐Ÿ“š Configuring Microsoft Learn MCP integration..."); - var mcpTool = new McpTool - { - ServerLabel = "microsoft_learn", - ServerUrl = Environment.GetEnvironmentVariable("MCP_SERVER_URL"), - AllowedTools = new List() // Allow all available tools - }; - - // Disable approval workflow for seamless demonstration - mcpTool.SetApprovalMode("never"); - Console.WriteLine($"โœ… Microsoft Learn MCP connected: {Environment.GetEnvironmentVariable("MCP_SERVER_URL")}"); - - // ==================================================================== - // AGENT CREATION WITH DYNAMIC CAPABILITIES - // ==================================================================== - // Create agent instructions based on available data sources - // This demonstrates adaptive system design - - string instructions; - if (sharepointTool != null) - { - instructions = @"You are a Modern Workplace Assistant for Contoso Corporation. - -CAPABILITIES: -- Search SharePoint for company policies, procedures, and internal documentation -- Access Microsoft Learn for current Azure and Microsoft 365 technical guidance -- Provide comprehensive solutions combining internal requirements with external implementation - -RESPONSE STRATEGY: -- For policy questions: Search SharePoint for company-specific requirements and guidelines -- For technical questions: Use Microsoft Learn for current Azure/M365 documentation and best practices -- For implementation questions: Combine both sources to show how company policies map to technical implementation -- Always cite your sources and provide step-by-step guidance -- Explain how internal requirements connect to external implementation steps - -EXAMPLE SCENARIOS: -- ""What is our MFA policy?"" โ†’ Search SharePoint for security policies -- ""How do I configure Azure AD Conditional Access?"" โ†’ Use Microsoft Learn for technical steps -- ""Our policy requires MFA - how do I implement this?"" โ†’ Combine policy requirements with implementation guidance"; - } - else - { - instructions = @"You are a Technical Assistant with access to Microsoft Learn documentation. - -CAPABILITIES: -- Access Microsoft Learn for current Azure and Microsoft 365 technical guidance -- Provide detailed implementation steps and best practices -- Explain Azure services, features, and configuration options - -LIMITATIONS: -- SharePoint integration is not available -- Cannot access company-specific policies or internal documentation -- When asked about company policies, explain that internal document access requires SharePoint configuration - -RESPONSE STRATEGY: -- Provide comprehensive technical guidance from Microsoft Learn -- Include step-by-step implementation instructions -- Reference official documentation and best practices -- Suggest how technical implementations typically align with enterprise requirements"; - } - - // Create the agent with appropriate tool configuration - Console.WriteLine("๐Ÿ› ๏ธ Configuring agent tools..."); - var availableTools = new List(); - if (sharepointTool != null) - { - availableTools.AddRange(sharepointTool.Definitions); - } - availableTools.AddRange(mcpTool.Definitions); - Console.WriteLine($" Available tools: {availableTools.Count}"); - - var agent = await projectClient.CreateAgentAsync( - Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"), - "Modern Workplace Assistant", - instructions, - availableTools - ); - - Console.WriteLine($"โœ… Agent created successfully: {agent.Id}"); - return new AgentConfiguration - { - Agent = agent, - McpTool = mcpTool, - SharepointTool = sharepointTool - }; - } - #endregion create_workplace_assistant - - #region demonstrate_business_scenarios - /// - /// Demonstrate realistic business scenarios combining internal and external knowledge. - /// - /// This function showcases the practical value of the Modern Workplace Assistant - /// by walking through scenarios that enterprise employees face regularly. - /// - /// Educational Value: - /// - Shows real business problems that AI agents can solve - /// - Demonstrates integration between internal policies and external guidance - /// - Illustrates how AI can bridge the gap between requirements and implementation - /// - public static async Task DemonstrateBusinessScenariosAsync(AgentConfiguration config) - { - var scenarios = new[] - { - new BusinessScenario - { - Title = "๐Ÿ“‹ Company Policy Question", - Question = "What is our remote work security policy regarding multi-factor authentication?", - Context = "Employee needs to understand company MFA requirements", - ExpectedSource = "SharePoint", - LearningPoint = "Internal policy retrieval and interpretation" - }, - new BusinessScenario - { - Title = "๐Ÿ”ง Technical Implementation Question", - Question = "How do I set up Azure Active Directory conditional access policies?", - Context = "IT administrator needs technical implementation steps", - ExpectedSource = "Microsoft Learn MCP", - LearningPoint = "External technical documentation access" - }, - new BusinessScenario - { - Title = "๐Ÿ”„ Combined Business Implementation Question", - Question = "Our company security policy requires multi-factor authentication for remote workers. How do I implement this requirement using Azure AD?", - Context = "Need to combine policy requirements with technical implementation", - ExpectedSource = "Both SharePoint and MCP", - LearningPoint = "Multi-source intelligence combining internal requirements with external implementation" - } - }; - - Console.WriteLine($"\n{new string('=', 70)}"); - Console.WriteLine("๐Ÿข MODERN WORKPLACE ASSISTANT - BUSINESS SCENARIO DEMONSTRATION"); - Console.WriteLine(new string('=', 70)); - Console.WriteLine("This demonstration shows how AI agents solve real business problems"); - Console.WriteLine("by combining internal company knowledge with external technical guidance."); - Console.WriteLine(new string('=', 70)); - - for (int i = 0; i < scenarios.Length; i++) - { - var scenario = scenarios[i]; - Console.WriteLine($"\n๐Ÿ“Š SCENARIO {i + 1}/3: {scenario.Title}"); - Console.WriteLine(new string('-', 50)); - Console.WriteLine($"โ“ QUESTION: {scenario.Question}"); - Console.WriteLine($"๐ŸŽฏ BUSINESS CONTEXT: {scenario.Context}"); - Console.WriteLine($"๐Ÿ“š EXPECTED SOURCE: {scenario.ExpectedSource}"); - Console.WriteLine($"๐ŸŽ“ LEARNING POINT: {scenario.LearningPoint}"); - Console.WriteLine(new string('-', 50)); - - // Get response from the agent - Console.WriteLine("๐Ÿค– ASSISTANT RESPONSE:"); - var response = await ChatWithAssistantAsync(config.Agent.Id, config.McpTool, scenario.Question); - - // Display response with analysis - if (response.Status == "completed" && !string.IsNullOrWhiteSpace(response.Content) && response.Content.Trim().Length > 10) - { - var preview = response.Content.Length > 300 ? response.Content.Substring(0, 300) + "..." : response.Content; - Console.WriteLine($"โœ… SUCCESS: {preview}"); - if (response.Content.Length > 300) - { - Console.WriteLine($" ๐Ÿ“ Full response: {response.Content.Length} characters"); - } - } - else - { - Console.WriteLine($"โš ๏ธ LIMITED RESPONSE: {response.Content}"); - if (config.SharepointTool == null && scenario.ExpectedSource.Contains("SharePoint")) - { - Console.WriteLine(" ๐Ÿ’ก This demonstrates graceful degradation when SharePoint is unavailable"); - } - } - - Console.WriteLine($"๐Ÿ“ˆ STATUS: {response.Status}"); - Console.WriteLine(new string('-', 50)); - } - - Console.WriteLine("\nโœ… DEMONSTRATION COMPLETED!"); - Console.WriteLine("๐ŸŽ“ Key Learning Outcomes:"); - Console.WriteLine(" โ€ข Multi-source data integration in enterprise AI"); - Console.WriteLine(" โ€ข Robust error handling and graceful degradation"); - Console.WriteLine(" โ€ข Real business value through combined intelligence"); - Console.WriteLine(" โ€ข Foundation for governance and monitoring (Tutorials 2-3)"); - } - - /// - /// Execute a conversation with the workplace assistant. - /// - /// This function demonstrates the conversation pattern for Azure AI Foundry agents - /// and includes comprehensive error handling for production readiness. - /// - /// Educational Value: - /// - Shows proper thread management and conversation flow - /// - Demonstrates streaming response handling - /// - Includes timeout and error management patterns - /// - public static async Task ChatWithAssistantAsync(string agentId, McpTool mcpTool, string message) - { - try - { - // Create conversation thread (maintains conversation context) - var thread = await projectClient.CreateThreadAsync(); - - // Add user message to thread - await projectClient.CreateMessageAsync(thread.Id, "user", message); - - // Execute the conversation with streaming response - var runStream = projectClient.CreateAndStreamRunAsync(thread.Id, agentId); - - // Collect streaming response - var responseParts = new List(); - var finalStatus = "unknown"; - - await foreach (var eventData in runStream) - { - if (eventData.EventType == "MessageDelta") - { - var delta = eventData.Data as dynamic; - foreach (var contentPart in delta?.delta?.content ?? new object[0]) - { - if (contentPart?.text?.value != null) - { - responseParts.Add(contentPart.text.value.ToString()); - } - } - } - if (eventData.RunStatus != null) - { - finalStatus = eventData.RunStatus.Status; - } - } - - var fullResponse = string.Join("", responseParts); - return new ChatResult { Content = fullResponse, Status = finalStatus }; - } - catch (Exception ex) - { - return new ChatResult { Content = $"Error in conversation: {ex.Message}", Status = "failed" }; - } - } - - /// - /// Interactive mode for testing the workplace assistant. - /// - /// This provides a simple interface for users to test the agent with their own questions - /// and see how it combines different data sources for comprehensive answers. - /// - public static async Task InteractiveModeAsync(AgentConfiguration config) - { - Console.WriteLine($"\n{new string('=', 60)}"); - Console.WriteLine("๐Ÿ’ฌ INTERACTIVE MODE - Test Your Workplace Assistant!"); - Console.WriteLine(new string('=', 60)); - Console.WriteLine("Ask questions that combine company policies with technical guidance:"); - Console.WriteLine("โ€ข 'What's our remote work policy for Azure access?'"); - Console.WriteLine("โ€ข 'How do I configure SharePoint security?'"); - Console.WriteLine("โ€ข 'Our policy requires encryption - how do I set this up in Azure?'"); - Console.WriteLine("Type 'quit' to exit."); - Console.WriteLine(new string('-', 60)); - - while (true) - { - try - { - Console.Write("\nโ“ Your question: "); - var question = Console.ReadLine()?.Trim(); - - if (string.IsNullOrEmpty(question)) - { - Console.WriteLine("๐Ÿ’ก Please ask a question about policies or technical implementation."); - continue; - } - - if (new[] { "quit", "exit", "bye" }.Contains(question.ToLower())) - { - break; - } - - Console.Write("\n๐Ÿค– Workplace Assistant: "); - var response = await ChatWithAssistantAsync(config.Agent.Id, config.McpTool, question); - Console.WriteLine(response.Content); - - if (response.Status != "completed") - { - Console.WriteLine($"\nโš ๏ธ Response status: {response.Status}"); - } - - Console.WriteLine(new string('-', 60)); - } - catch (Exception ex) - { - Console.WriteLine($"\nโŒ Error: {ex.Message}"); - Console.WriteLine(new string('-', 60)); - } - } - - Console.WriteLine("\n๐Ÿ‘‹ Thank you for testing the Modern Workplace Assistant!"); - } - #endregion demonstrate_business_scenarios - - #region main - /// - /// Main execution flow demonstrating the complete sample. - /// - /// This orchestrates the full demonstration: - /// 1. Agent creation with diagnostic information - /// 2. Business scenario demonstration - /// 3. Interactive testing mode - /// 4. Clean completion with next steps - /// - public static async Task Main(string[] args) - { - Console.WriteLine("๐Ÿš€ Azure AI Foundry - Modern Workplace Assistant"); - Console.WriteLine("Tutorial 1: Building Enterprise Agents with SharePoint + MCP Integration"); - Console.WriteLine(new string('=', 70)); - - try - { - // Create the agent with full diagnostic output - var agentConfig = await CreateWorkplaceAssistantAsync(); - - // Demonstrate business scenarios - await DemonstrateBusinessScenariosAsync(agentConfig); - - // Offer interactive testing - Console.Write("\n๐ŸŽฏ Try interactive mode? (y/n): "); - var answer = Console.ReadLine()?.ToLower(); - if (answer?.StartsWith("y") == true) - { - await InteractiveModeAsync(agentConfig); - } - - Console.WriteLine("\n๐ŸŽ‰ Sample completed successfully!"); - Console.WriteLine("๐Ÿ“š This foundation supports Tutorial 2 (Governance) and Tutorial 3 (Production)"); - Console.WriteLine("๐Ÿ”— Next: Add evaluation metrics, monitoring, and production deployment"); - } - catch (Exception ex) - { - Console.WriteLine($"โŒ Sample failed: {ex.Message}"); - Environment.Exit(1); - } - } - #endregion main - } -} \ No newline at end of file diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/README.md b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/README.md deleted file mode 100644 index 22ce8bc2e..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/README.md +++ /dev/null @@ -1,249 +0,0 @@ -# Modern Workplace Assistant - C# Sample - -This sample demonstrates building enterprise AI agents with Azure AI Foundry, combining SharePoint integration for internal company knowledge with Microsoft Learn MCP integration for external technical guidance. - -## ๐ŸŽฏ Business Scenario - -The **Modern Workplace Assistant** helps Contoso Corporation employees with: - -- **Company Policy Questions**: "What is our remote work security policy?" -- **Technical Implementation**: "How do I configure Azure AD Conditional Access?" -- **Combined Guidance**: "Our policy requires MFA - how do I implement this in Azure AD?" - -This represents realistic enterprise scenarios where employees need both internal requirements and external implementation guidance. - -## ๐Ÿ—๏ธ Architecture - -``` -โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ Modern Workplace Assistant โ”‚ -โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ ๐Ÿค– Azure AI Foundry Agent (gpt-4o) โ”‚ -โ”‚ โ”œโ”€โ”€ ๐Ÿ“ SharePoint Tool (Internal Knowledge) โ”‚ -โ”‚ โ”‚ โ””โ”€โ”€ Company policies, procedures, governance โ”‚ -โ”‚ โ””โ”€โ”€ ๐Ÿ“š Microsoft Learn MCP (External Knowledge) โ”‚ -โ”‚ โ””โ”€โ”€ Azure docs, best practices, implementation โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ -``` - -## ๐Ÿ“ Sample Structure - -``` -simple-agent-csharp/ -โ”œโ”€โ”€ ๐Ÿ”ง Program.cs # Core agent implementation (400+ lines) -โ”œโ”€โ”€ ๐Ÿ“Š Evaluate.cs # Business-focused evaluation system -โ”œโ”€โ”€ โ“ questions.jsonl # Test questions for evaluation -โ”œโ”€โ”€ ๐Ÿ“– README.md # This comprehensive guide -โ”œโ”€โ”€ โš™๏ธ .env.template # Configuration template -โ”œโ”€โ”€ ๐Ÿ”จ ModernWorkplaceAssistant.csproj # .NET project file with dependencies -โ”œโ”€โ”€ ๐Ÿ“„ SAMPLE_SHAREPOINT_CONTENT.md # Business documents to upload -โ””โ”€โ”€ ๐Ÿ”ง setup_sharepoint.py # SharePoint document upload utility -``` - -## ๐Ÿš€ Quick Start - -### 1. Prerequisites - -- **.NET 8 SDK** or later -- **Azure AI Foundry Project** with SharePoint connection configured -- **Microsoft Learn MCP Server** running (see MCP_SERVERS.md) -- **Azure CLI** authenticated to your tenant - -### 2. Configuration - -Copy the environment template and configure your settings: - -```bash -cp .env.template .env -``` - -Edit `.env` with your specific values: - -```properties -# Azure AI Foundry Configuration -PROJECT_ENDPOINT=https://your-project.cognitiveservices.azure.com/ -MODEL_DEPLOYMENT_NAME=gpt-4o -AI_FOUNDRY_TENANT_ID=your-tenant-id - -# SharePoint Integration -SHAREPOINT_RESOURCE_NAME=Benefits - -# Microsoft Learn MCP Server -MCP_SERVER_URL=https://learn.microsoft.com/api/mcp -``` - -### 3. SharePoint Document Setup - -Upload sample business documents to your SharePoint site: - -```bash -# Use the Python setup script (requires Python) -python setup_sharepoint.py - -# Or manually upload SAMPLE_SHAREPOINT_CONTENT.md files to: -# https://yourtenant.sharepoint.com/sites/benefits/Shared Documents/ -``` - -**Required Documents:** - -1. **Remote Work Security Policy** - Company MFA and security requirements -2. **IT Security Guidelines** - Technical implementation standards -3. **Employee Handbook** - General policies and procedures -4. **Compliance Requirements** - Governance and regulatory requirements - -### 4. Build and Run - -```bash -# Restore dependencies -dotnet restore - -# Build the project -dotnet build - -# Run the main sample -dotnet run - -# Run evaluation system (compile and run separately) -dotnet build Evaluate.cs && dotnet run Evaluate.dll -``` - -## ๐Ÿงช Interactive Testing - -The sample includes an interactive mode for testing: - -```bash -dotnet run -# Choose 'y' when prompted for interactive mode - -# Try these example questions: -โ“ What is our company MFA policy? -โ“ How do I configure Azure Conditional Access? -โ“ Our policy requires encryption - how do I set this up? -``` - -## ๐Ÿ“Š Evaluation System - -Run comprehensive evaluation with business-focused metrics: - -```bash -# Compile and run evaluation separately -dotnet build Evaluate.cs && dotnet run Evaluate.dll -``` - -**Evaluation Dimensions:** - -- **Completeness**: Does it answer the full question? -- **Accuracy**: Is the information technically correct? -- **Actionability**: Can users take concrete next steps? -- **Source Integration**: Does it combine internal/external sources? -- **Business Context**: Does it understand enterprise requirements? -- **Performance**: Response time and user experience - -## ๐Ÿ”ง Troubleshooting - -### SharePoint Connection Issues - -If you see `SharePoint connection has invalid target: '_'`: - -1. **Check Azure AI Foundry Portal**: - - Go to Management Center > Connected Resources - - Edit your SharePoint connection - - Verify the target URL matches your site - -2. **Verify Permissions**: - - Ensure your Azure identity has access to the SharePoint site - - Test SharePoint access manually in browser - -3. **Connection Name**: - - Verify `SHAREPOINT_RESOURCE_NAME` matches the connection name exactly - - Connection names are case-sensitive - -### MCP Server Issues - -If Microsoft Learn MCP connection fails: - -1. **Check Server URL**: Verify `MCP_SERVER_URL` is accessible -2. **Network Access**: Ensure your environment can reach external URLs -3. **Approval Mode**: The sample sets approval mode to "never" for demos - -### Authentication Issues - -If you see authentication errors: - -1. **Azure CLI Login**: Run `az login` and select correct tenant -2. **Tenant ID**: Verify `AI_FOUNDRY_TENANT_ID` matches your Azure AI Foundry tenant -3. **Permissions**: Ensure your identity has AI Foundry access - -## ๐ŸŽ“ Educational Value - -This sample teaches enterprise AI development patterns: - -### **Multi-Source Data Integration** - -- Combining internal company knowledge (SharePoint) with external guidance (MCP) -- Dynamic agent capabilities based on available data sources -- Graceful degradation when data sources are unavailable - -### **Production-Ready Error Handling** - -- Comprehensive diagnostic information during setup -- Clear troubleshooting guidance when connections fail -- User-friendly error messages with actionable solutions - -### **Business-Focused Evaluation** - -- Evaluation metrics that matter for enterprise deployment -- Assessment of business value, not just technical accuracy -- Foundation for governance and monitoring (Tutorials 2-3) - -### **Enterprise Architecture Patterns** - -- Proper authentication and credential management -- Configuration management with environment variables -- Scalable code structure for complex business scenarios - -## ๐Ÿ”— Tutorial Series Context - -This is **Tutorial 1** in the Azure AI Foundry enterprise development series: - -- **Tutorial 1** (This Sample): Build foundation with SharePoint + MCP integration -- **Tutorial 2**: Add governance, monitoring, and evaluation frameworks -- **Tutorial 3**: Production deployment, scaling, and operations - -## ๐Ÿ“š Key Learning Outcomes - -After completing this sample, you'll understand: - -โœ… **Enterprise AI Agent Architecture**: Multi-source data integration patterns -โœ… **SharePoint Integration**: Internal knowledge access for AI agents -โœ… **MCP Integration**: External knowledge source integration -โœ… **Business Scenario Design**: Realistic enterprise use cases -โœ… **Error Handling**: Production-ready resilience patterns -โœ… **Evaluation Frameworks**: Business-focused quality assessment -โœ… **Configuration Management**: Secure and scalable setup patterns - -## ๐Ÿš€ Next Steps - -1. **Customize for Your Business**: Replace sample policies with your actual documents -2. **Extend Agent Capabilities**: Add more tools and data sources -3. **Implement Governance**: Move to Tutorial 2 for monitoring and compliance -4. **Production Deployment**: Use Tutorial 3 for scaling and operations - -## ๐Ÿ” Code Highlights - -### Program.cs Key Features: - -- **400+ lines** of comprehensive enterprise AI implementation -- **Educational comments** explaining each business pattern and technical decision -- **Interactive demonstration mode** with 3 realistic business scenarios -- **Robust error handling** with clear troubleshooting guidance -- **Dynamic agent configuration** based on available data sources - -### C# Specific Features: - -- **Modern C# patterns**: Async/await, nullable reference types, record types -- **Dependency injection ready**: Easily integrate with ASP.NET Core applications -- **Strong typing**: Compile-time safety and IntelliSense support -- **Performance optimized**: Efficient memory usage and streaming responses - -This sample provides a complete foundation for building production-ready enterprise AI agents with Azure AI Foundry using C# and .NET! ๐ŸŽ‰ \ No newline at end of file diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md deleted file mode 100644 index dbc930527..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md +++ /dev/null @@ -1,176 +0,0 @@ -# Sample SharePoint Content for Tutorial Series - -To create a coherent business scenario, upload these sample documents to your SharePoint site: - -## Document Structure - -### ๐Ÿ“ Shared Documents/Policies/ -1. **remote-work-policy.docx** -2. **security-guidelines.docx** -3. **collaboration-standards.docx** -4. **data-governance-policy.docx** - -### ๐Ÿ“ Shared Documents/Procedures/ -1. **employee-onboarding.docx** -2. **project-workflow.docx** -3. **incident-response.docx** - ---- - -## Sample Document Content - -### 1. Remote Work Policy (remote-work-policy.docx) - -``` -CONTOSO CORP - REMOTE WORK POLICY - -Effective Date: January 2024 - -OVERVIEW -Contoso Corp supports flexible work arrangements including remote work to enhance employee productivity and work-life balance. - -ELIGIBILITY -- Full-time employees after 90-day probationary period -- Manager approval required -- Role must be suitable for remote work - -TECHNOLOGY REQUIREMENTS -- Secure VPN connection required -- Use of Microsoft 365 and Azure services mandatory -- Multi-factor authentication enabled -- Personal devices must meet security standards - -SECURITY PROTOCOLS -- All data must be stored in approved cloud services (SharePoint, OneDrive) -- No sensitive data on personal devices -- Regular security training completion required -- Incident reporting within 2 hours - -COLLABORATION TOOLS -- Microsoft Teams for meetings and communication -- SharePoint for document collaboration -- Azure DevOps for development projects -- Outlook for email and calendar management - -REVIEW -This policy is reviewed annually and updated as needed. -``` - -### 2. Security Guidelines (security-guidelines.docx) - -``` -CONTOSO CORP - INFORMATION SECURITY GUIDELINES - -OVERVIEW -These guidelines ensure the protection of Contoso's information assets and compliance with industry standards. - -AZURE SECURITY REQUIREMENTS -- All cloud resources must use Azure Active Directory -- Enable Azure Security Center monitoring -- Implement Azure Key Vault for secrets management -- Use Azure Policy for compliance enforcement - -ACCESS MANAGEMENT -- Role-based access control (RBAC) mandatory -- Privileged Identity Management (PIM) for admin roles -- Regular access reviews quarterly -- Conditional access policies enforced - -DATA PROTECTION -- Data classification using Microsoft Purview -- Encryption at rest and in transit -- Regular backup verification -- Data retention policies enforced - -INCIDENT RESPONSE -- Use Azure Sentinel for threat detection -- Report security incidents immediately -- Follow established escalation procedures -- Document all security events -``` - -### 3. Collaboration Standards (collaboration-standards.docx) - -``` -CONTOSO CORP - COLLABORATION STANDARDS - -DOCUMENT MANAGEMENT -- All business documents stored in SharePoint Online -- Version control enabled for all document libraries -- Metadata required: Department, Project, Classification -- Folder structure: /Department/Project/Year/ - -COMMUNICATION GUIDELINES -- Microsoft Teams for internal communication -- Email for external communication only -- Weekly team meetings via Teams -- Project updates in SharePoint lists - -DEVELOPMENT STANDARDS -- Source code in Azure DevOps repositories -- CI/CD pipelines for all applications -- Code reviews required for all changes -- Azure Monitor for application monitoring - -TRAINING REQUIREMENTS -- Microsoft 365 certification within 6 months -- Azure fundamentals for technical staff -- Security awareness training quarterly -- Collaboration tools training for new hires -``` - -### 4. Data Governance Policy (data-governance-policy.docx) - -``` -CONTOSO CORP - DATA GOVERNANCE POLICY - -DATA CLASSIFICATION -- Public: Marketing materials, published content -- Internal: Business documents, policies, procedures -- Confidential: Financial data, employee records -- Restricted: Legal documents, intellectual property - -STORAGE REQUIREMENTS -- Public: SharePoint sites, public websites -- Internal: SharePoint document libraries with access controls -- Confidential: Restricted SharePoint sites with encryption -- Restricted: Azure Key Vault, encrypted storage accounts - -MICROSOFT 365 COMPLIANCE -- Data Loss Prevention (DLP) policies enabled -- Sensitivity labels applied to all documents -- Retention policies configured by data type -- eDiscovery capabilities for legal requirements - -AZURE DATA SERVICES -- Azure SQL Database for structured data -- Azure Data Lake for analytics workloads -- Azure Synapse for data warehousing -- Power BI for business intelligence -``` - ---- - -## Business Scenario Test Questions - -These questions demonstrate the coherent business use case: - -### Internal Policy Questions (SharePoint) -- "What is our remote work policy regarding VPN requirements?" -- "What are the security protocols for remote employees?" -- "How should we classify confidential business documents?" -- "What collaboration tools are approved for internal use?" - -### Technical Implementation Questions (MCP - Microsoft Learn) -- "How do I set up Azure Active Directory for our remote workers?" -- "What are the steps to configure Azure Security Center monitoring?" -- "How do I implement data loss prevention in Microsoft 365?" -- "How do I set up conditional access policies in Azure AD?" - -### Hybrid Questions (Both Sources) -- "Our remote work policy requires secure VPN - how do I implement Azure VPN Gateway?" -- "What Azure services do I need to meet our data governance requirements?" -- "How do I configure Microsoft Teams to comply with our collaboration standards?" -- "What Azure security services align with our incident response procedures?" - -This creates a **realistic business scenario** where the AI assistant helps employees understand company policies AND implement them using Microsoft technologies. \ No newline at end of file diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/questions.jsonl b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/questions.jsonl deleted file mode 100644 index a7d843526..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/questions.jsonl +++ /dev/null @@ -1,8 +0,0 @@ -{"question": "What is our remote work policy regarding security requirements?", "expected_keywords": ["remote", "work", "security", "VPN", "authentication"]} -{"question": "How do I set up Azure Active Directory conditional access?", "expected_keywords": ["Azure", "Active Directory", "conditional access", "configure"]} -{"question": "What collaboration tools are approved for internal use?", "expected_keywords": ["Teams", "SharePoint", "collaboration", "approved"]} -{"question": "How do I implement multi-factor authentication in Azure AD?", "expected_keywords": ["multi-factor", "authentication", "Azure", "MFA", "implement"]} -{"question": "Get current weather data", "expected": "weather"} -{"question": "Summarize Q3 performance", "expected": "performance"} -{"question": "Research market trends", "expected": "research"} -{"question": "Research market trends", "expected": "research"} \ No newline at end of file diff --git a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py b/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py deleted file mode 100644 index a5c424873..000000000 --- a/samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env python3 -""" -SharePoint Connection Setup Guide and Diagnostic Tool -Helps configure SharePoint for the tutorial series foundation. -""" - -import os -from agent import project_client -from dotenv import load_dotenv - -load_dotenv() - -def check_sharepoint_connection_detailed(): - """Get detailed SharePoint connection information""" - - print("๐Ÿ” SharePoint Connection Analysis") - print("="*50) - - try: - connection_name = os.environ["SHAREPOINT_RESOURCE_NAME"] - conn = project_client.connections.get(name=connection_name) - - print(f"โœ… Connection Found: {conn.name}") - print(f"๐Ÿ†” ID: {conn.id}") - print(f"๐Ÿท๏ธ Type: {conn.type}") - print(f"๐Ÿ“‹ Metadata: {conn.metadata}") - print(f"๐Ÿ” Credentials: {conn.credentials}") - print(f"๐ŸŽฏ Target: {conn.target}") - print(f"๐Ÿ”ง Is Default: {conn.is_default}") - - # Analyze the issue - if conn.target == "_": - print(f"\nโŒ ISSUE IDENTIFIED: SharePoint site URL is not configured") - print(f" The 'target' field should contain your SharePoint site URL") - print(f" Current value: '{conn.target}'") - return False - else: - print(f"\nโœ… SharePoint site URL is configured: {conn.target}") - return True - - except Exception as e: - print(f"โŒ Error: {e}") - return False - -def provide_sharepoint_setup_instructions(): - """Provide step-by-step SharePoint setup instructions""" - - print(f"\n๐Ÿ› ๏ธ SHAREPOINT CONNECTION SETUP GUIDE") - print("="*50) - - print("To fix the SharePoint connection for this tutorial series:") - - print(f"\n1๏ธโƒฃ **Go to Azure AI Foundry Portal:**") - print(" - Navigate to https://ai.azure.com") - print(" - Sign in with your Azure account") - print(" - Select your AI Foundry project") - - print(f"\n2๏ธโƒฃ **Configure SharePoint Connection:**") - print(" - Go to 'Settings' > 'Connections'") - print(" - Find your 'Documentor' connection") - print(" - Click 'Edit' or 'Configure'") - - print(f"\n3๏ธโƒฃ **Set SharePoint Site URL:**") - print(" - Enter your SharePoint site URL in format:") - print(" โ€ข https://[tenant].sharepoint.com/sites/[sitename]") - print(" โ€ข Example: https://contoso.sharepoint.com/sites/documents") - print(" - OR use root site: https://[tenant].sharepoint.com") - - print(f"\n4๏ธโƒฃ **Verify Authentication:**") - print(" - Ensure the connection has proper permissions") - print(" - Test the connection in the portal") - print(" - Make sure your Azure AI service can access SharePoint") - - print(f"\n5๏ธโƒฃ **Alternative: Use Microsoft 365 Developer Tenant:**") - print(" - Get free access: https://developer.microsoft.com/microsoft-365/dev-program") - print(" - Includes SharePoint Online with sample data") - print(" - Perfect for tutorials and development") - - print(f"\n๐Ÿ’ก **For Tutorial Series Success:**") - print(" This SharePoint connection will be used across all 3 tutorials for:") - print(" โ€ข Evaluation datasets (Tutorial 2)") - print(" โ€ข Red-teaming scenarios (Tutorial 2)") - print(" โ€ข Production monitoring data (Tutorial 3)") - print(" โ€ข AI gateway integration (Tutorial 3)") - -def suggest_sharepoint_content_structure(): - """Suggest SharePoint content structure for the tutorial series""" - - print(f"\n๐Ÿ“ RECOMMENDED SHAREPOINT CONTENT STRUCTURE") - print("="*50) - print("For maximum tutorial effectiveness, organize your SharePoint with:") - - print(f"\n๐Ÿ“‚ **Document Libraries:**") - print(" โ€ข 'Shared Documents' - Main content library") - print(" โ€ข 'Policies' - Company policies and guidelines") - print(" โ€ข 'Projects' - Project documentation") - print(" โ€ข 'Training Materials' - Learning resources") - - print(f"\n๐Ÿ“„ **Sample Documents to Add:**") - print(" โ€ข Remote work policy document") - print(" โ€ข Employee handbook") - print(" โ€ข Project status reports") - print(" โ€ข Technical documentation") - print(" โ€ข Meeting notes and minutes") - - print(f"\n๐ŸŽฏ **Why This Helps the Tutorial Series:**") - print(" โ€ข Tutorial 1: Agent can find and discuss real content") - print(" โ€ข Tutorial 2: Realistic evaluation scenarios with actual data") - print(" โ€ข Tutorial 3: Production-like monitoring with meaningful content") - -def test_sharepoint_once_fixed(): - """Provide a test script for once SharePoint is fixed""" - - print(f"\n๐Ÿงช TEST SCRIPT (Run After Fixing SharePoint)") - print("="*50) - - test_script = ''' -# Save this as test_fixed_sharepoint.py and run after fixing the connection: - -from agent import create_single_agent, project_client, create_mcp_tool -from azure.ai.agents.models import SharepointTool -import time -import os - -def test_real_sharepoint(): - """Test SharePoint with real connection""" - - # Create SharePoint-only agent - sharepoint_conn = project_client.connections.get(name=os.environ["SHAREPOINT_RESOURCE_NAME"]) - sharepoint_tool = SharepointTool(connection_id=sharepoint_conn.id) - - agent = project_client.agents.create_agent( - model=os.environ["MODEL_DEPLOYMENT_NAME"], - name="sharepoint-tester", - instructions="You are a SharePoint assistant. Search and provide information from the connected SharePoint site.", - tools=sharepoint_tool.definitions - ) - - # Test questions that should work with real SharePoint - test_questions = [ - "What documents are in the Shared Documents library?", - "Are there any policy documents available?", - "What files can you find on this SharePoint site?", - "List the document libraries available" - ] - - print("Testing SharePoint connection...") - for question in test_questions: - thread = project_client.agents.threads.create() - project_client.agents.messages.create(thread_id=thread.id, role="user", content=question) - run = project_client.agents.runs.create(thread_id=thread.id, agent_id=agent.id) - - while run.status in ["queued", "in_progress", "requires_action"]: - time.sleep(1) - run = project_client.agents.runs.get(thread_id=thread.id, run_id=run.id) - - messages = list(project_client.agents.messages.list(thread_id=thread.id)) - for msg in messages: - if msg.role.value == "assistant" and msg.content: - print(f"Q: {question}") - print(f"A: {msg.content[0].text.value[:200]}...") - print("-" * 50) - break - -if __name__ == "__main__": - test_real_sharepoint() -''' - - print(test_script) - -def main(): - """Main diagnostic and setup guide""" - - print("๐Ÿš€ SharePoint Setup for Azure AI Foundry Tutorial Series") - print("This ensures your foundation supports all 3 tutorials") - - # Check current state - is_working = check_sharepoint_connection_detailed() - - if not is_working: - # Provide setup instructions - provide_sharepoint_setup_instructions() - suggest_sharepoint_content_structure() - test_sharepoint_once_fixed() - else: - print("โœ… SharePoint connection appears to be configured correctly!") - print("๐Ÿ’ก Proceed with testing the actual SharePoint functionality.") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/README.md b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/README.md index bfd4c839d..5d2af0a97 100644 --- a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/README.md +++ b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/README.md @@ -81,7 +81,8 @@ This implementation gives you full control over the inbound and outbound communi 2. Two subnets are needed as well: - **Agent Subnet** (e.g., 192.168.0.0/24): Hosts Agent client for Agent workloads, delegated to Microsoft.App/environments. The recommended size should be /24 for this delegated subnet. - **Private endpoint Subnet** (e.g. 192.168.1.0/24): Hosts private endpoints - - Ensure that the address spaces for these subnets do not overlap with any existing networks in your Azure environment or reserved IP ranges like the following: 169.254.0.0/16, 172.30.0.0/16, 172.31.0.0/16, 192.0.2.0/24, 0.0.0.0/8, 127.0.0.0/8, 100.100.0.0/17, 100.100.192.0/19, 100.100.224.0/19, 10.0.0.0/8. + - Ensure that the address spaces for the used VNET does not overlap with any existing networks in your Azure environment or reserved IP ranges like the following: 169.254.0.0/16,172.30.0.0/16,172.31.0.0/16,192.0.2.0/24,0.0.0.0/8,127.0.0.0/8,100.100.0.0/17,100.100.192.0/19,100.100.224.0/19,10.0.0.0/8. + This includes all address space(s) you have in your VNET if you have more than one, and peered VNETs. > **Notes:** - If you do not provide an existing virtual network, the template will create a new virtual network with the default address spaces and subnets described above. If you use an existing virtual network, make sure it already contains two subnets (Agent and Private Endpoint) before deploying the template. @@ -165,7 +166,7 @@ Click the deploy to Azure button above to open the Azure portal and deploy the t > **Note:** To access your Foundry resource securely, use either a VM, VPN, or ExpressRoute. ---- +--- ## Network Secured Agent Project Architecture Deep Dive @@ -349,6 +350,167 @@ modules-network-secured/ 4. Review network security groups --- +--- +# (Optional) Adding Multiple Projects to AI Foundry Deployment + +This guide explains how to add additional projects to your existing AI Foundry deployment with network security and capability hosts. + +## Overview + +After deploying your initial AI Foundry setup using `main.bicep`, you can add additional projects using the modular approach provided in this repository. Each new project will: + +- โœ… **Reuse existing shared infrastructure** (AI Services account, Storage, Cosmos DB, AI Search, VNet) +- โœ… **Create independent projects** with unique identities and connections +- โœ… **Set up proper role assignments** and capability hosts for each project +- โœ… **Maintain network security** configurations from your original deployment +- โœ… **Deploy independently** without affecting existing projects + +## Files Added + +### Core Deployment Files + +| File | Purpose | +|------|---------| +| `add-project.bicep` | Main Bicep template for adding new projects | +| `add-project.bicepparam` | Parameters file template for new projects | +| `modules-network-secured/ai-project-identity-unique.bicep` | Modified project module with unique connection names | +| `modules-network-secured/blob-storage-container-role-assignments-unique.bicep` | Modified storage role assignment module | + +### Helper Files + +| File | Purpose | +|------|---------| +| `get-existing-resources.ps1` | PowerShell script to discover existing resource names | + +## Prerequisites + +1. โœ… **Existing AI Foundry deployment** completed using `main.bicep` +2. โœ… **Azure CLI** installed and logged in +3. โœ… **Proper permissions** on the resource group and existing resources +4. โœ… **Resource names** from your existing deployment + +## Step-by-Step Guide + +### Step 1: Discover Existing Resource Names + +Run the PowerShell script to automatically discover your existing resource names: + +```powershell +# Navigate to your repository folder +cd "path\to\your\AgentRepro\folder" + +# Run the discovery script +.\get-existing-resources.ps1 -ResourceGroupName "your-resource-group-name" + +# Optional: Include subscription ID if needed +.\get-existing-resources.ps1 -ResourceGroupName "your-resource-group-name" -SubscriptionId "your-subscription-id" +``` + +**Example output:** +``` +=== Summary for add-project.bicepparam === +param existingAccountName = 'aiservicesytlz' +param existingAiSearchName = 'aiservicesytlzsearch' +param existingStorageName = 'aiservicesytlzstorage' +param existingCosmosDBName = 'aiservicesytlzcosmosdb' +param accountResourceGroupName = 'agenticvnet' +param aiSearchResourceGroupName = 'agenticvnet' +param storageResourceGroupName = 'agenticvnet' +param cosmosDBResourceGroupName = 'agenticvnet' +``` + +### Step 2: Configure Parameters File + +Copy the output from Step 1 and update your `add-project.bicepparam` file: + +### Step 3: Deploy the New Project + +Deploy using Azure CLI: + +```powershell +az deployment group create ` + --resource-group "your-resource-group" ` + --template-file "add-project.bicep" ` + --parameters "add-project.bicepparam" +``` + +## Adding Multiple Projects + +To add additional projects, repeat the process with different parameter values: + +### For a Third Project: + +1. **Update project-specific parameters:** + ```bicep + param projectName = 'thirdproject' // Must be unique + param displayName = 'Third Project' + param projectCapHost = 'caphostthird' // Must be unique + ``` + +3. **Deploy using the new parameters file:** + ```powershell + az deployment group create ` + --resource-group "your-resource-group" ` + --template-file "add-project.bicep" ` + --parameters "add-project.bicepparam" + ``` + +## What Gets Created + +Each new project deployment creates: + +| Resource | Description | +|----------|-------------| +| **AI Foundry Project** | New project under your existing AI Services account | +| **Managed Identity** | Project-specific system-assigned identity | +| **Unique Connections** | Project-specific connections to shared resources | +| **Capability Host** | Configured for Agents with proper connections | +| **RBAC Assignments** | Proper permissions on shared resources | + +### Role Assignments Created: + +- โœ… **Storage Blob Data Contributor** on Storage Account +- โœ… **Storage Blob Data Owner** on project-specific containers +- โœ… **Cosmos DB Operator** on Cosmos DB Account +- โœ… **Cosmos Built-In Data Contributor** on project-specific containers +- โœ… **Search Index Data Contributor** on AI Search Service +- โœ… **Search Service Contributor** on AI Search Service + +## Configuration Reference + +### Required Parameters (Must Customize for Each Project) + +| Parameter | Description | Example | +|-----------|-------------|---------| +| `projectName` | Unique name for the project | `'secondproject'` | +| `displayName` | Display name in Azure portal | `'Second Project'` | +| `projectCapHost` | Unique capability host name | `'caphostsecond'` | +| `projectDescription` | Description of the project | `'My second AI project'` | + +### Existing Resource Parameters (From Script) + +| Parameter | Description | Source | +|-----------|-------------|---------| +| `existingAccountName` | AI Services account name | Output from `get-existing-resources.ps1` | +| `existingAiSearchName` | AI Search service name | Output from `get-existing-resources.ps1` | +| `existingStorageName` | Storage account name | Output from `get-existing-resources.ps1` | +| `existingCosmosDBName` | Cosmos DB account name | Output from `get-existing-resources.ps1` | +| `*ResourceGroupName` | Resource group names | Usually same as deployment RG | +| `*SubscriptionId` | Subscription IDs | Usually same subscription | + + +## Security Considerations + +- โœ… **Least Privilege**: Each project gets only the permissions it needs +- โœ… **Isolated Containers**: Projects get separate storage containers +- โœ… **Network Security**: Inherits network security from original deployment +- โœ… **Unique Identities**: Each project has its own managed identity + +## Limitations + +- ๐Ÿ“ All projects share the same model deployments +- ๐Ÿ“ Projects must be in the same region as the original deployment +- ๐Ÿ“ Network configuration is inherited from original deployment ## References diff --git a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/add-project.bicep b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/add-project.bicep new file mode 100644 index 000000000..6a6d570df --- /dev/null +++ b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/add-project.bicep @@ -0,0 +1,197 @@ +@description('Location for the project resources.') +param location string = 'westus' + +@description('Name of the existing AI Services account') +param existingAccountName string + +@description('Resource group containing the AI Services account') +param accountResourceGroupName string = resourceGroup().name + +@description('Subscription ID containing the AI Services account') +param accountSubscriptionId string = subscription().subscriptionId + +@description('Name for the new project') +param projectName string + +@description('Description for the new project') +param projectDescription string = 'Additional AI Foundry project with network secured deployed Agent' + +@description('Display name for the new project') +param displayName string + +@description('Name for the project capability host') +param projectCapHost string = 'caphostproj' + +// Existing shared resources (from your original deployment) +@description('Name of the existing AI Search service') +param existingAiSearchName string + +@description('Resource group containing the AI Search service') +param aiSearchResourceGroupName string + +@description('Subscription ID containing the AI Search service') +param aiSearchSubscriptionId string + +@description('Name of the existing Storage Account') +param existingStorageName string + +@description('Resource group containing the Storage Account') +param storageResourceGroupName string + +@description('Subscription ID containing the Storage Account') +param storageSubscriptionId string + +@description('Name of the existing Cosmos DB account') +param existingCosmosDBName string + +@description('Resource group containing the Cosmos DB account') +param cosmosDBResourceGroupName string + +@description('Subscription ID containing the Cosmos DB account') +param cosmosDBSubscriptionId string + +// Create a short, unique suffix for this project +param deploymentTimestamp string = utcNow('yyyyMMddHHmmss') +var uniqueSuffix = substring(uniqueString('${resourceGroup().id}-${deploymentTimestamp}'), 0, 4) +var finalProjectName = toLower('${projectName}${uniqueSuffix}') + +// Reference existing AI Services account +resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' existing = { + name: existingAccountName + scope: resourceGroup(accountSubscriptionId, accountResourceGroupName) +} + +// Reference existing shared resources +resource aiSearch 'Microsoft.Search/searchServices@2023-11-01' existing = { + name: existingAiSearchName + scope: resourceGroup(aiSearchSubscriptionId, aiSearchResourceGroupName) +} + +resource storage 'Microsoft.Storage/storageAccounts@2022-05-01' existing = { + name: existingStorageName + scope: resourceGroup(storageSubscriptionId, storageResourceGroupName) +} + +resource cosmosDB 'Microsoft.DocumentDB/databaseAccounts@2024-11-15' existing = { + name: existingCosmosDBName + scope: resourceGroup(cosmosDBSubscriptionId, cosmosDBResourceGroupName) +} + +// Create the new project using the unique connection module +module aiProject 'modules-network-secured/ai-project-identity-unique.bicep' = { + name: 'ai-${finalProjectName}-${uniqueSuffix}-deployment' + params: { + projectName: finalProjectName + projectDescription: projectDescription + displayName: displayName + location: location + + aiSearchName: existingAiSearchName + aiSearchServiceResourceGroupName: aiSearchResourceGroupName + aiSearchServiceSubscriptionId: aiSearchSubscriptionId + + cosmosDBName: existingCosmosDBName + cosmosDBSubscriptionId: cosmosDBSubscriptionId + cosmosDBResourceGroupName: cosmosDBResourceGroupName + + azureStorageName: existingStorageName + azureStorageSubscriptionId: storageSubscriptionId + azureStorageResourceGroupName: storageResourceGroupName + + accountName: existingAccountName + + // Pass unique suffix for connection names + uniqueConnectionSuffix: '-${finalProjectName}' + } +} + +module formatProjectWorkspaceId 'modules-network-secured/format-project-workspace-id.bicep' = { + name: 'format-project-workspace-id-${uniqueSuffix}-deployment' + params: { + projectWorkspaceId: aiProject.outputs.projectWorkspaceId + } +} + +// Assign storage account role +module storageAccountRoleAssignment 'modules-network-secured/azure-storage-account-role-assignment.bicep' = { + name: 'storage-${existingStorageName}-${uniqueSuffix}-deployment' + scope: resourceGroup(storageSubscriptionId, storageResourceGroupName) + params: { + azureStorageName: existingStorageName + projectPrincipalId: aiProject.outputs.projectPrincipalId + } +} + +// Assign Cosmos DB account role +module cosmosAccountRoleAssignments 'modules-network-secured/cosmosdb-account-role-assignment.bicep' = { + name: 'cosmos-account-ra-${finalProjectName}-${uniqueSuffix}-deployment' + scope: resourceGroup(cosmosDBSubscriptionId, cosmosDBResourceGroupName) + params: { + cosmosDBName: existingCosmosDBName + projectPrincipalId: aiProject.outputs.projectPrincipalId + } +} + +// Assign AI Search role +module aiSearchRoleAssignments 'modules-network-secured/ai-search-role-assignments.bicep' = { + name: 'ai-search-ra-${finalProjectName}-${uniqueSuffix}-deployment' + scope: resourceGroup(aiSearchSubscriptionId, aiSearchResourceGroupName) + params: { + aiSearchName: existingAiSearchName + projectPrincipalId: aiProject.outputs.projectPrincipalId + } +} + +// Create capability host for the new project +module addProjectCapabilityHost 'modules-network-secured/add-project-capability-host.bicep' = { + name: 'capabilityHost-configuration-${uniqueSuffix}-deployment' + params: { + accountName: existingAccountName + projectName: aiProject.outputs.projectName + cosmosDBConnection: aiProject.outputs.cosmosDBConnection + azureStorageConnection: aiProject.outputs.azureStorageConnection + aiSearchConnection: aiProject.outputs.aiSearchConnection + projectCapHost: projectCapHost + } + dependsOn: [ + cosmosAccountRoleAssignments + storageAccountRoleAssignment + aiSearchRoleAssignments + ] +} + +// Assign storage container roles after capability host creation +module storageContainersRoleAssignment 'modules-network-secured/blob-storage-container-role-assignments-unique.bicep' = { + name: 'storage-containers-${uniqueSuffix}-deployment' + scope: resourceGroup(storageSubscriptionId, storageResourceGroupName) + params: { + aiProjectPrincipalId: aiProject.outputs.projectPrincipalId + storageName: existingStorageName + workspaceId: formatProjectWorkspaceId.outputs.projectWorkspaceIdGuid + uniqueSuffix: uniqueSuffix // Add this line + } + dependsOn: [ + addProjectCapabilityHost + ] +} + +// Assign Cosmos container roles after capability host creation +module cosmosContainerRoleAssignments 'modules-network-secured/cosmos-container-role-assignments.bicep' = { + name: 'cosmos-ra-${uniqueSuffix}-deployment' + scope: resourceGroup(cosmosDBSubscriptionId, cosmosDBResourceGroupName) + params: { + cosmosAccountName: existingCosmosDBName + projectWorkspaceId: formatProjectWorkspaceId.outputs.projectWorkspaceIdGuid + projectPrincipalId: aiProject.outputs.projectPrincipalId + } + dependsOn: [ + addProjectCapabilityHost + storageContainersRoleAssignment + ] +} + +// Outputs +output projectName string = aiProject.outputs.projectName +output projectPrincipalId string = aiProject.outputs.projectPrincipalId +output projectWorkspaceId string = aiProject.outputs.projectWorkspaceId +output capabilityHostName string = addProjectCapabilityHost.outputs.projectCapHost diff --git a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/add-project.bicepparam b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/add-project.bicepparam new file mode 100644 index 000000000..127907979 --- /dev/null +++ b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/add-project.bicepparam @@ -0,0 +1,29 @@ +using './add-project.bicep' + +param location = 'westus' + +// New project details +param projectName = 'secondproject' +param projectDescription = 'Second AI Foundry project with network secured deployed Agent' +param displayName = 'Second Project' +param projectCapHost = 'caphostsecond' + +// Existing AI Services account details (from your original deployment) +// You'll need to get these from your existing deployment +param existingAccountName = '' // Replace with your actual account name +param accountResourceGroupName = '' // Your resource group +param accountSubscriptionId = '' + +// Existing shared resources (from your original deployment) +// You'll need to get these from your existing deployment outputs +param existingAiSearchName = '' // Replace with your actual search service name +param aiSearchResourceGroupName = '' // Your resource group +param aiSearchSubscriptionId = '' + +param existingStorageName = '' // Replace with your actual storage account name +param storageResourceGroupName = '' // Your resource group +param storageSubscriptionId = '' + +param existingCosmosDBName = '' // Replace with your actual Cosmos DB name +param cosmosDBResourceGroupName = '' // Your resource group +param cosmosDBSubscriptionId = '' diff --git a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/get-existing-resources.ps1 b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/get-existing-resources.ps1 new file mode 100644 index 000000000..76cca81a9 --- /dev/null +++ b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/get-existing-resources.ps1 @@ -0,0 +1,62 @@ +# PowerShell script to help you get the names of your existing resources +# Run this after your initial deployment to get the resource names for the add-project parameters + +param( + [Parameter(Mandatory=$true)] + [string]$ResourceGroupName, + + [Parameter(Mandatory=$false)] + [string]$SubscriptionId +) + +if ($SubscriptionId) { + az account set --subscription $SubscriptionId +} + +Write-Host "Getting existing AI Foundry resources from Resource Group: $ResourceGroupName" -ForegroundColor Green + +# Get AI Services account +Write-Host "`n=== AI Services Account ===" -ForegroundColor Yellow +$aiAccount = az cognitiveservices account list --resource-group $ResourceGroupName --query "[?kind=='AIServices'].[name]" -o tsv +if ($aiAccount) { + Write-Host "AI Services Account Name: $aiAccount" +} else { + Write-Host "No AI Services account found" -ForegroundColor Red +} + +# Get Storage Account +Write-Host "`n=== Storage Account ===" -ForegroundColor Yellow +$storageAccount = az storage account list --resource-group $ResourceGroupName --query "[].name" -o tsv +if ($storageAccount) { + Write-Host "Storage Account Name: $storageAccount" +} else { + Write-Host "No Storage account found" -ForegroundColor Red +} + +# Get AI Search Service +Write-Host "`n=== AI Search Service ===" -ForegroundColor Yellow +$searchService = az search service list --resource-group $ResourceGroupName --query "[].name" -o tsv +if ($searchService) { + Write-Host "AI Search Service Name: $searchService" +} else { + Write-Host "No AI Search service found" -ForegroundColor Red +} + +# Get Cosmos DB Account +Write-Host "`n=== Cosmos DB Account ===" -ForegroundColor Yellow +$cosmosAccount = az cosmosdb list --resource-group $ResourceGroupName --query "[].name" -o tsv +if ($cosmosAccount) { + Write-Host "Cosmos DB Account Name: $cosmosAccount" +} else { + Write-Host "No Cosmos DB account found" -ForegroundColor Red +} + +Write-Host "`n=== Summary for add-project.bicepparam ===" -ForegroundColor Green +Write-Host "param existingAccountName = '$aiAccount'" +Write-Host "param existingAiSearchName = '$searchService'" +Write-Host "param existingStorageName = '$storageAccount'" +Write-Host "param existingCosmosDBName = '$cosmosAccount'" +Write-Host "param accountResourceGroupName = '$ResourceGroupName'" +Write-Host "param aiSearchResourceGroupName = '$ResourceGroupName'" +Write-Host "param storageResourceGroupName = '$ResourceGroupName'" +Write-Host "param cosmosDBResourceGroupName = '$ResourceGroupName'" diff --git a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/main.bicepparam b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/main.bicepparam index 5f9d9e51a..43097a366 100644 --- a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/main.bicepparam +++ b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/main.bicepparam @@ -42,9 +42,26 @@ param dnsZoneNames = [ ] -// Network configuration: only used when existingVnetResourceId is not provided -// These addresses are only used when creating a new VNet and subnets -// If you provide existingVnetResourceId, these values will be ignored +// Network configuration (behavior depends on `existingVnetResourceId`) +// +// - NEW VNet (existingVnetResourceId is empty): +// The values below are used to CREATE the VNet and the two subnets. +// Provide explicit, non-overlapping CIDR ranges when creating a new VNet. +// +// - EXISTING VNet (existingVnetResourceId is provided): +// The module will reference the existing VNet. Subnet handling depends on the +// values you provide: +// * If `agentSubnetPrefix` or `peSubnetPrefix` are empty, the module may +// auto-derive subnet CIDRs from the existing VNet's address space +// (using cidrSubnet). This can produce /24 (or configured) subnets +// starting at index 0, 1, etc. +// * If you provide explicit subnet prefixes, the module will attempt to +// create or update subnets with those prefixes in the existing VNet. +// +// Important operational notes and risks (when existingVnetResourceId is provided): +// - Avoid CIDR overlaps with any existing subnets in the target VNet. Overlap +// leads to `NetcfgSubnetRangesOverlap` and failed deployments. +// - For highest safety when using an existing VNet, supply the existing `agentSubnetPrefix` and `peSubnetPrefix`. param vnetAddressPrefix = '' param agentSubnetPrefix = '' param peSubnetPrefix = '' diff --git a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/ai-project-identity-unique.bicep b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/ai-project-identity-unique.bicep new file mode 100644 index 000000000..471e1fb98 --- /dev/null +++ b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/ai-project-identity-unique.bicep @@ -0,0 +1,106 @@ +param accountName string +param location string +param projectName string +param projectDescription string +param displayName string + +param aiSearchName string +param aiSearchServiceResourceGroupName string +param aiSearchServiceSubscriptionId string + +param cosmosDBName string +param cosmosDBSubscriptionId string +param cosmosDBResourceGroupName string + +param azureStorageName string +param azureStorageSubscriptionId string +param azureStorageResourceGroupName string + +// Add unique connection name parameter +param uniqueConnectionSuffix string = '' + +resource searchService 'Microsoft.Search/searchServices@2024-06-01-preview' existing = { + name: aiSearchName + scope: resourceGroup(aiSearchServiceSubscriptionId, aiSearchServiceResourceGroupName) +} +resource cosmosDBAccount 'Microsoft.DocumentDB/databaseAccounts@2024-12-01-preview' existing = { + name: cosmosDBName + scope: resourceGroup(cosmosDBSubscriptionId, cosmosDBResourceGroupName) +} +resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' existing = { + name: azureStorageName + scope: resourceGroup(azureStorageSubscriptionId, azureStorageResourceGroupName) +} + +resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' existing = { + name: accountName + scope: resourceGroup() +} + +resource project 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = { + parent: account + name: projectName + location: location + identity: { + type: 'SystemAssigned' + } + properties: { + description: projectDescription + displayName: displayName + } + + // Use unique connection names by appending the suffix + resource project_connection_cosmosdb_account 'connections@2025-04-01-preview' = { + name: '${cosmosDBName}${uniqueConnectionSuffix}' + properties: { + category: 'CosmosDB' + target: cosmosDBAccount.properties.documentEndpoint + authType: 'AAD' + metadata: { + ApiType: 'Azure' + ResourceId: cosmosDBAccount.id + location: cosmosDBAccount.location + } + } + } + + resource project_connection_azure_storage 'connections@2025-04-01-preview' = { + name: '${azureStorageName}${uniqueConnectionSuffix}' + properties: { + category: 'AzureStorageAccount' + target: storageAccount.properties.primaryEndpoints.blob + authType: 'AAD' + metadata: { + ApiType: 'Azure' + ResourceId: storageAccount.id + location: storageAccount.location + } + } + } + + resource project_connection_azureai_search 'connections@2025-04-01-preview' = { + name: '${aiSearchName}${uniqueConnectionSuffix}' + properties: { + category: 'CognitiveSearch' + target: 'https://${aiSearchName}.search.windows.net' + authType: 'AAD' + metadata: { + ApiType: 'Azure' + ResourceId: searchService.id + location: searchService.location + } + } + } +} + +output projectName string = project.name +output projectId string = project.id +output projectPrincipalId string = project.identity.principalId + +#disable-next-line BCP053 +output projectWorkspaceId string = project.properties.internalId + +// Return the unique connection names +output cosmosDBConnection string = '${cosmosDBName}${uniqueConnectionSuffix}' +output azureStorageConnection string = '${azureStorageName}${uniqueConnectionSuffix}' +output aiSearchConnection string = '${aiSearchName}${uniqueConnectionSuffix}' diff --git a/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/blob-storage-container-role-assignments-unique.bicep b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/blob-storage-container-role-assignments-unique.bicep new file mode 100644 index 000000000..2535a42c9 --- /dev/null +++ b/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/blob-storage-container-role-assignments-unique.bicep @@ -0,0 +1,38 @@ +@description('Name of the storage account') +param storageName string + +@description('Principal ID of the AI Project') +param aiProjectPrincipalId string + +@description('Workspace Id of the AI Project') +param workspaceId string + +@description('Unique suffix to make role assignment unique') +param uniqueSuffix string + +// Reference existing storage account +resource storage 'Microsoft.Storage/storageAccounts@2022-05-01' existing = { + name: storageName + scope: resourceGroup() +} + +// Storage Blob Data Owner Role +resource storageBlobDataOwner 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { + name: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b' // Built-in role ID + scope: resourceGroup() +} + +var conditionStr= '((!(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/read\'}) AND !(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/filter/action\'}) AND !(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/write\'}) ) OR (@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringStartsWithIgnoreCase \'${workspaceId}\' AND @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringLikeIgnoreCase \'*-azureml-agent\'))' + +// Assign Storage Blob Data Owner role with unique name +resource storageBlobDataOwnerAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + scope: storage + name: guid(storageBlobDataOwner.id, storage.id, aiProjectPrincipalId, uniqueSuffix) + properties: { + principalId: aiProjectPrincipalId + roleDefinitionId: storageBlobDataOwner.id + principalType: 'ServicePrincipal' + conditionVersion: '2.0' + condition: conditionStr + } +} diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/.env.template b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/.env.template deleted file mode 100644 index 5107649cc..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/.env.template +++ /dev/null @@ -1,10 +0,0 @@ -# Azure AI Foundry Configuration -PROJECT_ENDPOINT=https://your-project.aiservices.azure.com -MODEL_DEPLOYMENT_NAME=gpt-4o -AI_FOUNDRY_TENANT_ID=your-ai-foundry-tenant-id - -# Microsoft Learn MCP Server (Works out-of-the-box!) -MCP_SERVER_URL=https://learn.microsoft.com/api/mcp - -# SharePoint Integration (Optional - requires additional setup) -SHAREPOINT_RESOURCE_NAME=your-sharepoint-connection diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/Evaluate.java b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/Evaluate.java deleted file mode 100644 index 6c0c14e38..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/Evaluate.java +++ /dev/null @@ -1,553 +0,0 @@ -/** - * Azure AI Foundry Evaluation Sample - Tutorial 1 - * - * This sample demonstrates comprehensive evaluation of AI agents in business contexts. - * It evaluates both technical accuracy and business value alignment, providing - * metrics that matter for enterprise AI deployments. - * - * Educational Focus: - * - Business-focused evaluation metrics beyond technical accuracy - * - Comprehensive response quality assessment - * - Foundation for Tutorial 2 (governance) evaluation frameworks - * - Real-world quality assurance patterns - * - * Business Context: - * Evaluates the Modern Workplace Assistant's ability to: - * 1. Retrieve accurate company policy information - * 2. Provide current technical implementation guidance - * 3. Combine internal requirements with external best practices - * 4. Deliver actionable guidance for business scenarios - */ - -import com.azure.ai.projects.AIProjectClient; -import com.azure.ai.projects.AIProjectClientBuilder; -import com.azure.ai.agents.models.*; -import com.azure.identity.DefaultAzureCredential; -import com.azure.identity.AzureCliCredential; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.*; -import java.util.stream.Collectors; - -public class Evaluate { - - // ============================================================================ - // EVALUATION CONFIGURATION - // ============================================================================ - - private static final Properties config = new Properties(); - private static AIProjectClient projectClient; - private static final ObjectMapper objectMapper = new ObjectMapper(); - - // Business-focused evaluation criteria - private static final String[] POLICY_KEYWORDS = { - "security", "authentication", "authorization", "compliance", - "governance", "remote work", "access control", "MFA", "multi-factor" - }; - - private static final String[] TECHNICAL_KEYWORDS = { - "Azure", "configuration", "implementation", "setup", "deployment", - "Active Directory", "Conditional Access", "PowerShell", "portal" - }; - - static { - try { - loadEnvironmentConfig(); - setupAuthentication(); - } catch (Exception e) { - System.err.println("Failed to initialize evaluation configuration: " + e.getMessage()); - System.exit(1); - } - } - - private static void loadEnvironmentConfig() throws IOException { - // Load .env file if it exists - if (Files.exists(Paths.get(".env"))) { - Files.lines(Paths.get(".env")) - .filter(line -> !line.trim().isEmpty() && !line.startsWith("#")) - .forEach(line -> { - String[] parts = line.split("=", 2); - if (parts.length == 2) { - config.setProperty(parts[0].trim(), parts[1].trim()); - } - }); - } - - // Override with system environment variables - System.getenv().forEach((key, value) -> { - if (config.containsKey(key) || key.startsWith("AI_FOUNDRY_") || - key.startsWith("PROJECT_") || key.startsWith("SHAREPOINT_") || - key.startsWith("MCP_") || key.startsWith("MODEL_")) { - config.setProperty(key, value); - } - }); - } - - private static void setupAuthentication() { - String tenantId = config.getProperty("AI_FOUNDRY_TENANT_ID"); - - if (tenantId != null && !tenantId.isEmpty()) { - projectClient = new AIProjectClientBuilder() - .endpoint(config.getProperty("PROJECT_ENDPOINT")) - .credential(new AzureCliCredential()) - .buildClient(); - } else { - projectClient = new AIProjectClientBuilder() - .endpoint(config.getProperty("PROJECT_ENDPOINT")) - .credential(new DefaultAzureCredential()) - .buildClient(); - } - } - - /** - * Load test questions from JSONL file. - * - * Educational Value: - * - Shows standardized evaluation data format - * - Demonstrates systematic testing approach - * - Provides reproducible evaluation scenarios - */ - public static List loadTestQuestions() throws IOException { - List questions = new ArrayList<>(); - - if (!Files.exists(Paths.get("questions.jsonl"))) { - System.out.println("โš ๏ธ questions.jsonl not found, using default test questions"); - return getDefaultTestQuestions(); - } - - List lines = Files.readAllLines(Paths.get("questions.jsonl")); - for (String line : lines) { - if (!line.trim().isEmpty()) { - try { - JsonNode node = objectMapper.readTree(line); - questions.add(new TestQuestion( - node.get("question").asText(), - node.get("category").asText(), - node.get("expected_sources").asText(), - node.get("context").asText() - )); - } catch (Exception e) { - System.out.println("โš ๏ธ Failed to parse question: " + line); - } - } - } - - return questions; - } - - private static List getDefaultTestQuestions() { - return Arrays.asList( - new TestQuestion( - "What is our company policy on remote work security requirements?", - "policy", - "sharepoint", - "Employee needs to understand security requirements for remote work" - ), - new TestQuestion( - "How do I configure Azure AD multi-factor authentication?", - "technical", - "mcp", - "IT administrator needs step-by-step MFA setup instructions" - ), - new TestQuestion( - "Our security policy requires MFA for all remote access. How do I implement this in Azure AD?", - "implementation", - "both", - "Combining company policy requirements with technical implementation steps" - ), - new TestQuestion( - "What are the latest Azure Conditional Access best practices?", - "technical", - "mcp", - "IT team needs current best practices for security configuration" - ) - ); - } - - /** - * Evaluate response quality using comprehensive business metrics. - * - * This evaluation goes beyond simple accuracy to assess business value, - * practical applicability, and enterprise readiness. - * - * Educational Value: - * - Shows multi-dimensional evaluation approach - * - Demonstrates business-relevant quality metrics - * - Provides foundation for governance and monitoring - */ - //#region evaluation_functions - public static EvaluationResult evaluateResponse(TestQuestion question, String response, long responseTimeMs) { - EvaluationResult result = new EvaluationResult(); - result.question = question.question; - result.category = question.category; - result.response = response; - result.responseTimeMs = responseTimeMs; - - // ==================================================================== - // BUSINESS VALUE ASSESSMENT - // ==================================================================== - - // 1. Completeness: Does the response address all aspects of the question? - result.completenessScore = evaluateCompleteness(question, response); - - // 2. Accuracy: Is the information technically correct and current? - result.accuracyScore = evaluateAccuracy(question, response); - - // 3. Actionability: Can the user take concrete next steps? - result.actionabilityScore = evaluateActionability(response); - - // 4. Source Integration: Does it properly combine internal/external sources? - result.sourceIntegrationScore = evaluateSourceIntegration(question, response); - - // 5. Business Context: Does it understand enterprise requirements? - result.businessContextScore = evaluateBusinessContext(question, response); - - // ==================================================================== - // PERFORMANCE METRICS - // ==================================================================== - - // Response time evaluation (important for user experience) - if (responseTimeMs < 5000) { - result.performanceScore = 1.0; - } else if (responseTimeMs < 10000) { - result.performanceScore = 0.8; - } else if (responseTimeMs < 20000) { - result.performanceScore = 0.6; - } else { - result.performanceScore = 0.3; - } - - // ==================================================================== - // OVERALL QUALITY SCORE - // ==================================================================== - - // Weighted average emphasizing business value - result.overallScore = ( - result.completenessScore * 0.25 + // Must answer the full question - result.accuracyScore * 0.20 + // Must be technically correct - result.actionabilityScore * 0.20 + // Must provide actionable guidance - result.sourceIntegrationScore * 0.15 + // Must combine sources appropriately - result.businessContextScore * 0.15 + // Must understand business context - result.performanceScore * 0.05 // Must perform reasonably - ); - - // Grade assignment for easy interpretation - if (result.overallScore >= 0.9) { - result.grade = "A"; - } else if (result.overallScore >= 0.8) { - result.grade = "B"; - } else if (result.overallScore >= 0.7) { - result.grade = "C"; - } else if (result.overallScore >= 0.6) { - result.grade = "D"; - } else { - result.grade = "F"; - } - - return result; - } - - private static double evaluateCompleteness(TestQuestion question, String response) { - if (response == null || response.trim().isEmpty()) return 0.0; - - // Check if response addresses key aspects based on question category - double score = 0.5; // Base score for any response - - if (question.category.equals("policy") && - Arrays.stream(POLICY_KEYWORDS).anyMatch(kw -> - response.toLowerCase().contains(kw.toLowerCase()))) { - score += 0.3; - } - - if (question.category.equals("technical") && - Arrays.stream(TECHNICAL_KEYWORDS).anyMatch(kw -> - response.toLowerCase().contains(kw.toLowerCase()))) { - score += 0.3; - } - - if (question.category.equals("implementation") && - Arrays.stream(POLICY_KEYWORDS).anyMatch(kw -> - response.toLowerCase().contains(kw.toLowerCase())) && - Arrays.stream(TECHNICAL_KEYWORDS).anyMatch(kw -> - response.toLowerCase().contains(kw.toLowerCase()))) { - score += 0.4; - } - - // Length-based completeness (reasonable explanations should be substantial) - if (response.length() > 200) score += 0.2; - - return Math.min(1.0, score); - } - - private static double evaluateAccuracy(TestQuestion question, String response) { - if (response == null || response.trim().isEmpty()) return 0.0; - - // Base accuracy assessment (would be enhanced with domain-specific validation) - double score = 0.6; // Assume reasonable accuracy for non-empty responses - - // Check for structured information (lists, steps, examples) - if (response.contains("1.") || response.contains("โ€ข") || response.contains("-")) { - score += 0.2; - } - - // Check for specific technical terms that indicate detailed knowledge - if (question.category.equals("technical") || question.category.equals("implementation")) { - if (response.toLowerCase().contains("azure") && - response.toLowerCase().contains("active directory")) { - score += 0.2; - } - } - - return Math.min(1.0, score); - } - - private static double evaluateActionability(String response) { - if (response == null || response.trim().isEmpty()) return 0.0; - - double score = 0.0; - - // Check for actionable elements - if (response.contains("step") || response.contains("Step")) score += 0.3; - if (response.contains("1.") || response.contains("2.")) score += 0.3; - if (response.contains("configure") || response.contains("set up") || - response.contains("implement")) score += 0.2; - if (response.contains("portal") || response.contains("PowerShell") || - response.contains("command")) score += 0.2; - - return Math.min(1.0, score); - } - - private static double evaluateSourceIntegration(TestQuestion question, String response) { - if (response == null || response.trim().isEmpty()) return 0.0; - - double score = 0.5; // Base score - - // Check if response appropriately uses expected sources - if (question.expectedSources.contains("sharepoint") && - (response.toLowerCase().contains("policy") || - response.toLowerCase().contains("company") || - response.toLowerCase().contains("internal"))) { - score += 0.25; - } - - if (question.expectedSources.contains("mcp") && - (response.toLowerCase().contains("microsoft") || - response.toLowerCase().contains("azure") || - response.toLowerCase().contains("documentation"))) { - score += 0.25; - } - - return Math.min(1.0, score); - } - - private static double evaluateBusinessContext(TestQuestion question, String response) { - if (response == null || response.trim().isEmpty()) return 0.0; - - double score = 0.4; // Base score - - // Check for business awareness - if (response.toLowerCase().contains("enterprise") || - response.toLowerCase().contains("organization") || - response.toLowerCase().contains("company")) { - score += 0.2; - } - - // Check for security/compliance awareness - if (response.toLowerCase().contains("security") || - response.toLowerCase().contains("compliance") || - response.toLowerCase().contains("governance")) { - score += 0.2; - } - - // Check for practical considerations - if (response.toLowerCase().contains("user") || - response.toLowerCase().contains("administrator") || - response.toLowerCase().contains("deployment")) { - score += 0.2; - } - - return Math.min(1.0, score); - } - - /** - * Execute evaluation against the workplace assistant. - * - * This runs the complete evaluation suite and provides comprehensive - * business-focused metrics for the AI agent's performance. - */ - public static void runEvaluation() { - System.out.println("๐Ÿ”ฌ Azure AI Foundry - Agent Evaluation"); - System.out.println("Tutorial 1: Comprehensive Business-Focused Evaluation"); - System.out.println("=".repeat(60)); - - try { - // Create the agent (reusing Main class logic) - Main.AgentConfiguration agentConfig = Main.createWorkplaceAssistant(); - - // Load test questions - List questions = loadTestQuestions(); - System.out.println("๐Ÿ“‹ Loaded " + questions.size() + " test questions"); - - // Run evaluation - List results = new ArrayList<>(); - - for (int i = 0; i < questions.size(); i++) { - TestQuestion question = questions.get(i); - System.out.println(String.format("\n๐Ÿงช Test %d/%d: %s", - i + 1, questions.size(), question.category.toUpperCase())); - System.out.println("โ“ " + question.question); - - // Measure response time - long startTime = System.currentTimeMillis(); - Main.ChatResult response = Main.chatWithAssistant( - agentConfig.agent.getId(), - agentConfig.mcpTool, - question.question - ); - long responseTime = System.currentTimeMillis() - startTime; - - // Evaluate response - EvaluationResult result = evaluateResponse(question, response.content, responseTime); - results.add(result); - - // Display immediate results - System.out.println(String.format("๐Ÿ“Š Grade: %s (%.2f) | Time: %dms", - result.grade, result.overallScore, result.responseTimeMs)); - System.out.println("-".repeat(50)); - } - - // Generate comprehensive report - generateEvaluationReport(results); - - } catch (Exception e) { - System.err.println("โŒ Evaluation failed: " + e.getMessage()); - e.printStackTrace(); - } - } - - /** - * Generate comprehensive evaluation report with business insights. - * - * Educational Value: - * - Shows how to present evaluation results for business stakeholders - * - Demonstrates actionable insights from evaluation data - * - Provides foundation for continuous improvement processes - */ - private static void generateEvaluationReport(List results) { - System.out.println("\n" + "=".repeat(60)); - System.out.println("๐Ÿ“ˆ COMPREHENSIVE EVALUATION REPORT"); - System.out.println("=".repeat(60)); - - // Overall statistics - double avgScore = results.stream().mapToDouble(r -> r.overallScore).average().orElse(0.0); - long avgResponseTime = (long) results.stream().mapToLong(r -> r.responseTimeMs).average().orElse(0.0); - - Map gradeDistribution = results.stream() - .collect(Collectors.groupingBy(r -> r.grade, Collectors.counting())); - - System.out.println("๐ŸŽฏ OVERALL PERFORMANCE:"); - System.out.println(String.format(" Average Score: %.2f", avgScore)); - System.out.println(String.format(" Average Response Time: %dms", avgResponseTime)); - System.out.println(" Grade Distribution: " + gradeDistribution); - - // Category-specific analysis - Map> byCategory = results.stream() - .collect(Collectors.groupingBy(r -> r.category)); - - System.out.println("\n๐Ÿ“Š CATEGORY ANALYSIS:"); - for (Map.Entry> entry : byCategory.entrySet()) { - String category = entry.getKey(); - List categoryResults = entry.getValue(); - double categoryAvg = categoryResults.stream().mapToDouble(r -> r.overallScore).average().orElse(0.0); - - System.out.println(String.format(" %s: %.2f average (%d questions)", - category.toUpperCase(), categoryAvg, categoryResults.size())); - } - - // Detailed metrics breakdown - System.out.println("\n๐Ÿ” DETAILED METRICS:"); - double avgCompleteness = results.stream().mapToDouble(r -> r.completenessScore).average().orElse(0.0); - double avgAccuracy = results.stream().mapToDouble(r -> r.accuracyScore).average().orElse(0.0); - double avgActionability = results.stream().mapToDouble(r -> r.actionabilityScore).average().orElse(0.0); - double avgSourceIntegration = results.stream().mapToDouble(r -> r.sourceIntegrationScore).average().orElse(0.0); - double avgBusinessContext = results.stream().mapToDouble(r -> r.businessContextScore).average().orElse(0.0); - double avgPerformance = results.stream().mapToDouble(r -> r.performanceScore).average().orElse(0.0); - - System.out.println(String.format(" Completeness: %.2f", avgCompleteness)); - System.out.println(String.format(" Accuracy: %.2f", avgAccuracy)); - System.out.println(String.format(" Actionability: %.2f", avgActionability)); - System.out.println(String.format(" Source Integration: %.2f", avgSourceIntegration)); - System.out.println(String.format(" Business Context: %.2f", avgBusinessContext)); - System.out.println(String.format(" Performance: %.2f", avgPerformance)); - - // Business insights and recommendations - System.out.println("\n๐Ÿ’ก BUSINESS INSIGHTS:"); - if (avgScore >= 0.8) { - System.out.println(" โœ… Agent demonstrates strong enterprise readiness"); - System.out.println(" โœ… Suitable for pilot deployment with monitoring"); - } else if (avgScore >= 0.7) { - System.out.println(" โš ๏ธ Agent shows promise but needs improvement"); - System.out.println(" โš ๏ธ Recommend additional training before deployment"); - } else { - System.out.println(" โŒ Agent requires significant improvement"); - System.out.println(" โŒ Not ready for production deployment"); - } - - if (avgResponseTime > 10000) { - System.out.println(" โš ๏ธ Response times may impact user experience"); - System.out.println(" ๐Ÿ’ก Recommend performance optimization"); - } - - System.out.println("\n๐Ÿš€ NEXT STEPS:"); - System.out.println(" ๐Ÿ“š Tutorial 2: Implement governance and monitoring"); - System.out.println(" ๐Ÿ”„ Tutorial 3: Production deployment and scaling"); - System.out.println(" ๐Ÿ“Š Use these metrics to track improvement over time"); - - System.out.println("\n" + "=".repeat(60)); - } - //#endregion evaluation_functions - - public static void main(String[] args) { - runEvaluation(); - } - - // ============================================================================ - // HELPER CLASSES - // ============================================================================ - - public static class TestQuestion { - public final String question; - public final String category; - public final String expectedSources; - public final String context; - - public TestQuestion(String question, String category, String expectedSources, String context) { - this.question = question; - this.category = category; - this.expectedSources = expectedSources; - this.context = context; - } - } - - public static class EvaluationResult { - public String question; - public String category; - public String response; - public long responseTimeMs; - - // Quality metrics - public double completenessScore; - public double accuracyScore; - public double actionabilityScore; - public double sourceIntegrationScore; - public double businessContextScore; - public double performanceScore; - - // Overall assessment - public double overallScore; - public String grade; - } -} \ No newline at end of file diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md deleted file mode 100644 index 01aa46468..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md +++ /dev/null @@ -1,57 +0,0 @@ -# MCP Server Options for Azure AI Foundry Sample - -## Current Issue -The Microsoft Learn MCP server (https://learn.microsoft.com/api/mcp) requires approval, causing runs to get cancelled. - -## Recommended MCP Servers (No Approval Required) - -### 1. Weather MCP Server -``` -MCP_SERVER_URL=https://mcp-weather.vercel.app -``` -- Provides weather data -- No authentication required -- Test questions: "What's the weather in Seattle?", "Get current weather for New York" - -### 2. Public APIs MCP Server -``` -MCP_SERVER_URL=https://mcp-public-apis.herokuapp.com -``` -- Access to various public APIs -- No authentication required -- Test questions: "Get information about cats", "Find a random fact" - -### 3. Wikipedia MCP Server -``` -MCP_SERVER_URL=https://mcp-wikipedia.glitch.me -``` -- Search Wikipedia articles -- No authentication required -- Test questions: "Search Wikipedia for Azure", "Tell me about cloud computing" - -### 4. GitHub Public MCP Server -``` -MCP_SERVER_URL=https://api.githubcopilot.com/mcp/ -``` -- Access public GitHub repositories -- May require authentication -- Test questions: "Search GitHub for Azure samples" - -## Recommended for Sample -Use the **Weather MCP Server** as it's: -- โœ… Reliable and stable -- โœ… No authentication required -- โœ… No approval required -- โœ… Easy to test with weather questions -- โœ… Demonstrates external API integration - -## Update .env -``` -MCP_SERVER_URL=https://mcp-weather.vercel.app -``` - -## Test Questions -After updating: -- "What's the weather in Seattle?" -- "Get current weather for London" -- "Tell me the temperature in Tokyo" \ No newline at end of file diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/Main.java b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/Main.java deleted file mode 100644 index 3730c49c6..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/Main.java +++ /dev/null @@ -1,503 +0,0 @@ -/** - * Azure AI Foundry Agent Sample - Tutorial 1: Modern Workplace Assistant - * - * This sample demonstrates a complete business scenario combining: - * - SharePoint integration for internal company knowledge - * - Microsoft Learn MCP integration for external technical guidance - * - Intelligent orchestration of multiple data sources - * - Robust error handling and graceful degradation - * - * Educational Focus: - * - Enterprise AI patterns with multiple data sources - * - Real-world business scenarios that enterprises face daily - * - Production-ready error handling and diagnostics - * - Foundation for governance, evaluation, and monitoring (Tutorials 2-3) - * - * Business Scenario: - * An employee needs to implement Azure AD multi-factor authentication. They need: - * 1. Company security policy requirements (from SharePoint) - * 2. Technical implementation steps (from Microsoft Learn) - * 3. Combined guidance showing how policy requirements map to technical implementation - */ - -//#region imports_and_setup -import com.azure.ai.projects.AIProjectClient; -import com.azure.ai.projects.AIProjectClientBuilder; -import com.azure.ai.agents.models.*; -import com.azure.identity.DefaultAzureCredential; -import com.azure.identity.AzureCliCredential; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.*; -import java.util.stream.Collectors; -//#endregion imports_and_setup - -public class Main { - - // ============================================================================ - // CONFIGURATION AND SETUP - // ============================================================================ - - private static final Properties config = new Properties(); - private static AIProjectClient projectClient; - - static { - // Load environment configuration - try { - loadEnvironmentConfig(); - setupAuthentication(); - } catch (Exception e) { - System.err.println("Failed to initialize configuration: " + e.getMessage()); - System.exit(1); - } - } - - private static void loadEnvironmentConfig() throws IOException { - // Load .env file if it exists - if (Files.exists(Paths.get(".env"))) { - Files.lines(Paths.get(".env")) - .filter(line -> !line.trim().isEmpty() && !line.startsWith("#")) - .forEach(line -> { - String[] parts = line.split("=", 2); - if (parts.length == 2) { - config.setProperty(parts[0].trim(), parts[1].trim()); - } - }); - } - - // Override with system environment variables - System.getenv().forEach((key, value) -> { - if (config.containsKey(key) || key.startsWith("AI_FOUNDRY_") || - key.startsWith("PROJECT_") || key.startsWith("SHAREPOINT_") || - key.startsWith("MCP_") || key.startsWith("MODEL_")) { - config.setProperty(key, value); - } - }); - } - - private static void setupAuthentication() { - // Support both default Azure credentials and specific tenant authentication - String tenantId = config.getProperty("AI_FOUNDRY_TENANT_ID"); - - if (tenantId != null && !tenantId.isEmpty()) { - System.out.println("๐Ÿ” Using AI Foundry tenant: " + tenantId); - projectClient = new AIProjectClientBuilder() - .endpoint(config.getProperty("PROJECT_ENDPOINT")) - .credential(new AzureCliCredential()) - .buildClient(); - } else { - projectClient = new AIProjectClientBuilder() - .endpoint(config.getProperty("PROJECT_ENDPOINT")) - .credential(new DefaultAzureCredential()) - .buildClient(); - } - } - - /** - * Create a Modern Workplace Assistant combining internal and external knowledge. - * - * This demonstrates enterprise AI patterns: - * 1. Multi-source data integration (SharePoint + MCP) - * 2. Robust error handling with graceful degradation - * 3. Dynamic agent capabilities based on available resources - * 4. Clear diagnostic information for troubleshooting - * - * Educational Value: - * - Shows real-world complexity of enterprise AI systems - * - Demonstrates how to handle partial system failures - * - Provides patterns for combining internal and external data - * - * @return AgentConfiguration containing agent and tool information - */ - //#region create_workplace_assistant - public static AgentConfiguration createWorkplaceAssistant() { - System.out.println("๐Ÿค– Creating Modern Workplace Assistant..."); - - // ======================================================================== - // SHAREPOINT INTEGRATION SETUP - // ======================================================================== - // SharePoint provides access to internal company knowledge: - // - Company policies and procedures - // - Security guidelines and requirements - // - Governance and compliance documentation - // - Internal process documentation - - String sharepointResourceName = config.getProperty("SHAREPOINT_RESOURCE_NAME"); - - System.out.println("๐Ÿ“ Configuring SharePoint integration..."); - System.out.println(" Connection: " + sharepointResourceName); - - SharepointTool sharepointTool = null; - try { - // Attempt to retrieve pre-configured SharePoint connection - var sharepointConnection = projectClient.getConnections().get(sharepointResourceName); - sharepointTool = new SharepointTool(sharepointConnection.getId()); - System.out.println("โœ… SharePoint successfully connected"); - - } catch (Exception e) { - // Graceful degradation - system continues without SharePoint - System.out.println("โš ๏ธ SharePoint connection failed: " + e.getMessage()); - System.out.println(" Agent will operate in technical guidance mode only"); - System.out.println(" ๐Ÿ“ To enable full functionality:"); - System.out.println(" Create SharePoint connection in Azure AI Foundry portal"); - System.out.println(" Connection name: " + sharepointResourceName); - sharepointTool = null; - } - - // ======================================================================== - // MICROSOFT LEARN MCP INTEGRATION SETUP - // ======================================================================== - // Microsoft Learn MCP provides access to current technical documentation: - // - Azure service configuration guides - // - Best practices and implementation patterns - // - Troubleshooting and diagnostic information - // - Latest feature updates and capabilities - - System.out.println("๐Ÿ“š Configuring Microsoft Learn MCP integration..."); - McpTool mcpTool = new McpTool() - .setServerLabel("microsoft_learn") - .setServerUrl(config.getProperty("MCP_SERVER_URL")) - .setAllowedTools(Collections.emptyList()); // Allow all available tools - - // Disable approval workflow for seamless demonstration - mcpTool.setApprovalMode("never"); - System.out.println("โœ… Microsoft Learn MCP connected: " + config.getProperty("MCP_SERVER_URL")); - - // ======================================================================== - // AGENT CREATION WITH DYNAMIC CAPABILITIES - // ======================================================================== - // Create agent instructions based on available data sources - // This demonstrates adaptive system design - - String instructions; - if (sharepointTool != null) { - instructions = """ - You are a Modern Workplace Assistant for Contoso Corporation. - - CAPABILITIES: - - Search SharePoint for company policies, procedures, and internal documentation - - Access Microsoft Learn for current Azure and Microsoft 365 technical guidance - - Provide comprehensive solutions combining internal requirements with external implementation - - RESPONSE STRATEGY: - - For policy questions: Search SharePoint for company-specific requirements and guidelines - - For technical questions: Use Microsoft Learn for current Azure/M365 documentation and best practices - - For implementation questions: Combine both sources to show how company policies map to technical implementation - - Always cite your sources and provide step-by-step guidance - - Explain how internal requirements connect to external implementation steps - - EXAMPLE SCENARIOS: - - "What is our MFA policy?" โ†’ Search SharePoint for security policies - - "How do I configure Azure AD Conditional Access?" โ†’ Use Microsoft Learn for technical steps - - "Our policy requires MFA - how do I implement this?" โ†’ Combine policy requirements with implementation guidance - """; - } else { - instructions = """ - You are a Technical Assistant with access to Microsoft Learn documentation. - - CAPABILITIES: - - Access Microsoft Learn for current Azure and Microsoft 365 technical guidance - - Provide detailed implementation steps and best practices - - Explain Azure services, features, and configuration options - - LIMITATIONS: - - SharePoint integration is not available - - Cannot access company-specific policies or internal documentation - - When asked about company policies, explain that internal document access requires SharePoint configuration - - RESPONSE STRATEGY: - - Provide comprehensive technical guidance from Microsoft Learn - - Include step-by-step implementation instructions - - Reference official documentation and best practices - - Suggest how technical implementations typically align with enterprise requirements - """; - } - - // Create the agent with appropriate tool configuration - System.out.println("๐Ÿ› ๏ธ Configuring agent tools..."); - List availableTools = new ArrayList<>(); - if (sharepointTool != null) { - availableTools.addAll(sharepointTool.getDefinitions()); - } - availableTools.addAll(mcpTool.getDefinitions()); - System.out.println(" Available tools: " + availableTools.size()); - - Agent agent = projectClient.getAgents().createAgent( - config.getProperty("MODEL_DEPLOYMENT_NAME"), - "Modern Workplace Assistant", - instructions, - availableTools - ); - - System.out.println("โœ… Agent created successfully: " + agent.getId()); - return new AgentConfiguration(agent, mcpTool, sharepointTool); - } - - /** - * Demonstrate realistic business scenarios combining internal and external knowledge. - * - * This function showcases the practical value of the Modern Workplace Assistant - * by walking through scenarios that enterprise employees face regularly. - * - * Educational Value: - * - Shows real business problems that AI agents can solve - * - Demonstrates integration between internal policies and external guidance - * - Illustrates how AI can bridge the gap between requirements and implementation - */ - public static void demonstrateBusinessScenarios(AgentConfiguration config) { - BusinessScenario[] scenarios = { - new BusinessScenario( - "๐Ÿ“‹ Company Policy Question", - "What is our remote work security policy regarding multi-factor authentication?", - "Employee needs to understand company MFA requirements", - "SharePoint", - "Internal policy retrieval and interpretation" - ), - new BusinessScenario( - "๐Ÿ”ง Technical Implementation Question", - "How do I set up Azure Active Directory conditional access policies?", - "IT administrator needs technical implementation steps", - "Microsoft Learn MCP", - "External technical documentation access" - ), - new BusinessScenario( - "๐Ÿ”„ Combined Business Implementation Question", - "Our company security policy requires multi-factor authentication for remote workers. How do I implement this requirement using Azure AD?", - "Need to combine policy requirements with technical implementation", - "Both SharePoint and MCP", - "Multi-source intelligence combining internal requirements with external implementation" - ) - }; - - System.out.println("\n" + "=".repeat(70)); - System.out.println("๐Ÿข MODERN WORKPLACE ASSISTANT - BUSINESS SCENARIO DEMONSTRATION"); - System.out.println("=".repeat(70)); - System.out.println("This demonstration shows how AI agents solve real business problems"); - System.out.println("by combining internal company knowledge with external technical guidance."); - System.out.println("=".repeat(70)); - - for (int i = 0; i < scenarios.length; i++) { - BusinessScenario scenario = scenarios[i]; - System.out.println(String.format("\n๐Ÿ“Š SCENARIO %d/3: %s", i + 1, scenario.title)); - System.out.println("-".repeat(50)); - System.out.println("โ“ QUESTION: " + scenario.question); - System.out.println("๐ŸŽฏ BUSINESS CONTEXT: " + scenario.context); - System.out.println("๐Ÿ“š EXPECTED SOURCE: " + scenario.expectedSource); - System.out.println("๐ŸŽ“ LEARNING POINT: " + scenario.learningPoint); - System.out.println("-".repeat(50)); - - // Get response from the agent - System.out.println("๐Ÿค– ASSISTANT RESPONSE:"); - ChatResult response = chatWithAssistant(config.agent.getId(), config.mcpTool, scenario.question); - - // Display response with analysis - if ("completed".equals(response.status) && response.content != null && response.content.trim().length() > 10) { - String preview = response.content.length() > 300 ? - response.content.substring(0, 300) + "..." : response.content; - System.out.println("โœ… SUCCESS: " + preview); - if (response.content.length() > 300) { - System.out.println(" ๐Ÿ“ Full response: " + response.content.length() + " characters"); - } - } else { - System.out.println("โš ๏ธ LIMITED RESPONSE: " + response.content); - if (config.sharepointTool == null && (scenario.expectedSource.contains("SharePoint"))) { - System.out.println(" ๐Ÿ’ก This demonstrates graceful degradation when SharePoint is unavailable"); - } - } - - System.out.println("๐Ÿ“ˆ STATUS: " + response.status); - System.out.println("-".repeat(50)); - } - - System.out.println("\nโœ… DEMONSTRATION COMPLETED!"); - System.out.println("๐ŸŽ“ Key Learning Outcomes:"); - System.out.println(" โ€ข Multi-source data integration in enterprise AI"); - System.out.println(" โ€ข Robust error handling and graceful degradation"); - System.out.println(" โ€ข Real business value through combined intelligence"); - System.out.println(" โ€ข Foundation for governance and monitoring (Tutorials 2-3)"); - } - - /** - * Execute a conversation with the workplace assistant. - * - * This function demonstrates the conversation pattern for Azure AI Foundry agents - * and includes comprehensive error handling for production readiness. - * - * Educational Value: - * - Shows proper thread management and conversation flow - * - Demonstrates streaming response handling - * - Includes timeout and error management patterns - */ - public static ChatResult chatWithAssistant(String agentId, McpTool mcpTool, String message) { - try { - // Create conversation thread (maintains conversation context) - Thread thread = projectClient.getAgents().getThreads().create(); - - // Add user message to thread - projectClient.getAgents().getMessages().create( - thread.getId(), - "user", - message - ); - - // Execute the conversation with streaming response - RunStream runStream = projectClient.getAgents().getRuns().createAndStream( - thread.getId(), - agentId - ); - - // Collect streaming response - List responseParts = new ArrayList<>(); - String finalStatus = "unknown"; - - for (RunEvent event : runStream) { - if (event.getEventType().equals("MessageDelta")) { - MessageDelta delta = (MessageDelta) event.getData(); - for (ContentPart contentPart : delta.getDelta().getContent()) { - if (contentPart.getText() != null && contentPart.getText().getValue() != null) { - responseParts.add(contentPart.getText().getValue()); - } - } - } - if (event.getRunStatus() != null) { - finalStatus = event.getRunStatus().getStatus(); - } - } - - String fullResponse = String.join("", responseParts); - return new ChatResult(fullResponse, finalStatus); - - } catch (Exception e) { - return new ChatResult("Error in conversation: " + e.getMessage(), "failed"); - } - } - - /** - * Interactive mode for testing the workplace assistant. - * - * This provides a simple interface for users to test the agent with their own questions - * and see how it combines different data sources for comprehensive answers. - */ - public static void interactiveMode(AgentConfiguration config) { - System.out.println("\n" + "=".repeat(60)); - System.out.println("๐Ÿ’ฌ INTERACTIVE MODE - Test Your Workplace Assistant!"); - System.out.println("=".repeat(60)); - System.out.println("Ask questions that combine company policies with technical guidance:"); - System.out.println("โ€ข 'What's our remote work policy for Azure access?'"); - System.out.println("โ€ข 'How do I configure SharePoint security?'"); - System.out.println("โ€ข 'Our policy requires encryption - how do I set this up in Azure?'"); - System.out.println("Type 'quit' to exit."); - System.out.println("-".repeat(60)); - - Scanner scanner = new Scanner(System.in); - - while (true) { - try { - System.out.print("\nโ“ Your question: "); - String question = scanner.nextLine().trim(); - - if (question.toLowerCase().matches("quit|exit|bye")) { - break; - } - - if (question.isEmpty()) { - System.out.println("๐Ÿ’ก Please ask a question about policies or technical implementation."); - continue; - } - - System.out.print("\n๐Ÿค– Workplace Assistant: "); - ChatResult response = chatWithAssistant(config.agent.getId(), config.mcpTool, question); - System.out.println(response.content); - - if (!"completed".equals(response.status)) { - System.out.println("\nโš ๏ธ Response status: " + response.status); - } - - System.out.println("-".repeat(60)); - - } catch (Exception e) { - System.out.println("\nโŒ Error: " + e.getMessage()); - System.out.println("-".repeat(60)); - } - } - - System.out.println("\n๐Ÿ‘‹ Thank you for testing the Modern Workplace Assistant!"); - } - - /** - * Main execution flow demonstrating the complete sample. - * - * This orchestrates the full demonstration: - * 1. Agent creation with diagnostic information - * 2. Business scenario demonstration - * 3. Interactive testing mode - * 4. Clean completion with next steps - */ - public static void main(String[] args) { - System.out.println("๐Ÿš€ Azure AI Foundry - Modern Workplace Assistant"); - System.out.println("Tutorial 1: Building Enterprise Agents with SharePoint + MCP Integration"); - System.out.println("=".repeat(70)); - - // Create the agent with full diagnostic output - AgentConfiguration agentConfig = createWorkplaceAssistant(); - - // Demonstrate business scenarios - demonstrateBusinessScenarios(agentConfig); - - // Offer interactive testing - Scanner scanner = new Scanner(System.in); - System.out.print("\n๐ŸŽฏ Try interactive mode? (y/n): "); - if (scanner.nextLine().toLowerCase().startsWith("y")) { - interactiveMode(agentConfig); - } - - System.out.println("\n๐ŸŽ‰ Sample completed successfully!"); - System.out.println("๐Ÿ“š This foundation supports Tutorial 2 (Governance) and Tutorial 3 (Production)"); - System.out.println("๐Ÿ”— Next: Add evaluation metrics, monitoring, and production deployment"); - - scanner.close(); - } - - // ============================================================================ - // HELPER CLASSES - // ============================================================================ - - public static class AgentConfiguration { - public final Agent agent; - public final McpTool mcpTool; - public final SharepointTool sharepointTool; - - public AgentConfiguration(Agent agent, McpTool mcpTool, SharepointTool sharepointTool) { - this.agent = agent; - this.mcpTool = mcpTool; - this.sharepointTool = sharepointTool; - } - } - - public static class BusinessScenario { - public final String title; - public final String question; - public final String context; - public final String expectedSource; - public final String learningPoint; - - public BusinessScenario(String title, String question, String context, String expectedSource, String learningPoint) { - this.title = title; - this.question = question; - this.context = context; - this.expectedSource = expectedSource; - this.learningPoint = learningPoint; - } - } - - public static class ChatResult { - public final String content; - public final String status; - - public ChatResult(String content, String status) { - this.content = content; - this.status = status; - } - } -} \ No newline at end of file diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/README.md b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/README.md deleted file mode 100644 index c307803ea..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/README.md +++ /dev/null @@ -1,236 +0,0 @@ -# Modern Workplace Assistant - Java Sample - -This sample demonstrates building enterprise AI agents with Azure AI Foundry, combining SharePoint integration for internal company knowledge with Microsoft Learn MCP integration for external technical guidance. - -## ๐ŸŽฏ Business Scenario - -The **Modern Workplace Assistant** helps Contoso Corporation employees with: -- **Company Policy Questions**: "What is our remote work security policy?" -- **Technical Implementation**: "How do I configure Azure AD Conditional Access?" -- **Combined Guidance**: "Our policy requires MFA - how do I implement this in Azure AD?" - -This represents realistic enterprise scenarios where employees need both internal requirements and external implementation guidance. - -## ๐Ÿ—๏ธ Architecture - -``` -โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ Modern Workplace Assistant โ”‚ -โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ ๐Ÿค– Azure AI Foundry Agent (gpt-4o) โ”‚ -โ”‚ โ”œโ”€โ”€ ๐Ÿ“ SharePoint Tool (Internal Knowledge) โ”‚ -โ”‚ โ”‚ โ””โ”€โ”€ Company policies, procedures, governance โ”‚ -โ”‚ โ””โ”€โ”€ ๐Ÿ“š Microsoft Learn MCP (External Knowledge) โ”‚ -โ”‚ โ””โ”€โ”€ Azure docs, best practices, implementation โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ -``` - -## ๐Ÿ“ Sample Structure - -``` -simple-agent-java/ -โ”œโ”€โ”€ ๐Ÿ”ง Main.java # Core agent implementation (540+ lines) -โ”œโ”€โ”€ ๐Ÿ“Š Evaluate.java # Business-focused evaluation system -โ”œโ”€โ”€ โ“ questions.jsonl # Test questions for evaluation -โ”œโ”€โ”€ ๐Ÿ“– README.md # This comprehensive guide -โ”œโ”€โ”€ โš™๏ธ .env.template # Configuration template -โ”œโ”€โ”€ ๐Ÿ”จ pom.xml # Maven dependencies and build config -โ”œโ”€โ”€ ๐Ÿ“„ SAMPLE_SHAREPOINT_CONTENT.md # Business documents to upload -โ””โ”€โ”€ ๐Ÿ”ง setup_sharepoint.py # SharePoint document upload utility -``` - -## ๐Ÿš€ Quick Start - -### 1. Prerequisites - -- **Java 11+** with Maven 3.6+ -- **Azure AI Foundry Project** with SharePoint connection configured -- **Microsoft Learn MCP Server** running (see MCP_SERVERS.md) -- **Azure CLI** authenticated to your tenant - -### 2. Configuration - -Copy the environment template and configure your settings: - -```bash -cp .env.template .env -``` - -Edit `.env` with your specific values: - -```properties -# Azure AI Foundry Configuration -PROJECT_ENDPOINT=https://your-project.cognitiveservices.azure.com/ -MODEL_DEPLOYMENT_NAME=gpt-4o -AI_FOUNDRY_TENANT_ID=your-tenant-id - -# SharePoint Integration -SHAREPOINT_RESOURCE_NAME=Benefits - -# Microsoft Learn MCP Server -MCP_SERVER_URL=https://learn.microsoft.com/api/mcp -``` - -### 3. SharePoint Document Setup - -Upload sample business documents to your SharePoint site: - -```bash -# Use the Python setup script (requires Python) -python setup_sharepoint.py - -# Or manually upload SAMPLE_SHAREPOINT_CONTENT.md files to: -# https://yourtenant.sharepoint.com/sites/benefits/Shared Documents/ -``` - -**Required Documents:** -1. **Remote Work Security Policy** - Company MFA and security requirements -2. **IT Security Guidelines** - Technical implementation standards -3. **Employee Handbook** - General policies and procedures -4. **Compliance Requirements** - Governance and regulatory requirements - -### 4. Build and Run - -```bash -# Install dependencies -mvn clean compile - -# Run the main sample -mvn exec:java - -# Run evaluation system -mvn exec:java -Dexec.mainClass="Evaluate" -``` - -## ๐Ÿงช Interactive Testing - -The sample includes an interactive mode for testing: - -```bash -mvn exec:java -# Choose 'y' when prompted for interactive mode - -# Try these example questions: -โ“ What is our company MFA policy? -โ“ How do I configure Azure Conditional Access? -โ“ Our policy requires encryption - how do I set this up? -``` - -## ๐Ÿ“Š Evaluation System - -Run comprehensive evaluation with business-focused metrics: - -```bash -mvn exec:java -Dexec.mainClass="Evaluate" -``` - -**Evaluation Dimensions:** -- **Completeness**: Does it answer the full question? -- **Accuracy**: Is the information technically correct? -- **Actionability**: Can users take concrete next steps? -- **Source Integration**: Does it combine internal/external sources? -- **Business Context**: Does it understand enterprise requirements? -- **Performance**: Response time and user experience - -## ๐Ÿ”ง Troubleshooting - -### SharePoint Connection Issues - -If you see `SharePoint connection has invalid target: '_'`: - -1. **Check Azure AI Foundry Portal**: - - Go to Management Center > Connected Resources - - Edit your SharePoint connection - - Verify the target URL matches your site - -2. **Verify Permissions**: - - Ensure your Azure identity has access to the SharePoint site - - Test SharePoint access manually in browser - -3. **Connection Name**: - - Verify `SHAREPOINT_RESOURCE_NAME` matches the connection name exactly - - Connection names are case-sensitive - -### MCP Server Issues - -If Microsoft Learn MCP connection fails: - -1. **Check Server URL**: Verify `MCP_SERVER_URL` is accessible -2. **Network Access**: Ensure your environment can reach external URLs -3. **Approval Mode**: The sample sets approval mode to "never" for demos - -### Authentication Issues - -If you see authentication errors: - -1. **Azure CLI Login**: Run `az login` and select correct tenant -2. **Tenant ID**: Verify `AI_FOUNDRY_TENANT_ID` matches your Azure AI Foundry tenant -3. **Permissions**: Ensure your identity has AI Foundry access - -## ๐ŸŽ“ Educational Value - -This sample teaches enterprise AI development patterns: - -### **Multi-Source Data Integration** -- Combining internal company knowledge (SharePoint) with external guidance (MCP) -- Dynamic agent capabilities based on available data sources -- Graceful degradation when data sources are unavailable - -### **Production-Ready Error Handling** -- Comprehensive diagnostic information during setup -- Clear troubleshooting guidance when connections fail -- User-friendly error messages with actionable solutions - -### **Business-Focused Evaluation** -- Evaluation metrics that matter for enterprise deployment -- Assessment of business value, not just technical accuracy -- Foundation for governance and monitoring (Tutorials 2-3) - -### **Enterprise Architecture Patterns** -- Proper authentication and credential management -- Configuration management with environment variables -- Scalable code structure for complex business scenarios - -## ๐Ÿ”— Tutorial Series Context - -This is **Tutorial 1** in the Azure AI Foundry enterprise development series: - -- **Tutorial 1** (This Sample): Build foundation with SharePoint + MCP integration -- **Tutorial 2**: Add governance, monitoring, and evaluation frameworks -- **Tutorial 3**: Production deployment, scaling, and operations - -## ๐Ÿ“š Key Learning Outcomes - -After completing this sample, you'll understand: - -โœ… **Enterprise AI Agent Architecture**: Multi-source data integration patterns -โœ… **SharePoint Integration**: Internal knowledge access for AI agents -โœ… **MCP Integration**: External knowledge source integration -โœ… **Business Scenario Design**: Realistic enterprise use cases -โœ… **Error Handling**: Production-ready resilience patterns -โœ… **Evaluation Frameworks**: Business-focused quality assessment -โœ… **Configuration Management**: Secure and scalable setup patterns - -## ๐Ÿš€ Next Steps - -1. **Customize for Your Business**: Replace sample policies with your actual documents -2. **Extend Agent Capabilities**: Add more tools and data sources -3. **Implement Governance**: Move to Tutorial 2 for monitoring and compliance -4. **Production Deployment**: Use Tutorial 3 for scaling and operations - -## ๐Ÿ” Code Highlights - -### Main.java Key Features: -- **540+ lines** of comprehensive enterprise AI implementation -- **Educational comments** explaining each business pattern and technical decision -- **Interactive demonstration mode** with 3 realistic business scenarios -- **Robust error handling** with clear troubleshooting guidance -- **Dynamic agent configuration** based on available data sources - -### Evaluate.java Key Features: -- **Business-focused evaluation metrics** beyond simple accuracy -- **Multi-dimensional assessment**: completeness, actionability, business context -- **Performance monitoring**: response time and user experience tracking -- **Comprehensive reporting**: insights for business stakeholders and technical teams - -This sample provides a complete foundation for building production-ready enterprise AI agents with Azure AI Foundry! ๐ŸŽ‰ \ No newline at end of file diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md deleted file mode 100644 index dbc930527..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md +++ /dev/null @@ -1,176 +0,0 @@ -# Sample SharePoint Content for Tutorial Series - -To create a coherent business scenario, upload these sample documents to your SharePoint site: - -## Document Structure - -### ๐Ÿ“ Shared Documents/Policies/ -1. **remote-work-policy.docx** -2. **security-guidelines.docx** -3. **collaboration-standards.docx** -4. **data-governance-policy.docx** - -### ๐Ÿ“ Shared Documents/Procedures/ -1. **employee-onboarding.docx** -2. **project-workflow.docx** -3. **incident-response.docx** - ---- - -## Sample Document Content - -### 1. Remote Work Policy (remote-work-policy.docx) - -``` -CONTOSO CORP - REMOTE WORK POLICY - -Effective Date: January 2024 - -OVERVIEW -Contoso Corp supports flexible work arrangements including remote work to enhance employee productivity and work-life balance. - -ELIGIBILITY -- Full-time employees after 90-day probationary period -- Manager approval required -- Role must be suitable for remote work - -TECHNOLOGY REQUIREMENTS -- Secure VPN connection required -- Use of Microsoft 365 and Azure services mandatory -- Multi-factor authentication enabled -- Personal devices must meet security standards - -SECURITY PROTOCOLS -- All data must be stored in approved cloud services (SharePoint, OneDrive) -- No sensitive data on personal devices -- Regular security training completion required -- Incident reporting within 2 hours - -COLLABORATION TOOLS -- Microsoft Teams for meetings and communication -- SharePoint for document collaboration -- Azure DevOps for development projects -- Outlook for email and calendar management - -REVIEW -This policy is reviewed annually and updated as needed. -``` - -### 2. Security Guidelines (security-guidelines.docx) - -``` -CONTOSO CORP - INFORMATION SECURITY GUIDELINES - -OVERVIEW -These guidelines ensure the protection of Contoso's information assets and compliance with industry standards. - -AZURE SECURITY REQUIREMENTS -- All cloud resources must use Azure Active Directory -- Enable Azure Security Center monitoring -- Implement Azure Key Vault for secrets management -- Use Azure Policy for compliance enforcement - -ACCESS MANAGEMENT -- Role-based access control (RBAC) mandatory -- Privileged Identity Management (PIM) for admin roles -- Regular access reviews quarterly -- Conditional access policies enforced - -DATA PROTECTION -- Data classification using Microsoft Purview -- Encryption at rest and in transit -- Regular backup verification -- Data retention policies enforced - -INCIDENT RESPONSE -- Use Azure Sentinel for threat detection -- Report security incidents immediately -- Follow established escalation procedures -- Document all security events -``` - -### 3. Collaboration Standards (collaboration-standards.docx) - -``` -CONTOSO CORP - COLLABORATION STANDARDS - -DOCUMENT MANAGEMENT -- All business documents stored in SharePoint Online -- Version control enabled for all document libraries -- Metadata required: Department, Project, Classification -- Folder structure: /Department/Project/Year/ - -COMMUNICATION GUIDELINES -- Microsoft Teams for internal communication -- Email for external communication only -- Weekly team meetings via Teams -- Project updates in SharePoint lists - -DEVELOPMENT STANDARDS -- Source code in Azure DevOps repositories -- CI/CD pipelines for all applications -- Code reviews required for all changes -- Azure Monitor for application monitoring - -TRAINING REQUIREMENTS -- Microsoft 365 certification within 6 months -- Azure fundamentals for technical staff -- Security awareness training quarterly -- Collaboration tools training for new hires -``` - -### 4. Data Governance Policy (data-governance-policy.docx) - -``` -CONTOSO CORP - DATA GOVERNANCE POLICY - -DATA CLASSIFICATION -- Public: Marketing materials, published content -- Internal: Business documents, policies, procedures -- Confidential: Financial data, employee records -- Restricted: Legal documents, intellectual property - -STORAGE REQUIREMENTS -- Public: SharePoint sites, public websites -- Internal: SharePoint document libraries with access controls -- Confidential: Restricted SharePoint sites with encryption -- Restricted: Azure Key Vault, encrypted storage accounts - -MICROSOFT 365 COMPLIANCE -- Data Loss Prevention (DLP) policies enabled -- Sensitivity labels applied to all documents -- Retention policies configured by data type -- eDiscovery capabilities for legal requirements - -AZURE DATA SERVICES -- Azure SQL Database for structured data -- Azure Data Lake for analytics workloads -- Azure Synapse for data warehousing -- Power BI for business intelligence -``` - ---- - -## Business Scenario Test Questions - -These questions demonstrate the coherent business use case: - -### Internal Policy Questions (SharePoint) -- "What is our remote work policy regarding VPN requirements?" -- "What are the security protocols for remote employees?" -- "How should we classify confidential business documents?" -- "What collaboration tools are approved for internal use?" - -### Technical Implementation Questions (MCP - Microsoft Learn) -- "How do I set up Azure Active Directory for our remote workers?" -- "What are the steps to configure Azure Security Center monitoring?" -- "How do I implement data loss prevention in Microsoft 365?" -- "How do I set up conditional access policies in Azure AD?" - -### Hybrid Questions (Both Sources) -- "Our remote work policy requires secure VPN - how do I implement Azure VPN Gateway?" -- "What Azure services do I need to meet our data governance requirements?" -- "How do I configure Microsoft Teams to comply with our collaboration standards?" -- "What Azure security services align with our incident response procedures?" - -This creates a **realistic business scenario** where the AI assistant helps employees understand company policies AND implement them using Microsoft technologies. \ No newline at end of file diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/pom.xml b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/pom.xml deleted file mode 100644 index 838ebf0a1..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/pom.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - 4.0.0 - - com.microsoft.ai.foundry - modern-workplace-assistant - 1.0.0 - jar - - Modern Workplace Assistant - Azure AI Foundry Agent Sample - Tutorial 1: SharePoint + MCP Integration - - - 11 - 11 - UTF-8 - - - 1.2.0-beta.5 - 1.1.0-beta.4 - 1.11.1 - 2.15.2 - - - - - - com.azure - azure-ai-agents - ${azure.ai.agents.version} - - - - com.azure - azure-ai-projects - ${azure.ai.projects.version} - - - - - com.azure - azure-identity - ${azure.identity.version} - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - - org.slf4j - slf4j-simple - 2.0.7 - - - - - org.junit.jupiter - junit-jupiter-engine - 5.9.3 - test - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.11.0 - - 11 - 11 - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.1.0 - - Main - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.1.2 - - - - - - - - maven-central - https://repo1.maven.org/maven2 - - - \ No newline at end of file diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/questions.jsonl b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/questions.jsonl deleted file mode 100644 index a7d843526..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/questions.jsonl +++ /dev/null @@ -1,8 +0,0 @@ -{"question": "What is our remote work policy regarding security requirements?", "expected_keywords": ["remote", "work", "security", "VPN", "authentication"]} -{"question": "How do I set up Azure Active Directory conditional access?", "expected_keywords": ["Azure", "Active Directory", "conditional access", "configure"]} -{"question": "What collaboration tools are approved for internal use?", "expected_keywords": ["Teams", "SharePoint", "collaboration", "approved"]} -{"question": "How do I implement multi-factor authentication in Azure AD?", "expected_keywords": ["multi-factor", "authentication", "Azure", "MFA", "implement"]} -{"question": "Get current weather data", "expected": "weather"} -{"question": "Summarize Q3 performance", "expected": "performance"} -{"question": "Research market trends", "expected": "research"} -{"question": "Research market trends", "expected": "research"} \ No newline at end of file diff --git a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py b/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py deleted file mode 100644 index a5c424873..000000000 --- a/samples/microsoft/java/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env python3 -""" -SharePoint Connection Setup Guide and Diagnostic Tool -Helps configure SharePoint for the tutorial series foundation. -""" - -import os -from agent import project_client -from dotenv import load_dotenv - -load_dotenv() - -def check_sharepoint_connection_detailed(): - """Get detailed SharePoint connection information""" - - print("๐Ÿ” SharePoint Connection Analysis") - print("="*50) - - try: - connection_name = os.environ["SHAREPOINT_RESOURCE_NAME"] - conn = project_client.connections.get(name=connection_name) - - print(f"โœ… Connection Found: {conn.name}") - print(f"๐Ÿ†” ID: {conn.id}") - print(f"๐Ÿท๏ธ Type: {conn.type}") - print(f"๐Ÿ“‹ Metadata: {conn.metadata}") - print(f"๐Ÿ” Credentials: {conn.credentials}") - print(f"๐ŸŽฏ Target: {conn.target}") - print(f"๐Ÿ”ง Is Default: {conn.is_default}") - - # Analyze the issue - if conn.target == "_": - print(f"\nโŒ ISSUE IDENTIFIED: SharePoint site URL is not configured") - print(f" The 'target' field should contain your SharePoint site URL") - print(f" Current value: '{conn.target}'") - return False - else: - print(f"\nโœ… SharePoint site URL is configured: {conn.target}") - return True - - except Exception as e: - print(f"โŒ Error: {e}") - return False - -def provide_sharepoint_setup_instructions(): - """Provide step-by-step SharePoint setup instructions""" - - print(f"\n๐Ÿ› ๏ธ SHAREPOINT CONNECTION SETUP GUIDE") - print("="*50) - - print("To fix the SharePoint connection for this tutorial series:") - - print(f"\n1๏ธโƒฃ **Go to Azure AI Foundry Portal:**") - print(" - Navigate to https://ai.azure.com") - print(" - Sign in with your Azure account") - print(" - Select your AI Foundry project") - - print(f"\n2๏ธโƒฃ **Configure SharePoint Connection:**") - print(" - Go to 'Settings' > 'Connections'") - print(" - Find your 'Documentor' connection") - print(" - Click 'Edit' or 'Configure'") - - print(f"\n3๏ธโƒฃ **Set SharePoint Site URL:**") - print(" - Enter your SharePoint site URL in format:") - print(" โ€ข https://[tenant].sharepoint.com/sites/[sitename]") - print(" โ€ข Example: https://contoso.sharepoint.com/sites/documents") - print(" - OR use root site: https://[tenant].sharepoint.com") - - print(f"\n4๏ธโƒฃ **Verify Authentication:**") - print(" - Ensure the connection has proper permissions") - print(" - Test the connection in the portal") - print(" - Make sure your Azure AI service can access SharePoint") - - print(f"\n5๏ธโƒฃ **Alternative: Use Microsoft 365 Developer Tenant:**") - print(" - Get free access: https://developer.microsoft.com/microsoft-365/dev-program") - print(" - Includes SharePoint Online with sample data") - print(" - Perfect for tutorials and development") - - print(f"\n๐Ÿ’ก **For Tutorial Series Success:**") - print(" This SharePoint connection will be used across all 3 tutorials for:") - print(" โ€ข Evaluation datasets (Tutorial 2)") - print(" โ€ข Red-teaming scenarios (Tutorial 2)") - print(" โ€ข Production monitoring data (Tutorial 3)") - print(" โ€ข AI gateway integration (Tutorial 3)") - -def suggest_sharepoint_content_structure(): - """Suggest SharePoint content structure for the tutorial series""" - - print(f"\n๐Ÿ“ RECOMMENDED SHAREPOINT CONTENT STRUCTURE") - print("="*50) - print("For maximum tutorial effectiveness, organize your SharePoint with:") - - print(f"\n๐Ÿ“‚ **Document Libraries:**") - print(" โ€ข 'Shared Documents' - Main content library") - print(" โ€ข 'Policies' - Company policies and guidelines") - print(" โ€ข 'Projects' - Project documentation") - print(" โ€ข 'Training Materials' - Learning resources") - - print(f"\n๐Ÿ“„ **Sample Documents to Add:**") - print(" โ€ข Remote work policy document") - print(" โ€ข Employee handbook") - print(" โ€ข Project status reports") - print(" โ€ข Technical documentation") - print(" โ€ข Meeting notes and minutes") - - print(f"\n๐ŸŽฏ **Why This Helps the Tutorial Series:**") - print(" โ€ข Tutorial 1: Agent can find and discuss real content") - print(" โ€ข Tutorial 2: Realistic evaluation scenarios with actual data") - print(" โ€ข Tutorial 3: Production-like monitoring with meaningful content") - -def test_sharepoint_once_fixed(): - """Provide a test script for once SharePoint is fixed""" - - print(f"\n๐Ÿงช TEST SCRIPT (Run After Fixing SharePoint)") - print("="*50) - - test_script = ''' -# Save this as test_fixed_sharepoint.py and run after fixing the connection: - -from agent import create_single_agent, project_client, create_mcp_tool -from azure.ai.agents.models import SharepointTool -import time -import os - -def test_real_sharepoint(): - """Test SharePoint with real connection""" - - # Create SharePoint-only agent - sharepoint_conn = project_client.connections.get(name=os.environ["SHAREPOINT_RESOURCE_NAME"]) - sharepoint_tool = SharepointTool(connection_id=sharepoint_conn.id) - - agent = project_client.agents.create_agent( - model=os.environ["MODEL_DEPLOYMENT_NAME"], - name="sharepoint-tester", - instructions="You are a SharePoint assistant. Search and provide information from the connected SharePoint site.", - tools=sharepoint_tool.definitions - ) - - # Test questions that should work with real SharePoint - test_questions = [ - "What documents are in the Shared Documents library?", - "Are there any policy documents available?", - "What files can you find on this SharePoint site?", - "List the document libraries available" - ] - - print("Testing SharePoint connection...") - for question in test_questions: - thread = project_client.agents.threads.create() - project_client.agents.messages.create(thread_id=thread.id, role="user", content=question) - run = project_client.agents.runs.create(thread_id=thread.id, agent_id=agent.id) - - while run.status in ["queued", "in_progress", "requires_action"]: - time.sleep(1) - run = project_client.agents.runs.get(thread_id=thread.id, run_id=run.id) - - messages = list(project_client.agents.messages.list(thread_id=thread.id)) - for msg in messages: - if msg.role.value == "assistant" and msg.content: - print(f"Q: {question}") - print(f"A: {msg.content[0].text.value[:200]}...") - print("-" * 50) - break - -if __name__ == "__main__": - test_real_sharepoint() -''' - - print(test_script) - -def main(): - """Main diagnostic and setup guide""" - - print("๐Ÿš€ SharePoint Setup for Azure AI Foundry Tutorial Series") - print("This ensures your foundation supports all 3 tutorials") - - # Check current state - is_working = check_sharepoint_connection_detailed() - - if not is_working: - # Provide setup instructions - provide_sharepoint_setup_instructions() - suggest_sharepoint_content_structure() - test_sharepoint_once_fixed() - else: - print("โœ… SharePoint connection appears to be configured correctly!") - print("๐Ÿ’ก Proceed with testing the actual SharePoint functionality.") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/.env.template b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/.env.template deleted file mode 100644 index 5107649cc..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/.env.template +++ /dev/null @@ -1,10 +0,0 @@ -# Azure AI Foundry Configuration -PROJECT_ENDPOINT=https://your-project.aiservices.azure.com -MODEL_DEPLOYMENT_NAME=gpt-4o -AI_FOUNDRY_TENANT_ID=your-ai-foundry-tenant-id - -# Microsoft Learn MCP Server (Works out-of-the-box!) -MCP_SERVER_URL=https://learn.microsoft.com/api/mcp - -# SharePoint Integration (Optional - requires additional setup) -SHAREPOINT_RESOURCE_NAME=your-sharepoint-connection diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md deleted file mode 100644 index 01aa46468..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md +++ /dev/null @@ -1,57 +0,0 @@ -# MCP Server Options for Azure AI Foundry Sample - -## Current Issue -The Microsoft Learn MCP server (https://learn.microsoft.com/api/mcp) requires approval, causing runs to get cancelled. - -## Recommended MCP Servers (No Approval Required) - -### 1. Weather MCP Server -``` -MCP_SERVER_URL=https://mcp-weather.vercel.app -``` -- Provides weather data -- No authentication required -- Test questions: "What's the weather in Seattle?", "Get current weather for New York" - -### 2. Public APIs MCP Server -``` -MCP_SERVER_URL=https://mcp-public-apis.herokuapp.com -``` -- Access to various public APIs -- No authentication required -- Test questions: "Get information about cats", "Find a random fact" - -### 3. Wikipedia MCP Server -``` -MCP_SERVER_URL=https://mcp-wikipedia.glitch.me -``` -- Search Wikipedia articles -- No authentication required -- Test questions: "Search Wikipedia for Azure", "Tell me about cloud computing" - -### 4. GitHub Public MCP Server -``` -MCP_SERVER_URL=https://api.githubcopilot.com/mcp/ -``` -- Access public GitHub repositories -- May require authentication -- Test questions: "Search GitHub for Azure samples" - -## Recommended for Sample -Use the **Weather MCP Server** as it's: -- โœ… Reliable and stable -- โœ… No authentication required -- โœ… No approval required -- โœ… Easy to test with weather questions -- โœ… Demonstrates external API integration - -## Update .env -``` -MCP_SERVER_URL=https://mcp-weather.vercel.app -``` - -## Test Questions -After updating: -- "What's the weather in Seattle?" -- "Get current weather for London" -- "Tell me the temperature in Tokyo" \ No newline at end of file diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/README.md b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/README.md deleted file mode 100644 index d89126f3f..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/README.md +++ /dev/null @@ -1,323 +0,0 @@ -# Azure AI Foundry - Modern Workplace Assistant - -**Tutorial 1** of the Azure AI Foundry enterprise tutorial series. This sample demonstrates how to build AI agents that combine internal knowledge (SharePoint) with external technical guidance (Microsoft Learn) for realistic business scenarios. - -> **๐Ÿš€ Preview SDK**: This sample uses preview versions of the Azure AI SDK. These features will be GA at Microsoft Ignite. - -## ๐ŸŽฏ Business Scenario: Modern Workplace Assistant - -This sample creates an AI assistant that helps employees with: -- **Company policies** (from SharePoint documents) -- **Technical implementation** (from Microsoft Learn) -- **Complete solutions** (combining both sources) - -**Example Questions:** -- "What is our remote work security policy?" โ†’ *Uses SharePoint* -- "How do I set up Azure AD conditional access?" โ†’ *Uses Microsoft Learn* -- "Our policy requires MFA - how do I implement it in Azure?" โ†’ *Uses both sources* - -## ๏ฟฝ Quick Start - -### 1. Run the Main Sample - -```bash -python main.py -``` - -This demonstrates the core functionality with sample business scenarios. - -### 2. Run Evaluation - -```bash -python evaluate.py -``` - -Tests the agent with predefined questions and measures quality. - -## ๐Ÿ“ Ultra-Minimal Sample Structure - -This sample contains only **10 essential files** - nothing extraneous: - -### Core Sample (3 files) - -- **`main.py`** - Complete Modern Workplace Assistant (148 lines) -- **`evaluate.py`** - Business evaluation framework (54 lines) -- **`questions.jsonl`** - Business test scenarios (4 questions) - -### Setup & Documentation (7 files) - -- **`requirements.txt`** - Python dependencies -- **`.env.template`** - Environment variables template -- **`setup_sharepoint.py`** - SharePoint diagnostic tool -- **`MCP_SERVERS.md`** - MCP server configuration guide -- **`SAMPLE_SHAREPOINT_CONTENT.md`** - Sample business documents -- **`README.md`** - Complete setup instructions -- **`.env`** - Your actual configuration (create from template) - -## ๐Ÿ“ SharePoint Business Documents Setup - -To demonstrate the complete business scenario, you need to upload sample documents to your SharePoint site. The sample includes realistic Contoso Corp business documents that create scenarios where employees need both company policy information and technical implementation guidance. - -### Step 1: Prepare Your SharePoint Site - -1. **Navigate to your SharePoint site** (the one configured in your Azure AI Foundry SharePoint connection) -2. **Create or use a document library** called "Company Policies" or use the default "Documents" library -3. **Ensure you have edit permissions** to upload documents - -### Step 2: Create Sample Business Documents - -The `SAMPLE_SHAREPOINT_CONTENT.md` file contains four realistic business documents. Create these as Word documents (.docx) in your SharePoint site: - -#### ๐Ÿ“„ Document 1: `remote-work-policy.docx` -**Content**: Remote work security requirements including VPN usage, MFA requirements, device compliance, and data access policies. References Azure AD and Microsoft 365 security features. - -#### ๐Ÿ“„ Document 2: `security-guidelines.docx` -**Content**: Azure security standards including conditional access policies, identity governance, and compliance requirements. Establishes company standards for Azure resource security. - -#### ๐Ÿ“„ Document 3: `collaboration-standards.docx` -**Content**: Microsoft Teams and SharePoint usage policies, including data sharing guidelines, external collaboration rules, and communication standards. - -#### ๐Ÿ“„ Document 4: `data-governance-policy.docx` -**Content**: Data classification, retention policies, and governance requirements for Azure and Microsoft 365 data. Includes sensitivity labels and compliance procedures. - -### Step 3: Upload Documents to SharePoint - -1. **For each document in `SAMPLE_SHAREPOINT_CONTENT.md`**: - - Create a new Word document in SharePoint - - Copy the content from the corresponding section - - Save with the specified filename (e.g., `remote-work-policy.docx`) - -2. **Verify document access**: - - Ensure documents are searchable - - Check that your Azure AI Foundry connection can access the site - - Test that documents appear in SharePoint search results - -### Why These Documents Matter - -These sample documents create realistic business scenarios: - -- **"What is our remote work security policy?"** โ†’ Searches `remote-work-policy.docx` -- **"How do I set up Azure AD conditional access?"** โ†’ Uses Microsoft Learn MCP -- **"Our policy requires MFA - how do I implement it in Azure?"** โ†’ Combines both sources - -This demonstrates how modern workplace assistants help employees by connecting company policies with technical implementation guidance. - -## ๐Ÿš€ Quick Start (5 minutes) - -### Step 1: Prerequisites Check - -Make sure you have: - -- [x] **Azure AI Foundry project** with a deployed model (e.g., `gpt-4o-mini`) -- [x] **Python 3.10+** installed (`python --version`) -- [x] **SharePoint connection** configured in your Azure AI Foundry project -- [x] **MCP server endpoint** (or use a placeholder for testing) -- [x] **Azure CLI** authenticated (`az login`) - -### Step 2: Environment Setup - -1. **Copy the environment template:** - - ```bash - cp .env.template .env - ``` - -2. **Edit `.env` with your actual values:** - - ```bash - PROJECT_ENDPOINT=https://your-project.aiservices.azure.com - MODEL_DEPLOYMENT_NAME=gpt-4o-mini - SHAREPOINT_RESOURCE_NAME=your-sharepoint-connection - MCP_SERVER_URL=https://your-mcp-server.com - ``` - -3. **Install dependencies (with preview features):** - - ```bash - pip install --pre -r requirements.txt - ``` - -### Step 3: Test Single Agent - -Run the main agent script: - -```bash -python main.py -``` - -**Expected output:** - -```text -Created agent: -SharePoint Response: -``` - -> **Note**: You'll get a "Resource not found" error until you configure actual SharePoint and MCP connections in Azure AI Foundry. - -### Step 4: Test Multi-Agent System - -In Python interactive mode: - -```python -from agent import test_multi_agent -test_multi_agent() -``` - -**Expected output:** - -```text -Multi-agent system: Main , Research -Multi-agent response: -``` - -### Step 5: Run Evaluation - -Evaluate your agent with test questions: - -```bash -python eval.py -``` - -**Expected output:** - -```json -Evaluation: 3/4 passed -[ - { - "question": "What's our remote work policy?", - "response": "According to SharePoint...", - "contains_expected": true - } - ... -] -``` - -## ๐Ÿ”ง Troubleshooting - -### Common Issues - -#### Authentication failed - -- Run `az login` and ensure you're logged into the correct tenant -- Verify your `PROJECT_ENDPOINT` is correct - -#### SharePoint Connection Issues - -**๐Ÿ” The Problem**: SharePoint connections are tied to individual agents in the portal, but this sample creates agents programmatically. - -**๐Ÿ”ง The Solutions**: - -**Option 1: Fix Existing Connection (Recommended)** -1. Go to [Azure AI Foundry portal](https://ai.azure.com) โ†’ Your Project -2. **Management Center** โ†’ **Connected Resources** -3. Find your SharePoint connection (e.g., "Documentor") -4. **Edit** the connection and update **Target URL** from `_` to your actual site -5. Use format: `https://company.sharepoint.com/teams/site-name` - -**Option 2: Create Fresh Connection** -- **Management Center** โ†’ **Connected Resources** โ†’ **Add SharePoint** -- Connection name: Match your `SHAREPOINT_RESOURCE_NAME` in `.env` -- Site URL: Your actual SharePoint site -- Update `.env` with new connection name if different - -**Option 3: MCP-Only Mode** -- Comment out SharePoint variables in `.env` -- Sample works perfectly with just Microsoft Learn integration - -#### MCP server unreachable - -- For testing, you can comment out MCP tool lines in `agent.py` -- Or use a mock endpoint: `https://httpbin.org/json` - -#### Model deployment not found - -- Verify your `MODEL_DEPLOYMENT_NAME` matches exactly what's deployed -- Check Azure AI Foundry portal โ†’ Models โ†’ Deployments - -### Debug Mode - -Add debug logging to see what's happening: - -```python -import logging -logging.basicConfig(level=logging.DEBUG) -``` - -## ๐Ÿ“Š Understanding the Code - -### `agent.py` - Main Agent Logic - -- **`create_single_agent()`**: Creates an agent with SharePoint + MCP tools -- **`create_multi_agent()`**: Creates connected agents for delegation -- **`chat_with_agent()`**: Handles conversations with memory persistence -- **`test_multi_agent()`**: Demonstrates agent-to-agent communication - -### `eval.py` - Quality Assessment - -- **`run_evaluation()`**: Batch tests agent responses against expected keywords -- Uses `questions.jsonl` as test data -- Provides pass/fail summary with detailed results - -### `questions.jsonl` - Test Dataset - -Each line is a JSON object with: - -- **`question`**: What to ask the agent -- **`expected`**: Keyword that should appear in the response - -## ๐Ÿš€ Deploy to Azure AI Foundry - -### Option 1: Portal Deployment - -1. Go to [Azure AI Foundry](https://ai.azure.com) -2. Navigate to your project โ†’ **Agents** -3. Click **+ Create** โ†’ **Import from code** -4. Upload your `agent.py` file -5. Configure deployment settings -6. Click **Deploy** - -### Option 2: CLI Deployment - -```bash -# Install Azure AI CLI extension -az extension add --name azure-ai - -# Deploy agent -az ai agent create --file agent.py --project -``` - -### Get Share Link - -After deployment: - -1. Go to **Agents** โ†’ Your deployed agent -2. Click **Share** โ†’ **Create public link** -3. Test with friends/colleagues! - -## ๐ŸŽ“ Learning Path - -**Completed this sample?** Here's what to explore next: - -1. **Add more tools**: Azure AI Search, Bing Web Search, Function Calling -2. **Advanced evaluation**: Custom metrics, A/B testing, human feedback -3. **Production setup**: Monitoring, logging, error handling -4. **Scale up**: RAG with vector stores, complex multi-agent workflows - -## ๐Ÿ“š Resources - -- [Azure AI Foundry Documentation](https://docs.microsoft.com/azure/ai-foundry) -- [Agent Service Overview](https://docs.microsoft.com/azure/ai-foundry/agents) -- [SharePoint Tool Guide](https://docs.microsoft.com/azure/ai-foundry/agents/tools/sharepoint) -- [MCP Integration](https://docs.microsoft.com/azure/ai-foundry/agents/tools/mcp) - -## ๐Ÿค Support - -**Questions?** - -- Check the [troubleshooting section](#-troubleshooting) above -- Review the [full tutorial](https://docs.microsoft.com/azure/ai-foundry/tutorials/developer-journey-stage-1) -- File issues in the Azure AI Foundry feedback portal - ---- - -**Happy coding!** ๐ŸŽ‰ This sample gets you from zero to working enterprise agent in minutes. diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md deleted file mode 100644 index dbc930527..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md +++ /dev/null @@ -1,176 +0,0 @@ -# Sample SharePoint Content for Tutorial Series - -To create a coherent business scenario, upload these sample documents to your SharePoint site: - -## Document Structure - -### ๐Ÿ“ Shared Documents/Policies/ -1. **remote-work-policy.docx** -2. **security-guidelines.docx** -3. **collaboration-standards.docx** -4. **data-governance-policy.docx** - -### ๐Ÿ“ Shared Documents/Procedures/ -1. **employee-onboarding.docx** -2. **project-workflow.docx** -3. **incident-response.docx** - ---- - -## Sample Document Content - -### 1. Remote Work Policy (remote-work-policy.docx) - -``` -CONTOSO CORP - REMOTE WORK POLICY - -Effective Date: January 2024 - -OVERVIEW -Contoso Corp supports flexible work arrangements including remote work to enhance employee productivity and work-life balance. - -ELIGIBILITY -- Full-time employees after 90-day probationary period -- Manager approval required -- Role must be suitable for remote work - -TECHNOLOGY REQUIREMENTS -- Secure VPN connection required -- Use of Microsoft 365 and Azure services mandatory -- Multi-factor authentication enabled -- Personal devices must meet security standards - -SECURITY PROTOCOLS -- All data must be stored in approved cloud services (SharePoint, OneDrive) -- No sensitive data on personal devices -- Regular security training completion required -- Incident reporting within 2 hours - -COLLABORATION TOOLS -- Microsoft Teams for meetings and communication -- SharePoint for document collaboration -- Azure DevOps for development projects -- Outlook for email and calendar management - -REVIEW -This policy is reviewed annually and updated as needed. -``` - -### 2. Security Guidelines (security-guidelines.docx) - -``` -CONTOSO CORP - INFORMATION SECURITY GUIDELINES - -OVERVIEW -These guidelines ensure the protection of Contoso's information assets and compliance with industry standards. - -AZURE SECURITY REQUIREMENTS -- All cloud resources must use Azure Active Directory -- Enable Azure Security Center monitoring -- Implement Azure Key Vault for secrets management -- Use Azure Policy for compliance enforcement - -ACCESS MANAGEMENT -- Role-based access control (RBAC) mandatory -- Privileged Identity Management (PIM) for admin roles -- Regular access reviews quarterly -- Conditional access policies enforced - -DATA PROTECTION -- Data classification using Microsoft Purview -- Encryption at rest and in transit -- Regular backup verification -- Data retention policies enforced - -INCIDENT RESPONSE -- Use Azure Sentinel for threat detection -- Report security incidents immediately -- Follow established escalation procedures -- Document all security events -``` - -### 3. Collaboration Standards (collaboration-standards.docx) - -``` -CONTOSO CORP - COLLABORATION STANDARDS - -DOCUMENT MANAGEMENT -- All business documents stored in SharePoint Online -- Version control enabled for all document libraries -- Metadata required: Department, Project, Classification -- Folder structure: /Department/Project/Year/ - -COMMUNICATION GUIDELINES -- Microsoft Teams for internal communication -- Email for external communication only -- Weekly team meetings via Teams -- Project updates in SharePoint lists - -DEVELOPMENT STANDARDS -- Source code in Azure DevOps repositories -- CI/CD pipelines for all applications -- Code reviews required for all changes -- Azure Monitor for application monitoring - -TRAINING REQUIREMENTS -- Microsoft 365 certification within 6 months -- Azure fundamentals for technical staff -- Security awareness training quarterly -- Collaboration tools training for new hires -``` - -### 4. Data Governance Policy (data-governance-policy.docx) - -``` -CONTOSO CORP - DATA GOVERNANCE POLICY - -DATA CLASSIFICATION -- Public: Marketing materials, published content -- Internal: Business documents, policies, procedures -- Confidential: Financial data, employee records -- Restricted: Legal documents, intellectual property - -STORAGE REQUIREMENTS -- Public: SharePoint sites, public websites -- Internal: SharePoint document libraries with access controls -- Confidential: Restricted SharePoint sites with encryption -- Restricted: Azure Key Vault, encrypted storage accounts - -MICROSOFT 365 COMPLIANCE -- Data Loss Prevention (DLP) policies enabled -- Sensitivity labels applied to all documents -- Retention policies configured by data type -- eDiscovery capabilities for legal requirements - -AZURE DATA SERVICES -- Azure SQL Database for structured data -- Azure Data Lake for analytics workloads -- Azure Synapse for data warehousing -- Power BI for business intelligence -``` - ---- - -## Business Scenario Test Questions - -These questions demonstrate the coherent business use case: - -### Internal Policy Questions (SharePoint) -- "What is our remote work policy regarding VPN requirements?" -- "What are the security protocols for remote employees?" -- "How should we classify confidential business documents?" -- "What collaboration tools are approved for internal use?" - -### Technical Implementation Questions (MCP - Microsoft Learn) -- "How do I set up Azure Active Directory for our remote workers?" -- "What are the steps to configure Azure Security Center monitoring?" -- "How do I implement data loss prevention in Microsoft 365?" -- "How do I set up conditional access policies in Azure AD?" - -### Hybrid Questions (Both Sources) -- "Our remote work policy requires secure VPN - how do I implement Azure VPN Gateway?" -- "What Azure services do I need to meet our data governance requirements?" -- "How do I configure Microsoft Teams to comply with our collaboration standards?" -- "What Azure security services align with our incident response procedures?" - -This creates a **realistic business scenario** where the AI assistant helps employees understand company policies AND implement them using Microsoft technologies. \ No newline at end of file diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/evaluate.py b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/evaluate.py deleted file mode 100644 index 569b7dd08..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/evaluate.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python3 -""" -Evaluation Script for Modern Workplace Assistant -Tests the agent with predefined business scenarios to assess quality. -""" - -#region evaluation_imports -import json -from main import create_workplace_assistant, chat_with_assistant -#endregion evaluation_imports - -#region evaluation_functions -def load_test_questions(filepath="questions.jsonl"): - """Load test questions from JSONL file""" - questions = [] - with open(filepath, 'r') as f: - for line in f: - questions.append(json.loads(line.strip())) - return questions - -def run_evaluation(agent_id, mcp_tool): - """Run evaluation with test questions""" - questions = load_test_questions() - results = [] - - print(f"๐Ÿงช Running evaluation with {len(questions)} test questions...") - - for i, q in enumerate(questions, 1): - print(f"๐Ÿ“ Question {i}/{len(questions)}: {q['question']}") - - response = chat_with_assistant(agent_id, mcp_tool, q["question"]) - - # Simple evaluation: check if response contains expected keywords - contains_expected = any(keyword.lower() in response.lower() - for keyword in q.get("expected_keywords", [])) - - result = { - "question": q["question"], - "response": response, - "contains_expected": contains_expected, - "expected_keywords": q.get("expected_keywords", []) - } - results.append(result) - - status = "โœ…" if contains_expected else "โš ๏ธ" - print(f"{status} Response length: {len(response)} chars") - - # Calculate pass rate - passed = sum(1 for r in results if r["contains_expected"]) - print(f"\n๐Ÿ“Š Evaluation Results: {passed}/{len(results)} questions passed") - - return results -#endregion evaluation_functions - -#region evaluation_main -def main(): - """Run evaluation on the workplace assistant""" - print("๐Ÿงช Modern Workplace Assistant - Evaluation") - print("="*50) - - try: - # Create agent - agent, mcp_tool = create_workplace_assistant() - - # Run evaluation - results = run_evaluation(agent.id, mcp_tool) - - # Save results - with open("evaluation_results.json", "w") as f: - json.dump(results, f, indent=2) - - print(f"๐Ÿ’พ Results saved to evaluation_results.json") - - except Exception as e: - print(f"โŒ Evaluation failed: {e}") -#endregion evaluation_main - -#region evaluation_execution -if __name__ == "__main__": - main() -#endregion evaluation_execution \ No newline at end of file diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/main.py b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/main.py deleted file mode 100644 index 725cb3270..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/main.py +++ /dev/null @@ -1,392 +0,0 @@ -#!/usr/bin/env python3 -""" -Azure AI Foundry Agent Sample - Tutorial 1: Modern Workplace Assistant - -This sample demonstrates a complete business scenario combining: -- SharePoint integration for internal company knowledge -- Microsoft Learn MCP integration for external technical guidance -- Intelligent orchestration of multiple data sources -- Robust error handling and graceful degradation - -Educational Focus: -- Enterprise AI patterns with multiple data sources -- Real-world business scenarios that enterprises face daily -- Production-ready error handling and diagnostics -- Foundation for governance, evaluation, and monitoring (Tutorials 2-3) - -Business Scenario: -An employee needs to implement Azure AD multi-factor authentication. They need: -1. Company security policy requirements (from SharePoint) -2. Technical implementation steps (from Microsoft Learn) -3. Combined guidance showing how policy requirements map to technical implementation -""" - -#region imports_and_setup -import os -import time -from azure.ai.projects import AIProjectClient -from azure.identity import DefaultAzureCredential, AzureCliCredential -from azure.ai.agents.models import SharepointTool, McpTool, ToolResources -from dotenv import load_dotenv - -load_dotenv() - -# ============================================================================ -# AUTHENTICATION SETUP -# ============================================================================ -# Support both default Azure credentials and specific tenant authentication -ai_foundry_tenant_id = os.getenv("AI_FOUNDRY_TENANT_ID") -if ai_foundry_tenant_id: - print(f"๐Ÿ” Using AI Foundry tenant: {ai_foundry_tenant_id}") - credential = AzureCliCredential() -else: - credential = DefaultAzureCredential() - -project_client = AIProjectClient( - endpoint=os.environ["PROJECT_ENDPOINT"], - credential=credential, -) -#endregion imports_and_setup - -#region create_workplace_assistant -def create_workplace_assistant(): - """ - Create a Modern Workplace Assistant combining internal and external knowledge. - - This demonstrates enterprise AI patterns: - 1. Multi-source data integration (SharePoint + MCP) - 2. Robust error handling with graceful degradation - 3. Dynamic agent capabilities based on available resources - 4. Clear diagnostic information for troubleshooting - - Educational Value: - - Shows real-world complexity of enterprise AI systems - - Demonstrates how to handle partial system failures - - Provides patterns for combining internal and external data - - Returns: - tuple: (agent, mcp_tool) for further interaction and testing - """ - - print("๐Ÿค– Creating Modern Workplace Assistant...") - - # ======================================================================== - # SHAREPOINT INTEGRATION SETUP - # ======================================================================== - # SharePoint provides access to internal company knowledge: - # - Company policies and procedures - # - Security guidelines and requirements - # - Governance and compliance documentation - # - Internal process documentation - - sharepoint_resource_name = os.environ["SHAREPOINT_RESOURCE_NAME"] - - print(f"๐Ÿ“ Configuring SharePoint integration...") - print(f" Connection: {sharepoint_resource_name}") - - try: - # Attempt to retrieve pre-configured SharePoint connection - sharepoint_conn = project_client.connections.get(name=sharepoint_resource_name) - sharepoint_tool = SharepointTool(connection_id=sharepoint_conn.id) - print(f"โœ… SharePoint successfully connected") - - except Exception as e: - # Graceful degradation - system continues without SharePoint - print(f"โš ๏ธ SharePoint connection failed: {e}") - print(" Agent will operate in technical guidance mode only") - print(" ๐Ÿ“ To enable full functionality:") - print(" Create SharePoint connection in Azure AI Foundry portal") - print(f" Connection name: {sharepoint_resource_name}") - sharepoint_tool = None - - # ======================================================================== - # MICROSOFT LEARN MCP INTEGRATION SETUP - # ======================================================================== - # Microsoft Learn MCP provides access to current technical documentation: - # - Azure service configuration guides - # - Best practices and implementation patterns - # - Troubleshooting and diagnostic information - # - Latest feature updates and capabilities - - print(f"๐Ÿ“š Configuring Microsoft Learn MCP integration...") - mcp_tool = McpTool( - server_label="microsoft_learn", - server_url=os.environ["MCP_SERVER_URL"], - allowed_tools=[] # Allow all available tools - ) - # Disable approval workflow for seamless demonstration - mcp_tool.set_approval_mode("never") - print(f"โœ… Microsoft Learn MCP connected: {os.environ['MCP_SERVER_URL']}") - - # ======================================================================== - # AGENT CREATION WITH DYNAMIC CAPABILITIES - # ======================================================================== - # Create agent instructions based on available data sources - # This demonstrates adaptive system design - - if sharepoint_tool: - instructions = """You are a Modern Workplace Assistant for Contoso Corporation. - -CAPABILITIES: -- Search SharePoint for company policies, procedures, and internal documentation -- Access Microsoft Learn for current Azure and Microsoft 365 technical guidance -- Provide comprehensive solutions combining internal requirements with external implementation - -RESPONSE STRATEGY: -- For policy questions: Search SharePoint for company-specific requirements and guidelines -- For technical questions: Use Microsoft Learn for current Azure/M365 documentation and best practices -- For implementation questions: Combine both sources to show how company policies map to technical implementation -- Always cite your sources and provide step-by-step guidance -- Explain how internal requirements connect to external implementation steps - -EXAMPLE SCENARIOS: -- "What is our MFA policy?" โ†’ Search SharePoint for security policies -- "How do I configure Azure AD Conditional Access?" โ†’ Use Microsoft Learn for technical steps -- "Our policy requires MFA - how do I implement this?" โ†’ Combine policy requirements with implementation guidance""" - else: - instructions = """You are a Technical Assistant with access to Microsoft Learn documentation. - -CAPABILITIES: -- Access Microsoft Learn for current Azure and Microsoft 365 technical guidance -- Provide detailed implementation steps and best practices -- Explain Azure services, features, and configuration options - -LIMITATIONS: -- SharePoint integration is not available -- Cannot access company-specific policies or internal documentation -- When asked about company policies, explain that internal document access requires SharePoint configuration - -RESPONSE STRATEGY: -- Provide comprehensive technical guidance from Microsoft Learn -- Include step-by-step implementation instructions -- Reference official documentation and best practices -- Suggest how technical implementations typically align with enterprise requirements""" - - # Create the agent with appropriate tool configuration - print(f"๐Ÿ› ๏ธ Configuring agent tools...") - available_tools = (sharepoint_tool.definitions if sharepoint_tool else []) + mcp_tool.definitions - print(f" Available tools: {len(available_tools)}") - - agent = project_client.agents.create_agent( - model=os.environ["MODEL_DEPLOYMENT_NAME"], - name="Modern Workplace Assistant", - instructions=instructions, - tools=available_tools, - ) - - print(f"โœ… Agent created successfully: {agent.id}") - return agent, mcp_tool, sharepoint_tool -#endregion create_workplace_assistant - -#region demonstrate_business_scenarios -def demonstrate_business_scenarios(agent, mcp_tool, sharepoint_tool): - """ - Demonstrate realistic business scenarios combining internal and external knowledge. - - This function showcases the practical value of the Modern Workplace Assistant - by walking through scenarios that enterprise employees face regularly. - - Educational Value: - - Shows real business problems that AI agents can solve - - Demonstrates integration between internal policies and external guidance - - Illustrates how AI can bridge the gap between requirements and implementation - """ - - scenarios = [ - { - "title": "๐Ÿ“‹ Company Policy Question", - "question": "What is our remote work security policy regarding multi-factor authentication?", - "context": "Employee needs to understand company MFA requirements", - "expected_source": "SharePoint", - "learning_point": "Internal policy retrieval and interpretation" - }, - { - "title": "๐Ÿ”ง Technical Implementation Question", - "question": "How do I set up Azure Active Directory conditional access policies?", - "context": "IT administrator needs technical implementation steps", - "expected_source": "Microsoft Learn MCP", - "learning_point": "External technical documentation access" - }, - { - "title": "๐Ÿ”„ Combined Business Implementation Question", - "question": "Our company security policy requires multi-factor authentication for remote workers. How do I implement this requirement using Azure AD?", - "context": "Need to combine policy requirements with technical implementation", - "expected_source": "Both SharePoint and MCP", - "learning_point": "Multi-source intelligence combining internal requirements with external implementation" - } - ] - - print("\n" + "="*70) - print("๐Ÿข MODERN WORKPLACE ASSISTANT - BUSINESS SCENARIO DEMONSTRATION") - print("="*70) - print("This demonstration shows how AI agents solve real business problems") - print("by combining internal company knowledge with external technical guidance.") - print("="*70) - - for i, scenario in enumerate(scenarios, 1): - print(f"\n๐Ÿ“Š SCENARIO {i}/3: {scenario['title']}") - print("-" * 50) - print(f"โ“ QUESTION: {scenario['question']}") - print(f"๐ŸŽฏ BUSINESS CONTEXT: {scenario['context']}") - print(f"๐Ÿ“š EXPECTED SOURCE: {scenario['expected_source']}") - print(f"๐ŸŽ“ LEARNING POINT: {scenario['learning_point']}") - print("-" * 50) - - # Get response from the agent - print("๐Ÿค– ASSISTANT RESPONSE:") - response, status = chat_with_assistant(agent.id, mcp_tool, scenario['question']) - - # Display response with analysis - if status == 'completed' and response and len(response.strip()) > 10: - print(f"โœ… SUCCESS: {response[:300]}...") - if len(response) > 300: - print(f" ๐Ÿ“ Full response: {len(response)} characters") - else: - print(f"โš ๏ธ LIMITED RESPONSE: {response}") - if not sharepoint_tool and scenario['expected_source'] in ['SharePoint', 'Both SharePoint and MCP']: - print(" ๐Ÿ’ก This demonstrates graceful degradation when SharePoint is unavailable") - - print(f"๐Ÿ“ˆ STATUS: {status}") - print("-" * 50) - - print(f"\nโœ… DEMONSTRATION COMPLETED!") - print("๐ŸŽ“ Key Learning Outcomes:") - print(" โ€ข Multi-source data integration in enterprise AI") - print(" โ€ข Robust error handling and graceful degradation") - print(" โ€ข Real business value through combined intelligence") - print(" โ€ข Foundation for governance and monitoring (Tutorials 2-3)") - - return True - -def chat_with_assistant(agent_id, mcp_tool, message): - """ - Execute a conversation with the workplace assistant. - - This function demonstrates the conversation pattern for Azure AI Foundry agents - and includes comprehensive error handling for production readiness. - - Educational Value: - - Shows proper thread management and conversation flow - - Demonstrates streaming response handling - - Includes timeout and error management patterns - """ - - try: - # Create conversation thread (maintains conversation context) - thread = project_client.agents.threads.create() - - # Add user message to thread - project_client.agents.messages.create( - thread_id=thread.id, - role="user", - content=message - ) - - # Execute the conversation with streaming response - run = project_client.agents.runs.create_and_stream( - thread_id=thread.id, - assistant_id=agent_id, - ) - - # Collect streaming response - response_parts = [] - run_info = None - - for event_type, event_data, run_status in run: - run_info = run_status - if event_type == 'MessageDelta': - for content_part in event_data.delta.content: - if hasattr(content_part, 'text') and content_part.text.value: - response_parts.append(content_part.text.value) - - full_response = ''.join(response_parts) - final_status = run_info.status if run_info else 'unknown' - - return full_response, final_status - - except Exception as e: - return f"Error in conversation: {e}", 'failed' - -def interactive_mode(agent, mcp_tool): - """ - Interactive mode for testing the workplace assistant. - - This provides a simple interface for users to test the agent with their own questions - and see how it combines different data sources for comprehensive answers. - """ - - print("\n" + "="*60) - print("๐Ÿ’ฌ INTERACTIVE MODE - Test Your Workplace Assistant!") - print("="*60) - print("Ask questions that combine company policies with technical guidance:") - print("โ€ข 'What's our remote work policy for Azure access?'") - print("โ€ข 'How do I configure SharePoint security?'") - print("โ€ข 'Our policy requires encryption - how do I set this up in Azure?'") - print("Type 'quit' to exit.") - print("-" * 60) - - while True: - try: - question = input("\nโ“ Your question: ").strip() - - if question.lower() in ['quit', 'exit', 'bye']: - break - - if not question: - print("๐Ÿ’ก Please ask a question about policies or technical implementation.") - continue - - print(f"\n๐Ÿค– Workplace Assistant: ", end="", flush=True) - response, status = chat_with_assistant(agent.id, mcp_tool, question) - print(response) - - if status != 'completed': - print(f"\nโš ๏ธ Response status: {status}") - - print("-" * 60) - - except KeyboardInterrupt: - break - except Exception as e: - print(f"\nโŒ Error: {e}") - print("-" * 60) - - print("\n๐Ÿ‘‹ Thank you for testing the Modern Workplace Assistant!") -#endregion demonstrate_business_scenarios - -#region main -def main(): - """ - Main execution flow demonstrating the complete sample. - - This orchestrates the full demonstration: - 1. Agent creation with diagnostic information - 2. Business scenario demonstration - 3. Interactive testing mode - 4. Clean completion with next steps - """ - - print("๐Ÿš€ Azure AI Foundry - Modern Workplace Assistant") - print("Tutorial 1: Building Enterprise Agents with SharePoint + MCP Integration") - print("="*70) - - # Create the agent with full diagnostic output - agent, mcp_tool, sharepoint_tool = create_workplace_assistant() - - # Demonstrate business scenarios - demonstrate_business_scenarios(agent, mcp_tool, sharepoint_tool) - - # Offer interactive testing - print(f"\n๐ŸŽฏ Try interactive mode? (y/n): ", end="") - if input().lower().startswith('y'): - interactive_mode(agent, mcp_tool) - - print(f"\n๐ŸŽ‰ Sample completed successfully!") - print("๐Ÿ“š This foundation supports Tutorial 2 (Governance) and Tutorial 3 (Production)") - print("๐Ÿ”— Next: Add evaluation metrics, monitoring, and production deployment") -#endregion main - -#region main_execution -if __name__ == "__main__": - main() -#endregion main_execution \ No newline at end of file diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/main_backup.py b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/main_backup.py deleted file mode 100644 index 111f6d71a..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/main_backup.py +++ /dev/null @@ -1,253 +0,0 @@ -#!/usr/bin/env python3 -""" -Azure AI Foundry Agent Sample - Tutorial 1 - -A minimal sample demonstrating enterprise AI agents with: -- SharePoint integration for internal knowledge -- Microsoft Learn MCP integration for technical guidance -- Combined intelligence for business scenarios - -This sample serves as the foundation for Tutorial 2 (Governance & Evaluation) -and Tutorial 3 (Production & Monitoring). -""" - -import os -import time -from azure.ai.projects import AIProjectClient -from azure.identity import DefaultAzureCredential, AzureCliCredential -from azure.ai.agents.models import SharepointTool, McpTool, ToolResources -from dotenv import load_dotenv - -load_dotenv() - -# Authenticate to Azure AI Foundry -ai_foundry_tenant_id = os.getenv("AI_FOUNDRY_TENANT_ID") -if ai_foundry_tenant_id: - print(f"๐Ÿ” Using AI Foundry tenant: {ai_foundry_tenant_id}") - credential = AzureCliCredential() -else: - credential = DefaultAzureCredential() - -project_client = AIProjectClient( - endpoint=os.environ["PROJECT_ENDPOINT"], - credential=credential, -) - -def create_workplace_assistant(): - """Create an AI agent with SharePoint and Microsoft Learn integration""" - - print("๐Ÿค– Creating Modern Workplace Assistant...") - - # Configure SharePoint tool for internal knowledge - sharepoint_resource_name = os.environ["SHAREPOINT_RESOURCE_NAME"] - sharepoint_site_url = os.getenv("SHAREPOINT_SITE_URL") - - try: - # Try to get existing connection first - sharepoint_conn = project_client.connections.get(name=sharepoint_resource_name) - current_target = getattr(sharepoint_conn, 'target', 'N/A') - - # Check if connection has proper target - if current_target == "_" or not current_target or current_target == "N/A": - print(f"โš ๏ธ SharePoint connection '{sharepoint_resource_name}' has invalid target: '{current_target}'") - if sharepoint_site_url: - print(f" Expected: {sharepoint_site_url}") - print(" ๐Ÿ”ง SOLUTION: Update connection target in Azure AI Foundry portal") - print(" 1. Go to Management Center > Connected Resources") - print(f" 2. Edit '{sharepoint_resource_name}' connection") - print(f" 3. Set target URL to: {sharepoint_site_url}") - else: - print(" Set SHAREPOINT_SITE_URL in .env file") - sharepoint_tool = None - else: - sharepoint_tool = SharepointTool(connection_id=sharepoint_conn.id) - print(f"โœ… SharePoint connected: {sharepoint_resource_name}") - print(f" Target: {current_target}") - if sharepoint_site_url and current_target != sharepoint_site_url: - print(f" โš ๏ธ Target mismatch! Expected: {sharepoint_site_url}") - - except Exception as e: - print(f"โš ๏ธ SharePoint connection '{sharepoint_resource_name}' not found") - print(f" Error: {e}") - print(" ๏ฟฝ SOLUTION: Create SharePoint connection in Azure AI Foundry portal") - print(" 1. Management Center > Connected Resources > Add SharePoint") - print(f" 2. Connection name: {sharepoint_resource_name}") - if sharepoint_site_url: - print(f" 3. Site URL: {sharepoint_site_url}") - else: - print(" 3. Site URL: Set SHAREPOINT_SITE_URL in .env file") - sharepoint_tool = None - - # Configure Microsoft Learn MCP tool for technical guidance - mcp_tool = McpTool( - server_label="microsoft_learn", - server_url=os.environ["MCP_SERVER_URL"], - allowed_tools=[] - ) - mcp_tool.set_approval_mode("never") # Enable seamless experience - - # Combine tool resources - tool_resources = {} - if sharepoint_tool and hasattr(sharepoint_tool, 'resources') and sharepoint_tool.resources: - tool_resources.update(sharepoint_tool.resources) - if hasattr(mcp_tool, 'resources') and mcp_tool.resources: - tool_resources.update(mcp_tool.resources) - - # Create dynamic instructions based on available tools - if sharepoint_tool: - instructions = """You are a Modern Workplace Assistant for Contoso Corp. - -Your capabilities: -- Search SharePoint for company policies, procedures, and internal documents -- Access Microsoft Learn for current Azure and Microsoft 365 technical guidance -- Provide comprehensive answers combining internal policies with implementation guidance - -When responding: -- For policy questions: Search SharePoint for company documents -- For technical questions: Use Microsoft Learn for current Azure/M365 guidance -- For implementation questions: Combine both sources to show policy requirements AND technical steps -- Always cite your sources and provide actionable guidance""" - else: - instructions = """You are a Technical Assistant with access to Microsoft Learn documentation. - -Your capabilities: -- Access Microsoft Learn for current Azure and Microsoft 365 technical guidance -- Provide detailed technical implementation steps and best practices - -Note: SharePoint integration is not configured. You can only provide technical guidance from Microsoft Learn. -When users ask about company policies, explain that SharePoint integration needs to be configured.""" - - # Create the agent - agent = project_client.agents.create_agent( - model=os.environ["MODEL_DEPLOYMENT_NAME"], - name="Modern Workplace Assistant", - instructions=instructions, - tools=(sharepoint_tool.definitions if sharepoint_tool else []) + mcp_tool.definitions, - tool_resources=ToolResources(**tool_resources) if tool_resources else None - ) - - print(f"โœ… Agent created: {agent.id}") - return agent, mcp_tool - -def chat_with_assistant(agent_id, mcp_tool, message): - """Send a message to the workplace assistant and get a response""" - - # Create conversation thread - thread = project_client.agents.threads.create() - project_client.agents.messages.create(thread_id=thread.id, role="user", content=message) - - # Run the agent with both SharePoint and MCP tools - run = project_client.agents.runs.create( - thread_id=thread.id, - agent_id=agent_id, - tool_resources=mcp_tool.resources - ) - - # Wait for completion - while run.status in ["queued", "in_progress", "requires_action"]: - time.sleep(1) - run = project_client.agents.runs.get(thread_id=thread.id, run_id=run.id) - - # Get the response - messages = list(project_client.agents.messages.list(thread_id=thread.id)) - for msg in messages: - if msg.role.value == "assistant" and msg.content: - return msg.content[0].text.value - - return f"No response received (Status: {run.status})" - -def run_sample_demo(): - """Demonstrate the workplace assistant with sample business scenarios""" - - print("๐Ÿข Modern Workplace Assistant Demo") - print("="*50) - - # Create the assistant - agent, mcp_tool = create_workplace_assistant() - - # Sample business scenarios that demonstrate both data sources - scenarios = [ - { - "type": "๐Ÿ“‹ Policy Question", - "question": "What is our remote work policy regarding security requirements?", - "note": "Should search SharePoint for company policies" - }, - { - "type": "๐Ÿ”ง Technical Question", - "question": "How do I set up Azure Active Directory conditional access?", - "note": "Should use Microsoft Learn documentation" - }, - { - "type": "๐Ÿ”„ Implementation Question", - "question": "Our security policy requires multi-factor authentication - how do I implement this in Azure AD?", - "note": "Should combine internal policy with Azure implementation guidance" - } - ] - - for i, scenario in enumerate(scenarios, 1): - print(f"\n{scenario['type']} {i}/3") - print(f"โ“ {scenario['question']}") - print(f"๐Ÿ’ก {scenario['note']}") - print("-" * 50) - - response = chat_with_assistant(agent.id, mcp_tool, scenario['question']) - - # Show response preview - preview = response[:300] + "..." if len(response) > 300 else response - print(f"๐Ÿค– {preview}") - print("-" * 50) - - print(f"\nโœ… Demo completed! The assistant successfully handled {len(scenarios)} business scenarios.") - return agent, mcp_tool - -def interactive_mode(agent, mcp_tool): - """Interactive chat mode for testing the workplace assistant""" - - print(f"\n๐Ÿ’ฌ Interactive Mode - Ask Your Workplace Questions!") - print("="*50) - print("Try questions about:") - print("โ€ข Company policies and procedures (uses SharePoint)") - print("โ€ข Azure/Microsoft 365 technical guidance (uses Microsoft Learn)") - print("โ€ข Implementation scenarios (combines both sources)") - print("Type 'quit' to exit.\n") - - while True: - question = input("โ“ Your question: ").strip() - - if question.lower() in ['quit', 'exit', 'q']: - break - elif not question: - continue - - response = chat_with_assistant(agent.id, mcp_tool, question) - print(f"\n๐Ÿค– Workplace Assistant: {response}\n") - print("-" * 60) - -def main(): - """Main function to run the workplace assistant sample""" - - print("๐Ÿš€ Azure AI Foundry - Modern Workplace Assistant") - print("Tutorial 1: Building Enterprise Agents with SharePoint + MCP Integration") - print("="*70) - - try: - # Run demonstration - agent, mcp_tool = run_sample_demo() - - # Offer interactive mode - choice = input("\n๐ŸŽฏ Try interactive mode? (y/n): ").lower() - if choice in ['y', 'yes']: - interactive_mode(agent, mcp_tool) - - print("\n๐ŸŽ‰ Sample completed successfully!") - print("๐Ÿ“š This foundation supports Tutorial 2 (Governance) and Tutorial 3 (Production)") - - except Exception as e: - print(f"\nโŒ Error: {e}") - print("\n๐Ÿ”ง Setup Help:") - print("1. Verify your .env configuration matches .env.template") - print("2. Ensure SharePoint connection is configured in Azure AI Foundry portal") - print("3. Run 'python setup_sharepoint.py' for detailed setup guidance") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/questions.jsonl b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/questions.jsonl deleted file mode 100644 index a7d843526..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/questions.jsonl +++ /dev/null @@ -1,8 +0,0 @@ -{"question": "What is our remote work policy regarding security requirements?", "expected_keywords": ["remote", "work", "security", "VPN", "authentication"]} -{"question": "How do I set up Azure Active Directory conditional access?", "expected_keywords": ["Azure", "Active Directory", "conditional access", "configure"]} -{"question": "What collaboration tools are approved for internal use?", "expected_keywords": ["Teams", "SharePoint", "collaboration", "approved"]} -{"question": "How do I implement multi-factor authentication in Azure AD?", "expected_keywords": ["multi-factor", "authentication", "Azure", "MFA", "implement"]} -{"question": "Get current weather data", "expected": "weather"} -{"question": "Summarize Q3 performance", "expected": "performance"} -{"question": "Research market trends", "expected": "research"} -{"question": "Research market trends", "expected": "research"} \ No newline at end of file diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/requirements.txt b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/requirements.txt deleted file mode 100644 index 4ba4ba6b8..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -azure-ai-projects>=1.1.0b4 -azure-ai-agents>=1.2.0b5 -azure-identity -python-dotenv \ No newline at end of file diff --git a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py b/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py deleted file mode 100644 index a5c424873..000000000 --- a/samples/microsoft/python/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env python3 -""" -SharePoint Connection Setup Guide and Diagnostic Tool -Helps configure SharePoint for the tutorial series foundation. -""" - -import os -from agent import project_client -from dotenv import load_dotenv - -load_dotenv() - -def check_sharepoint_connection_detailed(): - """Get detailed SharePoint connection information""" - - print("๐Ÿ” SharePoint Connection Analysis") - print("="*50) - - try: - connection_name = os.environ["SHAREPOINT_RESOURCE_NAME"] - conn = project_client.connections.get(name=connection_name) - - print(f"โœ… Connection Found: {conn.name}") - print(f"๐Ÿ†” ID: {conn.id}") - print(f"๐Ÿท๏ธ Type: {conn.type}") - print(f"๐Ÿ“‹ Metadata: {conn.metadata}") - print(f"๐Ÿ” Credentials: {conn.credentials}") - print(f"๐ŸŽฏ Target: {conn.target}") - print(f"๐Ÿ”ง Is Default: {conn.is_default}") - - # Analyze the issue - if conn.target == "_": - print(f"\nโŒ ISSUE IDENTIFIED: SharePoint site URL is not configured") - print(f" The 'target' field should contain your SharePoint site URL") - print(f" Current value: '{conn.target}'") - return False - else: - print(f"\nโœ… SharePoint site URL is configured: {conn.target}") - return True - - except Exception as e: - print(f"โŒ Error: {e}") - return False - -def provide_sharepoint_setup_instructions(): - """Provide step-by-step SharePoint setup instructions""" - - print(f"\n๐Ÿ› ๏ธ SHAREPOINT CONNECTION SETUP GUIDE") - print("="*50) - - print("To fix the SharePoint connection for this tutorial series:") - - print(f"\n1๏ธโƒฃ **Go to Azure AI Foundry Portal:**") - print(" - Navigate to https://ai.azure.com") - print(" - Sign in with your Azure account") - print(" - Select your AI Foundry project") - - print(f"\n2๏ธโƒฃ **Configure SharePoint Connection:**") - print(" - Go to 'Settings' > 'Connections'") - print(" - Find your 'Documentor' connection") - print(" - Click 'Edit' or 'Configure'") - - print(f"\n3๏ธโƒฃ **Set SharePoint Site URL:**") - print(" - Enter your SharePoint site URL in format:") - print(" โ€ข https://[tenant].sharepoint.com/sites/[sitename]") - print(" โ€ข Example: https://contoso.sharepoint.com/sites/documents") - print(" - OR use root site: https://[tenant].sharepoint.com") - - print(f"\n4๏ธโƒฃ **Verify Authentication:**") - print(" - Ensure the connection has proper permissions") - print(" - Test the connection in the portal") - print(" - Make sure your Azure AI service can access SharePoint") - - print(f"\n5๏ธโƒฃ **Alternative: Use Microsoft 365 Developer Tenant:**") - print(" - Get free access: https://developer.microsoft.com/microsoft-365/dev-program") - print(" - Includes SharePoint Online with sample data") - print(" - Perfect for tutorials and development") - - print(f"\n๐Ÿ’ก **For Tutorial Series Success:**") - print(" This SharePoint connection will be used across all 3 tutorials for:") - print(" โ€ข Evaluation datasets (Tutorial 2)") - print(" โ€ข Red-teaming scenarios (Tutorial 2)") - print(" โ€ข Production monitoring data (Tutorial 3)") - print(" โ€ข AI gateway integration (Tutorial 3)") - -def suggest_sharepoint_content_structure(): - """Suggest SharePoint content structure for the tutorial series""" - - print(f"\n๐Ÿ“ RECOMMENDED SHAREPOINT CONTENT STRUCTURE") - print("="*50) - print("For maximum tutorial effectiveness, organize your SharePoint with:") - - print(f"\n๐Ÿ“‚ **Document Libraries:**") - print(" โ€ข 'Shared Documents' - Main content library") - print(" โ€ข 'Policies' - Company policies and guidelines") - print(" โ€ข 'Projects' - Project documentation") - print(" โ€ข 'Training Materials' - Learning resources") - - print(f"\n๐Ÿ“„ **Sample Documents to Add:**") - print(" โ€ข Remote work policy document") - print(" โ€ข Employee handbook") - print(" โ€ข Project status reports") - print(" โ€ข Technical documentation") - print(" โ€ข Meeting notes and minutes") - - print(f"\n๐ŸŽฏ **Why This Helps the Tutorial Series:**") - print(" โ€ข Tutorial 1: Agent can find and discuss real content") - print(" โ€ข Tutorial 2: Realistic evaluation scenarios with actual data") - print(" โ€ข Tutorial 3: Production-like monitoring with meaningful content") - -def test_sharepoint_once_fixed(): - """Provide a test script for once SharePoint is fixed""" - - print(f"\n๐Ÿงช TEST SCRIPT (Run After Fixing SharePoint)") - print("="*50) - - test_script = ''' -# Save this as test_fixed_sharepoint.py and run after fixing the connection: - -from agent import create_single_agent, project_client, create_mcp_tool -from azure.ai.agents.models import SharepointTool -import time -import os - -def test_real_sharepoint(): - """Test SharePoint with real connection""" - - # Create SharePoint-only agent - sharepoint_conn = project_client.connections.get(name=os.environ["SHAREPOINT_RESOURCE_NAME"]) - sharepoint_tool = SharepointTool(connection_id=sharepoint_conn.id) - - agent = project_client.agents.create_agent( - model=os.environ["MODEL_DEPLOYMENT_NAME"], - name="sharepoint-tester", - instructions="You are a SharePoint assistant. Search and provide information from the connected SharePoint site.", - tools=sharepoint_tool.definitions - ) - - # Test questions that should work with real SharePoint - test_questions = [ - "What documents are in the Shared Documents library?", - "Are there any policy documents available?", - "What files can you find on this SharePoint site?", - "List the document libraries available" - ] - - print("Testing SharePoint connection...") - for question in test_questions: - thread = project_client.agents.threads.create() - project_client.agents.messages.create(thread_id=thread.id, role="user", content=question) - run = project_client.agents.runs.create(thread_id=thread.id, agent_id=agent.id) - - while run.status in ["queued", "in_progress", "requires_action"]: - time.sleep(1) - run = project_client.agents.runs.get(thread_id=thread.id, run_id=run.id) - - messages = list(project_client.agents.messages.list(thread_id=thread.id)) - for msg in messages: - if msg.role.value == "assistant" and msg.content: - print(f"Q: {question}") - print(f"A: {msg.content[0].text.value[:200]}...") - print("-" * 50) - break - -if __name__ == "__main__": - test_real_sharepoint() -''' - - print(test_script) - -def main(): - """Main diagnostic and setup guide""" - - print("๐Ÿš€ SharePoint Setup for Azure AI Foundry Tutorial Series") - print("This ensures your foundation supports all 3 tutorials") - - # Check current state - is_working = check_sharepoint_connection_detailed() - - if not is_working: - # Provide setup instructions - provide_sharepoint_setup_instructions() - suggest_sharepoint_content_structure() - test_sharepoint_once_fixed() - else: - print("โœ… SharePoint connection appears to be configured correctly!") - print("๐Ÿ’ก Proceed with testing the actual SharePoint functionality.") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/.env.template b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/.env.template deleted file mode 100644 index 5107649cc..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/.env.template +++ /dev/null @@ -1,10 +0,0 @@ -# Azure AI Foundry Configuration -PROJECT_ENDPOINT=https://your-project.aiservices.azure.com -MODEL_DEPLOYMENT_NAME=gpt-4o -AI_FOUNDRY_TENANT_ID=your-ai-foundry-tenant-id - -# Microsoft Learn MCP Server (Works out-of-the-box!) -MCP_SERVER_URL=https://learn.microsoft.com/api/mcp - -# SharePoint Integration (Optional - requires additional setup) -SHAREPOINT_RESOURCE_NAME=your-sharepoint-connection diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md deleted file mode 100644 index 01aa46468..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/MCP_SERVERS.md +++ /dev/null @@ -1,57 +0,0 @@ -# MCP Server Options for Azure AI Foundry Sample - -## Current Issue -The Microsoft Learn MCP server (https://learn.microsoft.com/api/mcp) requires approval, causing runs to get cancelled. - -## Recommended MCP Servers (No Approval Required) - -### 1. Weather MCP Server -``` -MCP_SERVER_URL=https://mcp-weather.vercel.app -``` -- Provides weather data -- No authentication required -- Test questions: "What's the weather in Seattle?", "Get current weather for New York" - -### 2. Public APIs MCP Server -``` -MCP_SERVER_URL=https://mcp-public-apis.herokuapp.com -``` -- Access to various public APIs -- No authentication required -- Test questions: "Get information about cats", "Find a random fact" - -### 3. Wikipedia MCP Server -``` -MCP_SERVER_URL=https://mcp-wikipedia.glitch.me -``` -- Search Wikipedia articles -- No authentication required -- Test questions: "Search Wikipedia for Azure", "Tell me about cloud computing" - -### 4. GitHub Public MCP Server -``` -MCP_SERVER_URL=https://api.githubcopilot.com/mcp/ -``` -- Access public GitHub repositories -- May require authentication -- Test questions: "Search GitHub for Azure samples" - -## Recommended for Sample -Use the **Weather MCP Server** as it's: -- โœ… Reliable and stable -- โœ… No authentication required -- โœ… No approval required -- โœ… Easy to test with weather questions -- โœ… Demonstrates external API integration - -## Update .env -``` -MCP_SERVER_URL=https://mcp-weather.vercel.app -``` - -## Test Questions -After updating: -- "What's the weather in Seattle?" -- "Get current weather for London" -- "Tell me the temperature in Tokyo" \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/README.md b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/README.md deleted file mode 100644 index 0446616b3..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/README.md +++ /dev/null @@ -1,266 +0,0 @@ -# Modern Workplace Assistant - TypeScript Sample - -This sample demonstrates building enterprise AI agents with Azure AI Foundry, combining SharePoint integration for internal company knowledge with Microsoft Learn MCP integration for external technical guidance. - -## ๐ŸŽฏ Business Scenario - -The **Modern Workplace Assistant** helps Contoso Corporation employees with: - -- **Company Policy Questions**: "What is our remote work security policy?" -- **Technical Implementation**: "How do I configure Azure AD Conditional Access?" -- **Combined Guidance**: "Our policy requires MFA - how do I implement this in Azure AD?" - -This represents realistic enterprise scenarios where employees need both internal requirements and external implementation guidance. - -## ๐Ÿ—๏ธ Architecture - -``` -โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ Modern Workplace Assistant โ”‚ -โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ ๐Ÿค– Azure AI Foundry Agent (gpt-4o) โ”‚ -โ”‚ โ”œโ”€โ”€ ๐Ÿ“ SharePoint Tool (Internal Knowledge) โ”‚ -โ”‚ โ”‚ โ””โ”€โ”€ Company policies, procedures, governance โ”‚ -โ”‚ โ””โ”€โ”€ ๐Ÿ“š Microsoft Learn MCP (External Knowledge) โ”‚ -โ”‚ โ””โ”€โ”€ Azure docs, best practices, implementation โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ -``` - -## ๐Ÿ“ Sample Structure - -``` -simple-agent-typescript/ -โ”œโ”€โ”€ ๐Ÿ“ src/ -โ”‚ โ”œโ”€โ”€ ๐Ÿ”ง main.ts # Core agent implementation (400+ lines) -โ”‚ โ””โ”€โ”€ ๐Ÿ“Š evaluate.ts # Business-focused evaluation system -โ”œโ”€โ”€ โ“ questions.jsonl # Test questions for evaluation -โ”œโ”€โ”€ ๐Ÿ“– README.md # This comprehensive guide -โ”œโ”€โ”€ โš™๏ธ .env.template # Configuration template -โ”œโ”€โ”€ ๐Ÿ”จ package.json # npm dependencies and scripts -โ”œโ”€โ”€ ๐Ÿ”ง tsconfig.json # TypeScript configuration -โ”œโ”€โ”€ ๐Ÿ“„ SAMPLE_SHAREPOINT_CONTENT.md # Business documents to upload -โ””โ”€โ”€ ๐Ÿ”ง setup_sharepoint.py # SharePoint document upload utility -``` - -## ๐Ÿš€ Quick Start - -### 1. Prerequisites - -- **Node.js 18+** with npm -- **Azure AI Foundry Project** with SharePoint connection configured -- **Microsoft Learn MCP Server** running (see MCP_SERVERS.md) -- **Azure CLI** authenticated to your tenant - -### 2. Installation - -Install dependencies: - -```bash -npm install -``` - -### 3. Configuration - -Copy the environment template and configure your settings: - -```bash -cp .env.template .env -``` - -Edit `.env` with your specific values: - -```properties -# Azure AI Foundry Configuration -PROJECT_ENDPOINT=https://your-project.cognitiveservices.azure.com/ -MODEL_DEPLOYMENT_NAME=gpt-4o -AI_FOUNDRY_TENANT_ID=your-tenant-id - -# SharePoint Integration -SHAREPOINT_RESOURCE_NAME=Benefits - -# Microsoft Learn MCP Server -MCP_SERVER_URL=https://learn.microsoft.com/api/mcp -``` - -### 4. SharePoint Document Setup - -Upload sample business documents to your SharePoint site: - -```bash -# Use the Python setup script (requires Python) -python setup_sharepoint.py - -# Or manually upload SAMPLE_SHAREPOINT_CONTENT.md files to: -# https://yourtenant.sharepoint.com/sites/benefits/Shared Documents/ -``` - -**Required Documents:** - -1. **Remote Work Security Policy** - Company MFA and security requirements -2. **IT Security Guidelines** - Technical implementation standards -3. **Employee Handbook** - General policies and procedures -4. **Compliance Requirements** - Governance and regulatory requirements - -### 5. Build and Run - -```bash -# Build TypeScript to JavaScript -npm run build - -# Run the main sample -npm start - -# Or run directly with ts-node (development) -npm run dev - -# Run evaluation system -npm run evaluate -``` - -## ๐Ÿงช Interactive Testing - -The sample includes an interactive mode for testing: - -```bash -npm run dev -# Choose 'y' when prompted for interactive mode - -# Try these example questions: -โ“ What is our company MFA policy? -โ“ How do I configure Azure Conditional Access? -โ“ Our policy requires encryption - how do I set this up? -``` - -## ๐Ÿ“Š Evaluation System - -Run comprehensive evaluation with business-focused metrics: - -```bash -npm run evaluate -``` - -**Evaluation Dimensions:** - -- **Completeness**: Does it answer the full question? -- **Accuracy**: Is the information technically correct? -- **Actionability**: Can users take concrete next steps? -- **Source Integration**: Does it combine internal/external sources? -- **Business Context**: Does it understand enterprise requirements? -- **Performance**: Response time and user experience - -## ๐Ÿ”ง Troubleshooting - -### SharePoint Connection Issues - -If you see `SharePoint connection has invalid target: '_'`: - -1. **Check Azure AI Foundry Portal**: - - Go to Management Center > Connected Resources - - Edit your SharePoint connection - - Verify the target URL matches your site - -2. **Verify Permissions**: - - Ensure your Azure identity has access to the SharePoint site - - Test SharePoint access manually in browser - -3. **Connection Name**: - - Verify `SHAREPOINT_RESOURCE_NAME` matches the connection name exactly - - Connection names are case-sensitive - -### MCP Server Issues - -If Microsoft Learn MCP connection fails: - -1. **Check Server URL**: Verify `MCP_SERVER_URL` is accessible -2. **Network Access**: Ensure your environment can reach external URLs -3. **Approval Mode**: The sample sets approval mode to "never" for demos - -### Authentication Issues - -If you see authentication errors: - -1. **Azure CLI Login**: Run `az login` and select correct tenant -2. **Tenant ID**: Verify `AI_FOUNDRY_TENANT_ID` matches your Azure AI Foundry tenant -3. **Permissions**: Ensure your identity has AI Foundry access - -### TypeScript/Node.js Issues - -1. **Node Version**: Ensure Node.js 18+ is installed -2. **Dependencies**: Run `npm install` if you see module not found errors -3. **Build Issues**: Run `npm run build` to compile TypeScript - -## ๐ŸŽ“ Educational Value - -This sample teaches enterprise AI development patterns: - -### **Multi-Source Data Integration** - -- Combining internal company knowledge (SharePoint) with external guidance (MCP) -- Dynamic agent capabilities based on available data sources -- Graceful degradation when data sources are unavailable - -### **Production-Ready Error Handling** - -- Comprehensive diagnostic information during setup -- Clear troubleshooting guidance when connections fail -- User-friendly error messages with actionable solutions - -### **Business-Focused Evaluation** - -- Evaluation metrics that matter for enterprise deployment -- Assessment of business value, not just technical accuracy -- Foundation for governance and monitoring (Tutorials 2-3) - -### **Modern TypeScript Patterns** - -- Strong typing with interfaces and type safety -- Async/await patterns throughout -- Modern ES2020+ features and syntax -- Proper module organization and exports - -## ๐Ÿ”— Tutorial Series Context - -This is **Tutorial 1** in the Azure AI Foundry enterprise development series: - -- **Tutorial 1** (This Sample): Build foundation with SharePoint + MCP integration -- **Tutorial 2**: Add governance, monitoring, and evaluation frameworks -- **Tutorial 3**: Production deployment, scaling, and operations - -## ๐Ÿ“š Key Learning Outcomes - -After completing this sample, you'll understand: - -โœ… **Enterprise AI Agent Architecture**: Multi-source data integration patterns -โœ… **SharePoint Integration**: Internal knowledge access for AI agents -โœ… **MCP Integration**: External knowledge source integration -โœ… **Business Scenario Design**: Realistic enterprise use cases -โœ… **Error Handling**: Production-ready resilience patterns -โœ… **Evaluation Frameworks**: Business-focused quality assessment -โœ… **TypeScript Development**: Modern patterns for enterprise applications - -## ๐Ÿš€ Next Steps - -1. **Customize for Your Business**: Replace sample policies with your actual documents -2. **Extend Agent Capabilities**: Add more tools and data sources -3. **Implement Governance**: Move to Tutorial 2 for monitoring and compliance -4. **Production Deployment**: Use Tutorial 3 for scaling and operations - -## ๐Ÿ” Code Highlights - -### TypeScript Specific Features: - -- **Type Safety**: Full TypeScript typing with interfaces and generics -- **Modern Async/Await**: Promise-based patterns throughout -- **ES Modules**: Proper import/export organization -- **Build Pipeline**: TypeScript to JavaScript compilation -- **Development Workflow**: ts-node for rapid development iteration - -### Main Features: - -- **400+ lines** of comprehensive enterprise AI implementation -- **Educational comments** explaining each business pattern and technical decision -- **Interactive demonstration mode** with 3 realistic business scenarios -- **Robust error handling** with clear troubleshooting guidance -- **Dynamic agent configuration** based on available data sources - -This sample provides a complete foundation for building production-ready enterprise AI agents with Azure AI Foundry using TypeScript and Node.js! ๐ŸŽ‰ \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md deleted file mode 100644 index dbc930527..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/SAMPLE_SHAREPOINT_CONTENT.md +++ /dev/null @@ -1,176 +0,0 @@ -# Sample SharePoint Content for Tutorial Series - -To create a coherent business scenario, upload these sample documents to your SharePoint site: - -## Document Structure - -### ๐Ÿ“ Shared Documents/Policies/ -1. **remote-work-policy.docx** -2. **security-guidelines.docx** -3. **collaboration-standards.docx** -4. **data-governance-policy.docx** - -### ๐Ÿ“ Shared Documents/Procedures/ -1. **employee-onboarding.docx** -2. **project-workflow.docx** -3. **incident-response.docx** - ---- - -## Sample Document Content - -### 1. Remote Work Policy (remote-work-policy.docx) - -``` -CONTOSO CORP - REMOTE WORK POLICY - -Effective Date: January 2024 - -OVERVIEW -Contoso Corp supports flexible work arrangements including remote work to enhance employee productivity and work-life balance. - -ELIGIBILITY -- Full-time employees after 90-day probationary period -- Manager approval required -- Role must be suitable for remote work - -TECHNOLOGY REQUIREMENTS -- Secure VPN connection required -- Use of Microsoft 365 and Azure services mandatory -- Multi-factor authentication enabled -- Personal devices must meet security standards - -SECURITY PROTOCOLS -- All data must be stored in approved cloud services (SharePoint, OneDrive) -- No sensitive data on personal devices -- Regular security training completion required -- Incident reporting within 2 hours - -COLLABORATION TOOLS -- Microsoft Teams for meetings and communication -- SharePoint for document collaboration -- Azure DevOps for development projects -- Outlook for email and calendar management - -REVIEW -This policy is reviewed annually and updated as needed. -``` - -### 2. Security Guidelines (security-guidelines.docx) - -``` -CONTOSO CORP - INFORMATION SECURITY GUIDELINES - -OVERVIEW -These guidelines ensure the protection of Contoso's information assets and compliance with industry standards. - -AZURE SECURITY REQUIREMENTS -- All cloud resources must use Azure Active Directory -- Enable Azure Security Center monitoring -- Implement Azure Key Vault for secrets management -- Use Azure Policy for compliance enforcement - -ACCESS MANAGEMENT -- Role-based access control (RBAC) mandatory -- Privileged Identity Management (PIM) for admin roles -- Regular access reviews quarterly -- Conditional access policies enforced - -DATA PROTECTION -- Data classification using Microsoft Purview -- Encryption at rest and in transit -- Regular backup verification -- Data retention policies enforced - -INCIDENT RESPONSE -- Use Azure Sentinel for threat detection -- Report security incidents immediately -- Follow established escalation procedures -- Document all security events -``` - -### 3. Collaboration Standards (collaboration-standards.docx) - -``` -CONTOSO CORP - COLLABORATION STANDARDS - -DOCUMENT MANAGEMENT -- All business documents stored in SharePoint Online -- Version control enabled for all document libraries -- Metadata required: Department, Project, Classification -- Folder structure: /Department/Project/Year/ - -COMMUNICATION GUIDELINES -- Microsoft Teams for internal communication -- Email for external communication only -- Weekly team meetings via Teams -- Project updates in SharePoint lists - -DEVELOPMENT STANDARDS -- Source code in Azure DevOps repositories -- CI/CD pipelines for all applications -- Code reviews required for all changes -- Azure Monitor for application monitoring - -TRAINING REQUIREMENTS -- Microsoft 365 certification within 6 months -- Azure fundamentals for technical staff -- Security awareness training quarterly -- Collaboration tools training for new hires -``` - -### 4. Data Governance Policy (data-governance-policy.docx) - -``` -CONTOSO CORP - DATA GOVERNANCE POLICY - -DATA CLASSIFICATION -- Public: Marketing materials, published content -- Internal: Business documents, policies, procedures -- Confidential: Financial data, employee records -- Restricted: Legal documents, intellectual property - -STORAGE REQUIREMENTS -- Public: SharePoint sites, public websites -- Internal: SharePoint document libraries with access controls -- Confidential: Restricted SharePoint sites with encryption -- Restricted: Azure Key Vault, encrypted storage accounts - -MICROSOFT 365 COMPLIANCE -- Data Loss Prevention (DLP) policies enabled -- Sensitivity labels applied to all documents -- Retention policies configured by data type -- eDiscovery capabilities for legal requirements - -AZURE DATA SERVICES -- Azure SQL Database for structured data -- Azure Data Lake for analytics workloads -- Azure Synapse for data warehousing -- Power BI for business intelligence -``` - ---- - -## Business Scenario Test Questions - -These questions demonstrate the coherent business use case: - -### Internal Policy Questions (SharePoint) -- "What is our remote work policy regarding VPN requirements?" -- "What are the security protocols for remote employees?" -- "How should we classify confidential business documents?" -- "What collaboration tools are approved for internal use?" - -### Technical Implementation Questions (MCP - Microsoft Learn) -- "How do I set up Azure Active Directory for our remote workers?" -- "What are the steps to configure Azure Security Center monitoring?" -- "How do I implement data loss prevention in Microsoft 365?" -- "How do I set up conditional access policies in Azure AD?" - -### Hybrid Questions (Both Sources) -- "Our remote work policy requires secure VPN - how do I implement Azure VPN Gateway?" -- "What Azure services do I need to meet our data governance requirements?" -- "How do I configure Microsoft Teams to comply with our collaboration standards?" -- "What Azure security services align with our incident response procedures?" - -This creates a **realistic business scenario** where the AI assistant helps employees understand company policies AND implement them using Microsoft technologies. \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/package.json b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/package.json deleted file mode 100644 index a948ded4a..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "modern-workplace-assistant-typescript", - "version": "1.0.0", - "description": "Azure AI Foundry Agent Sample - Tutorial 1: SharePoint + MCP Integration", - "main": "dist/main.js", - "scripts": { - "build": "tsc", - "start": "node dist/main.js", - "dev": "ts-node src/main.ts", - "evaluate": "ts-node src/evaluate.ts", - "clean": "rimraf dist", - "test": "jest", - "lint": "eslint src/**/*.ts", - "format": "prettier --write src/**/*.ts" - }, - "dependencies": { - "@azure/ai-agents": "1.2.0-beta.5", - "@azure/ai-projects": "1.1.0-beta.4", - "@azure/identity": "^4.0.1", - "dotenv": "^16.3.1" - }, - "devDependencies": { - "@types/node": "^20.8.0", - "@typescript-eslint/eslint-plugin": "^6.7.0", - "@typescript-eslint/parser": "^6.7.0", - "eslint": "^8.50.0", - "jest": "^29.7.0", - "@types/jest": "^29.5.5", - "prettier": "^3.0.3", - "rimraf": "^5.0.5", - "ts-jest": "^29.1.1", - "ts-node": "^10.9.1", - "typescript": "^5.2.2" - }, - "keywords": [ - "azure", - "ai-foundry", - "agents", - "sharepoint", - "mcp", - "enterprise", - "workplace-assistant" - ], - "author": "Microsoft", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } -} \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/questions.jsonl b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/questions.jsonl deleted file mode 100644 index a7d843526..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/questions.jsonl +++ /dev/null @@ -1,8 +0,0 @@ -{"question": "What is our remote work policy regarding security requirements?", "expected_keywords": ["remote", "work", "security", "VPN", "authentication"]} -{"question": "How do I set up Azure Active Directory conditional access?", "expected_keywords": ["Azure", "Active Directory", "conditional access", "configure"]} -{"question": "What collaboration tools are approved for internal use?", "expected_keywords": ["Teams", "SharePoint", "collaboration", "approved"]} -{"question": "How do I implement multi-factor authentication in Azure AD?", "expected_keywords": ["multi-factor", "authentication", "Azure", "MFA", "implement"]} -{"question": "Get current weather data", "expected": "weather"} -{"question": "Summarize Q3 performance", "expected": "performance"} -{"question": "Research market trends", "expected": "research"} -{"question": "Research market trends", "expected": "research"} \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py deleted file mode 100644 index a5c424873..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/setup_sharepoint.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env python3 -""" -SharePoint Connection Setup Guide and Diagnostic Tool -Helps configure SharePoint for the tutorial series foundation. -""" - -import os -from agent import project_client -from dotenv import load_dotenv - -load_dotenv() - -def check_sharepoint_connection_detailed(): - """Get detailed SharePoint connection information""" - - print("๐Ÿ” SharePoint Connection Analysis") - print("="*50) - - try: - connection_name = os.environ["SHAREPOINT_RESOURCE_NAME"] - conn = project_client.connections.get(name=connection_name) - - print(f"โœ… Connection Found: {conn.name}") - print(f"๐Ÿ†” ID: {conn.id}") - print(f"๐Ÿท๏ธ Type: {conn.type}") - print(f"๐Ÿ“‹ Metadata: {conn.metadata}") - print(f"๐Ÿ” Credentials: {conn.credentials}") - print(f"๐ŸŽฏ Target: {conn.target}") - print(f"๐Ÿ”ง Is Default: {conn.is_default}") - - # Analyze the issue - if conn.target == "_": - print(f"\nโŒ ISSUE IDENTIFIED: SharePoint site URL is not configured") - print(f" The 'target' field should contain your SharePoint site URL") - print(f" Current value: '{conn.target}'") - return False - else: - print(f"\nโœ… SharePoint site URL is configured: {conn.target}") - return True - - except Exception as e: - print(f"โŒ Error: {e}") - return False - -def provide_sharepoint_setup_instructions(): - """Provide step-by-step SharePoint setup instructions""" - - print(f"\n๐Ÿ› ๏ธ SHAREPOINT CONNECTION SETUP GUIDE") - print("="*50) - - print("To fix the SharePoint connection for this tutorial series:") - - print(f"\n1๏ธโƒฃ **Go to Azure AI Foundry Portal:**") - print(" - Navigate to https://ai.azure.com") - print(" - Sign in with your Azure account") - print(" - Select your AI Foundry project") - - print(f"\n2๏ธโƒฃ **Configure SharePoint Connection:**") - print(" - Go to 'Settings' > 'Connections'") - print(" - Find your 'Documentor' connection") - print(" - Click 'Edit' or 'Configure'") - - print(f"\n3๏ธโƒฃ **Set SharePoint Site URL:**") - print(" - Enter your SharePoint site URL in format:") - print(" โ€ข https://[tenant].sharepoint.com/sites/[sitename]") - print(" โ€ข Example: https://contoso.sharepoint.com/sites/documents") - print(" - OR use root site: https://[tenant].sharepoint.com") - - print(f"\n4๏ธโƒฃ **Verify Authentication:**") - print(" - Ensure the connection has proper permissions") - print(" - Test the connection in the portal") - print(" - Make sure your Azure AI service can access SharePoint") - - print(f"\n5๏ธโƒฃ **Alternative: Use Microsoft 365 Developer Tenant:**") - print(" - Get free access: https://developer.microsoft.com/microsoft-365/dev-program") - print(" - Includes SharePoint Online with sample data") - print(" - Perfect for tutorials and development") - - print(f"\n๐Ÿ’ก **For Tutorial Series Success:**") - print(" This SharePoint connection will be used across all 3 tutorials for:") - print(" โ€ข Evaluation datasets (Tutorial 2)") - print(" โ€ข Red-teaming scenarios (Tutorial 2)") - print(" โ€ข Production monitoring data (Tutorial 3)") - print(" โ€ข AI gateway integration (Tutorial 3)") - -def suggest_sharepoint_content_structure(): - """Suggest SharePoint content structure for the tutorial series""" - - print(f"\n๐Ÿ“ RECOMMENDED SHAREPOINT CONTENT STRUCTURE") - print("="*50) - print("For maximum tutorial effectiveness, organize your SharePoint with:") - - print(f"\n๐Ÿ“‚ **Document Libraries:**") - print(" โ€ข 'Shared Documents' - Main content library") - print(" โ€ข 'Policies' - Company policies and guidelines") - print(" โ€ข 'Projects' - Project documentation") - print(" โ€ข 'Training Materials' - Learning resources") - - print(f"\n๐Ÿ“„ **Sample Documents to Add:**") - print(" โ€ข Remote work policy document") - print(" โ€ข Employee handbook") - print(" โ€ข Project status reports") - print(" โ€ข Technical documentation") - print(" โ€ข Meeting notes and minutes") - - print(f"\n๐ŸŽฏ **Why This Helps the Tutorial Series:**") - print(" โ€ข Tutorial 1: Agent can find and discuss real content") - print(" โ€ข Tutorial 2: Realistic evaluation scenarios with actual data") - print(" โ€ข Tutorial 3: Production-like monitoring with meaningful content") - -def test_sharepoint_once_fixed(): - """Provide a test script for once SharePoint is fixed""" - - print(f"\n๐Ÿงช TEST SCRIPT (Run After Fixing SharePoint)") - print("="*50) - - test_script = ''' -# Save this as test_fixed_sharepoint.py and run after fixing the connection: - -from agent import create_single_agent, project_client, create_mcp_tool -from azure.ai.agents.models import SharepointTool -import time -import os - -def test_real_sharepoint(): - """Test SharePoint with real connection""" - - # Create SharePoint-only agent - sharepoint_conn = project_client.connections.get(name=os.environ["SHAREPOINT_RESOURCE_NAME"]) - sharepoint_tool = SharepointTool(connection_id=sharepoint_conn.id) - - agent = project_client.agents.create_agent( - model=os.environ["MODEL_DEPLOYMENT_NAME"], - name="sharepoint-tester", - instructions="You are a SharePoint assistant. Search and provide information from the connected SharePoint site.", - tools=sharepoint_tool.definitions - ) - - # Test questions that should work with real SharePoint - test_questions = [ - "What documents are in the Shared Documents library?", - "Are there any policy documents available?", - "What files can you find on this SharePoint site?", - "List the document libraries available" - ] - - print("Testing SharePoint connection...") - for question in test_questions: - thread = project_client.agents.threads.create() - project_client.agents.messages.create(thread_id=thread.id, role="user", content=question) - run = project_client.agents.runs.create(thread_id=thread.id, agent_id=agent.id) - - while run.status in ["queued", "in_progress", "requires_action"]: - time.sleep(1) - run = project_client.agents.runs.get(thread_id=thread.id, run_id=run.id) - - messages = list(project_client.agents.messages.list(thread_id=thread.id)) - for msg in messages: - if msg.role.value == "assistant" and msg.content: - print(f"Q: {question}") - print(f"A: {msg.content[0].text.value[:200]}...") - print("-" * 50) - break - -if __name__ == "__main__": - test_real_sharepoint() -''' - - print(test_script) - -def main(): - """Main diagnostic and setup guide""" - - print("๐Ÿš€ SharePoint Setup for Azure AI Foundry Tutorial Series") - print("This ensures your foundation supports all 3 tutorials") - - # Check current state - is_working = check_sharepoint_connection_detailed() - - if not is_working: - # Provide setup instructions - provide_sharepoint_setup_instructions() - suggest_sharepoint_content_structure() - test_sharepoint_once_fixed() - else: - print("โœ… SharePoint connection appears to be configured correctly!") - print("๐Ÿ’ก Proceed with testing the actual SharePoint functionality.") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/src/evaluate.ts b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/src/evaluate.ts deleted file mode 100644 index 1dde30f27..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/src/evaluate.ts +++ /dev/null @@ -1,312 +0,0 @@ -/** - * Azure AI Foundry Agent Evaluation - Tutorial 1: Modern Workplace Assistant - * - * This evaluation system demonstrates enterprise AI quality assurance patterns: - * - Business-focused evaluation scenarios - * - Multi-source knowledge validation (SharePoint + MCP) - * - Response quality assessment - * - Source attribution verification - * - Performance and reliability measurement - * - * Educational Focus: - * - Shows how to evaluate enterprise AI systems - * - Demonstrates quality metrics for business scenarios - * - Provides foundation for governance and monitoring - */ - -import { AIProjectClient } from '@azure/ai-projects'; -import { DefaultAzureCredential } from '@azure/identity'; -import { Agent, SharepointTool, McpTool } from '@azure/ai-agents'; -import * as fs from 'fs'; -import * as path from 'path'; -import * as dotenv from 'dotenv'; - -// Load environment variables -dotenv.config(); - -interface TestQuestion { - question: string; - expected_source: string; - category: string; -} - -interface EvaluationResult { - question: string; - answer: string; - status: string; - sources: string[]; - timestamp: Date; - responseTimeMs: number; - expectedSource: string; - sourceMatch: boolean; -} - -interface AgentConfiguration { - agent: Agent; - mcpTool: McpTool; - sharepointTool: SharepointTool | null; -} - -class AgentEvaluator { - private projectClient: AIProjectClient; - - constructor() { - // Setup authentication - const credential = new DefaultAzureCredential(); - this.projectClient = new AIProjectClient( - process.env.PROJECT_ENDPOINT!, - credential - ); - } - - //#region evaluation_functions - async runEvaluation(): Promise { - console.log('๐Ÿงช Starting Modern Workplace Assistant Evaluation'); - console.log('=================================================='); - - // Load test questions - const questions = await this.loadTestQuestions(); - console.log(`๐Ÿ“ Loaded ${questions.length} test questions`); - - // Create agent for evaluation - console.log('๐Ÿค– Creating evaluation agent...'); - const agentConfig = await this.createWorkplaceAssistant(); - - const results: EvaluationResult[] = []; - - // Run evaluation for each question - for (let i = 0; i < questions.length; i++) { - const question = questions[i]; - console.log(`\n[${i + 1}/${questions.length}] Testing: ${question.category}`); - console.log(`โ“ Question: ${question.question}`); - - const result = await this.evaluateQuestion(agentConfig.agent, question); - results.push(result); - - // Display result - console.log(`โœ… Status: ${result.status}`); - console.log(`โฑ๏ธ Response time: ${result.responseTimeMs.toFixed(0)}ms`); - console.log(`๐Ÿ“š Sources found: ${result.sources.length}`); - console.log(`๐ŸŽฏ Expected source match: ${result.sourceMatch ? 'โœ…' : 'โš ๏ธ'}`); - - if (result.sources.length > 0) { - console.log(' Sources:'); - result.sources.slice(0, 3).forEach(source => { - console.log(` - ${source}`); - }); - } - } - - // Display summary - this.displayEvaluationSummary(results); - - // Cleanup - await this.cleanupAgent(agentConfig.agent); - - return results; - } - - private async loadTestQuestions(): Promise { - const questionsFile = 'questions.jsonl'; - if (!fs.existsSync(questionsFile)) { - throw new Error(`Test questions file not found: ${questionsFile}`); - } - - const questions: TestQuestion[] = []; - const content = fs.readFileSync(questionsFile, 'utf-8'); - const lines = content.split('\n').filter(line => line.trim()); - - for (const line of lines) { - try { - const question = JSON.parse(line) as TestQuestion; - questions.push(question); - } catch (error) { - console.log(`โš ๏ธ Failed to parse question: ${line} - ${error}`); - } - } - - return questions; - } - - private async createWorkplaceAssistant(): Promise { - // Create agent using the same logic as the main program - const sharePointResourceName = process.env.SHAREPOINT_RESOURCE_NAME!; - let sharePointTool: SharepointTool | null = null; - - try { - const sharePointConn = await this.projectClient.connections.get(sharePointResourceName); - sharePointTool = new SharepointTool(sharePointConn.id); - console.log('โœ… SharePoint tool configured'); - } catch (error) { - console.log(`โš ๏ธ SharePoint connection failed: ${error}`); - } - - const mcpTool = new McpTool({ - serverLabel: 'microsoft_learn', - serverUrl: process.env.MCP_SERVER_URL!, - allowedTools: [] - }); - - const instructions = sharePointTool - ? 'You are a Modern Workplace Assistant. Use SharePoint for company policies and Microsoft Learn for technical guidance. Always cite your sources.' - : 'You are a Technical Assistant with Microsoft Learn access. Provide technical guidance and cite sources.'; - - const tools = []; - if (sharePointTool) { - tools.push(...sharePointTool.definitions); - } - tools.push(...mcpTool.definitions); - - const agent = await this.projectClient.agents.createAgent({ - model: process.env.MODEL_DEPLOYMENT_NAME!, - name: 'Evaluation Agent', - instructions, - tools - }); - - return { agent, mcpTool, sharepointTool: sharePointTool }; - } - - private async evaluateQuestion(agent: Agent, question: TestQuestion): Promise { - const startTime = Date.now(); - const result: EvaluationResult = { - question: question.question, - answer: '', - status: '', - sources: [], - timestamp: new Date(), - responseTimeMs: 0, - expectedSource: question.expected_source, - sourceMatch: false - }; - - try { - // Create thread and run conversation - const thread = await this.projectClient.agents.createThread(); - - await this.projectClient.agents.createMessage(thread.id, { - role: 'user', - content: question.question - }); - - let run = await this.projectClient.agents.createRun(thread.id, { - assistantId: agent.id - }); - - // Wait for completion - while (run.status === 'in_progress' || run.status === 'queued') { - await new Promise(resolve => setTimeout(resolve, 1000)); - run = await this.projectClient.agents.getRun(thread.id, run.id); - } - - const endTime = Date.now(); - result.responseTimeMs = endTime - startTime; - - if (run.status === 'completed') { - const messages = await this.projectClient.agents.getMessages(thread.id); - const assistantMessage = messages.data - .filter(m => m.role === 'assistant') - .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())[0]; - - if (assistantMessage && assistantMessage.content[0]?.text) { - result.answer = assistantMessage.content[0].text.value; - result.status = 'Completed'; - - // Extract sources from response - result.sources = this.extractSourcesFromResponse(result.answer); - result.sourceMatch = this.checkSourceMatch(result.sources, question.expected_source); - } else { - result.status = 'No response'; - } - } else { - result.status = `Failed: ${run.status}`; - } - - // Cleanup thread - await this.projectClient.agents.deleteThread(thread.id); - } catch (error) { - result.status = `Error: ${error}`; - } - - return result; - } - - private extractSourcesFromResponse(response: string): string[] { - const sources: string[] = []; - - // Look for common source indicators - const sourceIndicators = ['SharePoint', 'Microsoft Learn', 'learn.microsoft.com', 'documentation']; - - for (const indicator of sourceIndicators) { - if (response.toLowerCase().includes(indicator.toLowerCase())) { - sources.push(indicator); - } - } - - return Array.from(new Set(sources)); - } - - private checkSourceMatch(foundSources: string[], expectedSource: string): boolean { - if (!expectedSource) return true; - - return foundSources.some(source => - source.toLowerCase().includes(expectedSource.toLowerCase()) || - expectedSource.toLowerCase().includes(source.toLowerCase()) - ); - } - - private displayEvaluationSummary(results: EvaluationResult[]): void { - console.log('\n๐Ÿ“Š EVALUATION SUMMARY'); - console.log('====================='); - - const successful = results.filter(r => r.status === 'Completed').length; - const avgResponseTime = results - .filter(r => r.status === 'Completed') - .reduce((sum, r) => sum + r.responseTimeMs, 0) / successful || 0; - const sourceMatches = results.filter(r => r.sourceMatch).length; - - console.log(`โœ… Successful responses: ${successful}/${results.length} (${(100.0 * successful / results.length).toFixed(1)}%)`); - console.log(`โฑ๏ธ Average response time: ${avgResponseTime.toFixed(0)}ms`); - console.log(`๐ŸŽฏ Source attribution accuracy: ${sourceMatches}/${results.length} (${(100.0 * sourceMatches / results.length).toFixed(1)}%)`); - - // Show failed cases - const failed = results.filter(r => r.status !== 'Completed'); - if (failed.length > 0) { - console.log('\nโš ๏ธ Failed Cases:'); - failed.forEach(fail => { - console.log(` - ${fail.question}: ${fail.status}`); - }); - } - } - //#endregion evaluation_functions - - private async cleanupAgent(agent: Agent): Promise { - try { - await this.projectClient.agents.deleteAgent(agent.id); - console.log('๐Ÿงน Cleanup completed'); - } catch (error) { - console.log(`โš ๏ธ Cleanup warning: ${error}`); - } - } -} - -// Entry point for evaluation -async function main(): Promise { - console.log('Azure AI Foundry - Modern Workplace Assistant Evaluation'); - console.log('========================================================'); - - try { - const evaluator = new AgentEvaluator(); - const results = await evaluator.runEvaluation(); - - console.log(`\n๐ŸŽ‰ Evaluation completed with ${results.length} test cases`); - } catch (error) { - console.log(`โŒ Evaluation failed: ${error}`); - process.exit(1); - } -} - -// Run if this file is executed directly -if (require.main === module) { - main().catch(console.error); -} \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/src/main.ts b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/src/main.ts deleted file mode 100644 index 3be482165..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/src/main.ts +++ /dev/null @@ -1,472 +0,0 @@ -/** - * Azure AI Foundry Agent Sample - Tutorial 1: Modern Workplace Assistant - * - * This sample demonstrates a complete business scenario combining: - * - SharePoint integration for internal company knowledge - * - Microsoft Learn MCP integration for external technical guidance - * - Intelligent orchestration of multiple data sources - * - Robust error handling and graceful degradation - * - * Educational Focus: - * - Enterprise AI patterns with multiple data sources - * - Real-world business scenarios that enterprises face daily - * - Production-ready error handling and diagnostics - * - Foundation for governance, evaluation, and monitoring (Tutorials 2-3) - * - * Business Scenario: - * An employee needs to implement Azure AD multi-factor authentication. They need: - * 1. Company security policy requirements (from SharePoint) - * 2. Technical implementation steps (from Microsoft Learn) - * 3. Combined guidance showing how policy requirements map to technical implementation - */ - -//#region imports_and_setup -import { AIProjectClient } from '@azure/ai-projects'; -import { DefaultAzureCredential, AzureCliCredential } from '@azure/identity'; -import { Agent, SharepointTool, McpTool, ToolDefinition } from '@azure/ai-agents'; -import * as dotenv from 'dotenv'; -import * as readline from 'readline'; - -// Load environment configuration -dotenv.config(); - -// ============================================================================ -// AUTHENTICATION SETUP -// ============================================================================ -// Support both default Azure credentials and specific tenant authentication -const aiFundryTenantId = process.env.AI_FOUNDRY_TENANT_ID; -let credential: DefaultAzureCredential | AzureCliCredential; - -if (aiFundryTenantId) { - console.log(`๐Ÿ” Using AI Foundry tenant: ${aiFundryTenantId}`); - credential = new AzureCliCredential(); -} else { - credential = new DefaultAzureCredential(); -} - -const projectClient = new AIProjectClient( - process.env.PROJECT_ENDPOINT!, - credential -); -//#endregion imports_and_setup - -// ============================================================================ -// INTERFACES AND TYPES -// ============================================================================ - -interface AgentConfiguration { - agent: Agent; - mcpTool: McpTool; - sharepointTool: SharepointTool | null; -} - -interface BusinessScenario { - title: string; - question: string; - context: string; - expectedSource: string; - learningPoint: string; -} - -interface ChatResult { - content: string; - status: string; -} - -/** - * Create a Modern Workplace Assistant combining internal and external knowledge. - * - * This demonstrates enterprise AI patterns: - * 1. Multi-source data integration (SharePoint + MCP) - * 2. Robust error handling with graceful degradation - * 3. Dynamic agent capabilities based on available resources - * 4. Clear diagnostic information for troubleshooting - * - * Educational Value: - * - Shows real-world complexity of enterprise AI systems - * - Demonstrates how to handle partial system failures - * - Provides patterns for combining internal and external data - * - * @returns AgentConfiguration for further interaction and testing - */ -async function createWorkplaceAssistant(): Promise { - console.log('๐Ÿค– Creating Modern Workplace Assistant...'); - - // ======================================================================== - // SHAREPOINT INTEGRATION SETUP - // ======================================================================== - // SharePoint provides access to internal company knowledge: - // - Company policies and procedures - // - Security guidelines and requirements - // - Governance and compliance documentation - // - Internal process documentation - - const sharepointResourceName = process.env.SHAREPOINT_RESOURCE_NAME!; - - console.log('๐Ÿ“ Configuring SharePoint integration...'); - console.log(` Connection: ${sharepointResourceName}`); - - let sharepointTool: SharepointTool | null = null; - try { - // Attempt to retrieve pre-configured SharePoint connection - const sharepointConnection = await projectClient.connections.get(sharepointResourceName); - sharepointTool = new SharepointTool({ connectionId: sharepointConnection.id }); - console.log('โœ… SharePoint successfully connected'); - - } catch (error) { - // Graceful degradation - system continues without SharePoint - console.log(`โš ๏ธ SharePoint connection failed: ${error}`); - console.log(' Agent will operate in technical guidance mode only'); - console.log(' ๐Ÿ“ To enable full functionality:'); - console.log(' Create SharePoint connection in Azure AI Foundry portal'); - console.log(` Connection name: ${sharepointResourceName}`); - sharepointTool = null; - } - - // ======================================================================== - // MICROSOFT LEARN MCP INTEGRATION SETUP - // ======================================================================== - // Microsoft Learn MCP provides access to current technical documentation: - // - Azure service configuration guides - // - Best practices and implementation patterns - // - Troubleshooting and diagnostic information - // - Latest feature updates and capabilities - - console.log('๐Ÿ“š Configuring Microsoft Learn MCP integration...'); - const mcpTool = new McpTool({ - serverLabel: 'microsoft_learn', - serverUrl: process.env.MCP_SERVER_URL!, - allowedTools: [] // Allow all available tools - }); - - // Disable approval workflow for seamless demonstration - mcpTool.setApprovalMode('never'); - console.log(`โœ… Microsoft Learn MCP connected: ${process.env.MCP_SERVER_URL}`); - - // ======================================================================== - // AGENT CREATION WITH DYNAMIC CAPABILITIES - // ======================================================================== - // Create agent instructions based on available data sources - // This demonstrates adaptive system design - - let instructions: string; - if (sharepointTool) { - instructions = `You are a Modern Workplace Assistant for Contoso Corporation. - -CAPABILITIES: -- Search SharePoint for company policies, procedures, and internal documentation -- Access Microsoft Learn for current Azure and Microsoft 365 technical guidance -- Provide comprehensive solutions combining internal requirements with external implementation - -RESPONSE STRATEGY: -- For policy questions: Search SharePoint for company-specific requirements and guidelines -- For technical questions: Use Microsoft Learn for current Azure/M365 documentation and best practices -- For implementation questions: Combine both sources to show how company policies map to technical implementation -- Always cite your sources and provide step-by-step guidance -- Explain how internal requirements connect to external implementation steps - -EXAMPLE SCENARIOS: -- "What is our MFA policy?" โ†’ Search SharePoint for security policies -- "How do I configure Azure AD Conditional Access?" โ†’ Use Microsoft Learn for technical steps -- "Our policy requires MFA - how do I implement this?" โ†’ Combine policy requirements with implementation guidance`; - } else { - instructions = `You are a Technical Assistant with access to Microsoft Learn documentation. - -CAPABILITIES: -- Access Microsoft Learn for current Azure and Microsoft 365 technical guidance -- Provide detailed implementation steps and best practices -- Explain Azure services, features, and configuration options - -LIMITATIONS: -- SharePoint integration is not available -- Cannot access company-specific policies or internal documentation -- When asked about company policies, explain that internal document access requires SharePoint configuration - -RESPONSE STRATEGY: -- Provide comprehensive technical guidance from Microsoft Learn -- Include step-by-step implementation instructions -- Reference official documentation and best practices -- Suggest how technical implementations typically align with enterprise requirements`; - } - - // Create the agent with appropriate tool configuration - console.log('๐Ÿ› ๏ธ Configuring agent tools...'); - const availableTools: ToolDefinition[] = []; - if (sharepointTool) { - availableTools.push(...sharepointTool.definitions); - } - availableTools.push(...mcpTool.definitions); - console.log(` Available tools: ${availableTools.length}`); - - const agent = await projectClient.agents.create({ - model: process.env.MODEL_DEPLOYMENT_NAME!, - name: 'Modern Workplace Assistant', - instructions: instructions, - tools: availableTools - }); - - console.log(`โœ… Agent created successfully: ${agent.id}`); - return { agent, mcpTool, sharepointTool }; -} - -/** - * Demonstrate realistic business scenarios combining internal and external knowledge. - * - * This function showcases the practical value of the Modern Workplace Assistant - * by walking through scenarios that enterprise employees face regularly. - * - * Educational Value: - * - Shows real business problems that AI agents can solve - * - Demonstrates integration between internal policies and external guidance - * - Illustrates how AI can bridge the gap between requirements and implementation - */ -async function demonstrateBusinessScenarios(config: AgentConfiguration): Promise { - const scenarios: BusinessScenario[] = [ - { - title: '๐Ÿ“‹ Company Policy Question', - question: 'What is our remote work security policy regarding multi-factor authentication?', - context: 'Employee needs to understand company MFA requirements', - expectedSource: 'SharePoint', - learningPoint: 'Internal policy retrieval and interpretation' - }, - { - title: '๐Ÿ”ง Technical Implementation Question', - question: 'How do I set up Azure Active Directory conditional access policies?', - context: 'IT administrator needs technical implementation steps', - expectedSource: 'Microsoft Learn MCP', - learningPoint: 'External technical documentation access' - }, - { - title: '๐Ÿ”„ Combined Business Implementation Question', - question: 'Our company security policy requires multi-factor authentication for remote workers. How do I implement this requirement using Azure AD?', - context: 'Need to combine policy requirements with technical implementation', - expectedSource: 'Both SharePoint and MCP', - learningPoint: 'Multi-source intelligence combining internal requirements with external implementation' - } - ]; - - console.log('\n' + '='.repeat(70)); - console.log('๐Ÿข MODERN WORKPLACE ASSISTANT - BUSINESS SCENARIO DEMONSTRATION'); - console.log('='.repeat(70)); - console.log('This demonstration shows how AI agents solve real business problems'); - console.log('by combining internal company knowledge with external technical guidance.'); - console.log('='.repeat(70)); - - for (let i = 0; i < scenarios.length; i++) { - const scenario = scenarios[i]; - console.log(`\n๐Ÿ“Š SCENARIO ${i + 1}/3: ${scenario.title}`); - console.log('-'.repeat(50)); - console.log(`โ“ QUESTION: ${scenario.question}`); - console.log(`๐ŸŽฏ BUSINESS CONTEXT: ${scenario.context}`); - console.log(`๐Ÿ“š EXPECTED SOURCE: ${scenario.expectedSource}`); - console.log(`๐ŸŽ“ LEARNING POINT: ${scenario.learningPoint}`); - console.log('-'.repeat(50)); - - // Get response from the agent - console.log('๐Ÿค– ASSISTANT RESPONSE:'); - const response = await chatWithAssistant(config.agent.id, config.mcpTool, scenario.question); - - // Display response with analysis - if (response.status === 'completed' && response.content && response.content.trim().length > 10) { - const preview = response.content.length > 300 ? response.content.substring(0, 300) + '...' : response.content; - console.log(`โœ… SUCCESS: ${preview}`); - if (response.content.length > 300) { - console.log(` ๐Ÿ“ Full response: ${response.content.length} characters`); - } - } else { - console.log(`โš ๏ธ LIMITED RESPONSE: ${response.content}`); - if (!config.sharepointTool && scenario.expectedSource.includes('SharePoint')) { - console.log(' ๐Ÿ’ก This demonstrates graceful degradation when SharePoint is unavailable'); - } - } - - console.log(`๐Ÿ“ˆ STATUS: ${response.status}`); - console.log('-'.repeat(50)); - } - - console.log('\nโœ… DEMONSTRATION COMPLETED!'); - console.log('๐ŸŽ“ Key Learning Outcomes:'); - console.log(' โ€ข Multi-source data integration in enterprise AI'); - console.log(' โ€ข Robust error handling and graceful degradation'); - console.log(' โ€ข Real business value through combined intelligence'); - console.log(' โ€ข Foundation for governance and monitoring (Tutorials 2-3)'); -} - -/** - * Execute a conversation with the workplace assistant. - * - * This function demonstrates the conversation pattern for Azure AI Foundry agents - * and includes comprehensive error handling for production readiness. - * - * Educational Value: - * - Shows proper thread management and conversation flow - * - Demonstrates streaming response handling - * - Includes timeout and error management patterns - */ -async function chatWithAssistant(agentId: string, mcpTool: McpTool, message: string): Promise { - try { - // Create conversation thread (maintains conversation context) - const thread = await projectClient.agents.threads.create(); - - // Add user message to thread - await projectClient.agents.messages.create(thread.id, { - role: 'user', - content: message - }); - - // Execute the conversation with streaming response - const runStream = await projectClient.agents.runs.createAndStream( - thread.id, - { assistantId: agentId } - ); - - // Collect streaming response - const responseParts: string[] = []; - let finalStatus = 'unknown'; - - for await (const event of runStream) { - if (event.eventType === 'MessageDelta') { - const delta = event.data as any; - for (const contentPart of delta.delta.content || []) { - if (contentPart.text?.value) { - responseParts.push(contentPart.text.value); - } - } - } - if (event.runStatus) { - finalStatus = event.runStatus.status; - } - } - - const fullResponse = responseParts.join(''); - return { content: fullResponse, status: finalStatus }; - - } catch (error) { - return { content: `Error in conversation: ${error}`, status: 'failed' }; - } -} - -/** - * Interactive mode for testing the workplace assistant. - * - * This provides a simple interface for users to test the agent with their own questions - * and see how it combines different data sources for comprehensive answers. - */ -async function interactiveMode(config: AgentConfiguration): Promise { - console.log('\n' + '='.repeat(60)); - console.log('๐Ÿ’ฌ INTERACTIVE MODE - Test Your Workplace Assistant!'); - console.log('='.repeat(60)); - console.log('Ask questions that combine company policies with technical guidance:'); - console.log("โ€ข 'What's our remote work policy for Azure access?'"); - console.log("โ€ข 'How do I configure SharePoint security?'"); - console.log("โ€ข 'Our policy requires encryption - how do I set this up in Azure?'"); - console.log("Type 'quit' to exit."); - console.log('-'.repeat(60)); - - const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout - }); - - const askQuestion = (): Promise => { - return new Promise((resolve) => { - rl.question('\nโ“ Your question: ', (answer) => { - resolve(answer.trim()); - }); - }); - }; - - try { - while (true) { - const question = await askQuestion(); - - if (['quit', 'exit', 'bye'].includes(question.toLowerCase())) { - break; - } - - if (!question) { - console.log('๐Ÿ’ก Please ask a question about policies or technical implementation.'); - continue; - } - - process.stdout.write('\n๐Ÿค– Workplace Assistant: '); - const response = await chatWithAssistant(config.agent.id, config.mcpTool, question); - console.log(response.content); - - if (response.status !== 'completed') { - console.log(`\nโš ๏ธ Response status: ${response.status}`); - } - - console.log('-'.repeat(60)); - } - } catch (error) { - console.log(`\nโŒ Error: ${error}`); - } finally { - rl.close(); - } - - console.log('\n๐Ÿ‘‹ Thank you for testing the Modern Workplace Assistant!'); -} - -/** - * Main execution flow demonstrating the complete sample. - * - * This orchestrates the full demonstration: - * 1. Agent creation with diagnostic information - * 2. Business scenario demonstration - * 3. Interactive testing mode - * 4. Clean completion with next steps - */ -async function main(): Promise { - console.log('๐Ÿš€ Azure AI Foundry - Modern Workplace Assistant'); - console.log('Tutorial 1: Building Enterprise Agents with SharePoint + MCP Integration'); - console.log('='.repeat(70)); - - try { - // Create the agent with full diagnostic output - const agentConfig = await createWorkplaceAssistant(); - - // Demonstrate business scenarios - await demonstrateBusinessScenarios(agentConfig); - - // Offer interactive testing - const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout - }); - - const answer = await new Promise((resolve) => { - rl.question('\n๐ŸŽฏ Try interactive mode? (y/n): ', (answer) => { - rl.close(); - resolve(answer.toLowerCase()); - }); - }); - - if (answer.startsWith('y')) { - await interactiveMode(agentConfig); - } - - console.log('\n๐ŸŽ‰ Sample completed successfully!'); - console.log('๐Ÿ“š This foundation supports Tutorial 2 (Governance) and Tutorial 3 (Production)'); - console.log('๐Ÿ”— Next: Add evaluation metrics, monitoring, and production deployment'); - - } catch (error) { - console.error('โŒ Sample failed:', error); - process.exit(1); - } -} - -// Run the main function if this is the main module -if (require.main === module) { - main(); -} - -export { - createWorkplaceAssistant, - demonstrateBusinessScenarios, - chatWithAssistant, - interactiveMode, - AgentConfiguration, - BusinessScenario, - ChatResult -}; \ No newline at end of file diff --git a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/tsconfig.json b/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/tsconfig.json deleted file mode 100644 index b7b57dd88..000000000 --- a/samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype/tsconfig.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "commonjs", - "lib": ["ES2020"], - "outDir": "./dist", - "rootDir": "./src", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "declaration": true, - "declarationMap": true, - "sourceMap": true, - "removeComments": false, - "noImplicitAny": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "moduleResolution": "node", - "baseUrl": "./", - "paths": { - "*": ["node_modules/*"] - }, - "allowSyntheticDefaultImports": true, - "experimentalDecorators": true, - "emitDecoratorMetadata": true - }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "dist", - "**/*.test.ts" - ] -} \ No newline at end of file