Building AI Solutions with Azure AI Foundry and Copilot Studio
A hands-on technical guide to building production AI applications using Azure AI Foundry, prompt flows, and Copilot Studio.
You've deployed a model. You've played with the chat playground. Now you need to build something real.
This guide takes you from "AI is working in my tests" to "AI is integrated into my application and serving users." We'll use Azure AI Foundry for orchestration and Copilot Studio for user-facing interfaces.
What We're Building
A practical internal IT support assistant that:
- Answers questions using company documentation
- Escalates to humans when confidence is low
- Integrates with Microsoft Teams for user access
- Logs interactions for improvement
This isn't a toy demo. It's a pattern you can adapt for real use cases.
Prerequisites
Before starting, you need:
- Azure subscription with AI services enabled
- Access to Azure AI Foundry (ai.azure.com)
- Copilot Studio license (included with some M365 plans)
- Basic understanding of REST APIs
- Some documents to use as a knowledge base
Part 1: Building the AI Backend in AI Foundry
Step 1: Set Up Your Project
- Go to ai.azure.com
- Create a new project: "IT-Support-Assistant"
- Select your resource group and region
- Enable Azure AI Search connection (we'll need this for RAG)
Step 2: Prepare Your Data
Create an index from your IT documentation:
- Navigate to Data + indexes in your project
- Click New index
- Choose data source:
- Azure Blob Storage for large document sets
- Upload files for smaller collections
- Upload your IT documentation (PDFs, Word docs, Markdown)
- Configure chunking:
- Chunk size: 1024 tokens (good balance for Q&A)
- Overlap: 128 tokens (maintains context across chunks)
- Create the index and wait for processing
Tip: Start with 10-20 representative documents. You can add more later, but it's easier to iterate on a smaller set.
Step 3: Deploy Your Model
- Open Model catalog
- Deploy GPT-4o (or GPT-4o-mini for cost savings)
- Configuration:
- Tokens per minute: Start with 10K (scale later)
- Content filter: Keep default settings
- Note your deployment name — you'll need it
Step 4: Create the Prompt Flow
This is where the magic happens. A prompt flow chains together data retrieval and AI generation.
- Go to Prompt flow → Create
- Choose template: Chat with your data
- Configure the flow:
Node 1: Query Rewriting
You are a query rewriter for an IT support system.
Rewrite the user's question to be more specific and searchable.
If the question is already clear, return it unchanged.
User question: {{user_question}}
Rewritten query:
Node 2: Document Retrieval
- Connect to your index
- Top K results: 5
- Search type: Hybrid (vector + keyword)
Node 3: Response Generation
You are an IT support assistant for [Company Name].
CONTEXT (from internal documentation):
{{retrieved_documents}}
GUIDELINES:
- Answer based ONLY on the provided context
- If the context doesn't contain the answer, say "I don't have information about that. Let me connect you with the IT team."
- Be concise but complete
- For step-by-step procedures, use numbered lists
- Never invent procedures not in the documentation
USER QUESTION: {{user_question}}
RESPONSE:
Node 4: Confidence Check
Based on your response, rate your confidence (HIGH, MEDIUM, LOW):
- HIGH: Answer directly from documentation
- MEDIUM: Answer derived from documentation but not explicit
- LOW: Limited relevant documentation found
Confidence:
- Test the flow with sample questions
- Iterate on prompts until quality is acceptable
Step 5: Add Evaluation
Before deploying, measure quality:
- Create a test dataset:
[
{
"question": "How do I reset my password?",
"expected": "Contains steps for password reset portal"
},
{
"question": "What's the VPN server address?",
"expected": "Contains specific server URL"
}
]
-
Run evaluation:
- Groundedness: Is the response based on retrieved docs?
- Relevance: Does it answer the question?
- Coherence: Is it well-structured?
-
Review results and refine prompts
Step 6: Deploy as Endpoint
- Click Deploy from your prompt flow
- Choose Managed online endpoint
- Configure:
- Instance type: Standard_DS3_v2 (start small)
- Instance count: 1 (scale based on usage)
- Deploy and note the endpoint URL + API key
Test the endpoint:
curl -X POST "https://your-endpoint.inference.ai.azure.com/score" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"question": "How do I connect to VPN?"}'
Part 2: Building the User Interface with Copilot Studio
Now we'll create a Teams bot that calls your AI Foundry endpoint.
Step 1: Create a New Copilot
- Go to copilotstudio.microsoft.com
- Create new copilot: "IT Support Bot"
- Skip the AI-generated topics for now
Step 2: Create a Power Automate Flow for AI Foundry
Copilot Studio needs to call your AI Foundry endpoint. We'll use Power Automate as the bridge.
- In Copilot Studio, go to Actions → Add an action
- Choose Create a new flow
- Build the flow:
Trigger: When Power Virtual Agents calls a flow
- Input:
UserQuestion(text)
HTTP Action:
- Method: POST
- URI: Your AI Foundry endpoint URL
- Headers:
- Authorization: Bearer YOUR_API_KEY
- Content-Type: application/json
- Body:
{
"question": "@{triggerBody()['text']}"
}
Parse JSON:
- Content: Body from HTTP action
- Schema: Generate from sample response
Response:
- Return
responseandconfidenceto Copilot Studio
- Save and publish the flow
Step 3: Create the Conversation Topic
-
In Copilot Studio, create a new topic: "IT Support Question"
-
Add trigger phrases:
- "I have a question"
- "Help me with"
- "How do I"
- "What's the process for"
-
Build the conversation:
Question node:
- "What do you need help with?"
- Save to variable:
UserQuestion
Action node:
- Call your Power Automate flow
- Pass
UserQuestion - Store response in
AIResponse - Store confidence in
Confidence
Condition node:
- If
Confidenceequals "LOW":- Message: "I'm not certain about this. Let me connect you with the IT team."
- Transfer to agent or create ticket
- Else:
- Message:
AIResponse - Ask: "Did this answer your question?"
- Message:
Follow-up:
- If yes: "Great! Anything else I can help with?"
- If no: Offer to create a support ticket
Step 4: Add Fallback Handling
For questions outside IT scope:
- Go to System topics → Fallback
- Customize to redirect to IT topic or explain scope
Step 5: Publish to Teams
- Go to Channels → Microsoft Teams
- Configure bot details:
- Name: "IT Support Assistant"
- Description: "Get help with IT questions"
- Submit for admin approval (or approve yourself if admin)
- Add to Teams
Part 3: Production Considerations
Monitoring
Set up observability:
AI Foundry:
- Enable Application Insights for your endpoint
- Track: latency, token usage, error rates
Copilot Studio:
- Review Analytics dashboard
- Monitor: session counts, resolution rates, escalations
Create alerts for:
- Latency > 5 seconds
- Error rate > 5%
- Daily cost exceeding threshold
Cost Management
AI costs can surprise you. Implement controls:
- Set Azure budgets with alerts at 50%, 80%, 100%
- Use GPT-4o-mini where possible (10x cheaper than GPT-4o)
- Cache common responses for frequently asked questions
- Rate limit the Teams bot to prevent abuse
Continuous Improvement
Your AI gets better with feedback:
- Log all interactions (question, response, confidence, user feedback)
- Review low-confidence responses weekly
- Add missing documentation when gaps appear
- Refine prompts based on failure patterns
- Expand test dataset with real user questions
Security
- Store API keys in Azure Key Vault, not in flows
- Implement authentication for the Teams bot
- Review content filters in AI Foundry
- Ensure documentation doesn't contain sensitive data unintentionally
Troubleshooting Common Issues
"I don't have information about that" for everything
- Check index is properly created
- Verify search is returning results (test in AI Foundry)
- Adjust chunk size or search parameters
Slow responses
- Check endpoint instance size
- Consider caching for common questions
- Reduce Top K results if retrieval is slow
Inconsistent answers
- Add examples to your system prompt
- Increase temperature if too repetitive, decrease if too random
- Improve document quality (AI is only as good as your data)
Teams bot not responding
- Check Power Automate flow is published
- Verify API key hasn't expired
- Review Copilot Studio error logs
What's Next
Once this pattern is working:
- Add more data sources — Connect SharePoint, ServiceNow, etc.
- Implement ticket creation — Auto-create tickets from the bot
- Add analytics — Dashboard of common questions and trends
- Expand scope — HR questions, facilities, other departments
You've built the foundation. The same architecture scales to more complex scenarios.
The code is the easy part. The hard part is curating good documentation and iterating based on real user feedback.
Start small. Measure everything. Improve continuously.
Read Next
Azure AI Foundry: Getting Started with Microsoft's AI Platform
A practical introduction to Azure AI Foundry — what it is, when to use it, and how to build your first AI application.
Implementing Conditional Access for Azure Virtual Desktop
A step-by-step guide to securing your AVD environment with Conditional Access policies that actually make sense.
Free Azure Learning Resources I Actually Recommend (2026)
The genuinely useful free resources for learning Azure — no fluff, no outdated links, just what works.