Introduction
This article explains how to create a Grounded Search Agent in Azure AI Foundry using Bing Search as the external grounding tool.
Once created, the agent can be exposed as a REST API endpoint and integrated into applications such as:
- AI for Work
- Copilot
- Web or backend applications
- Slack/Teams bots
- Enterprise services
- Partner solutions
The agent uses Azure OpenAI models (GPT-4o, GPT-4.1, GPT-5) to process user queries and provide accurate, citation-backed, search-grounded responses.
Architecture Overview
+---------------------------+
| Azure AI Foundry |
| Agent Runtime |
+------------+--------------+
|
Tool Call
|
v
+---------------------------+
| Bing Search v7 API |
| (Grounding Source) |
+---------------------------+
^
|
Search Results
|
v
+---------------------------+
| Azure OpenAI LLM |
| (GPT-4o / GPT-5) |
| Reasoning + Synthesis |
+---------------------------+
|
Grounded Answer
|
v
+---------------------------+
| REST Agent Endpoint |
+---------------------------+
Prerequisites
You will need:
Required Azure Resources
| Resource | Purpose |
|---|---|
| Azure Subscription | Access to Azure AI Foundry and OpenAI |
| Azure AI Foundry Hub + Project | Where the agent is hosted |
| Azure OpenAI Model Deployment | GPT-4o / GPT-4.1 / GPT-5 |
| Bing Search v7 Cognitive Service | External grounding via web search |
Values to Keep Handy
- BING_SEARCH_KEY
- BING_SEARCH_ENDPOINT
- Model deployment name
- Project Endpoint + API Keys
Step 1 β Deploy an Azure OpenAI Model
-
Go to Azure AI Foundry β Your Project β Models
-
Choose and deploy a model:
- GPT-4o
- GPT-4.1
- GPT-5-mini
-
Deployment Options:
- Serverless API (recommended)
- Dedicated deployment (for VNet or private setups)
Step 2 β Add Bing Search as a Tool
Azure AI Foundry supports built-in tools or custom tools.
Option A β Built-in Bing Web Search Tool (Recommended)
Navigate:
AI Foundry β Agents β Tools β Add Tool β βWeb Search (Bing)β
Enter your:
- API Key
- Endpoint
- Region
Option B β Custom HTTP Tool (Manual Setup)
Tool Name: bing_web_search
Method: GET
Endpoint:
https://api.bing.microsoft.com/v7.0/search?q={query}
Headers:
Ocp-Apim-Subscription-Key: {{BING_SEARCH_KEY}}
Request Schema:
{
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Search query to execute on Bing"
}
},
"required": ["query"]
}
Step 3 β Create the Search Agent
Navigate to:
AI Foundry β Agents β Create Agent
Agent Configuration
| Setting | Value |
|---|---|
| Name | grounded-bing-search-agent |
| Runtime Model | GPT-4o or GPT-5 |
| Mode | Standard Agent |
| Tools | Attach β bing_web_search |
Recommended System Prompt
You are a grounded search agent.
For all factual questions, you MUST call the bing_web_search tool first.
Use the returned web results to synthesize short, citation-backed responses.
Never hallucinate or invent facts not supported by search results.
Always cite sources or URLs in the final answer.
If a query appears subjective, still attempt grounding via search.
Step 4 β Test the Agent
Example query:
βLatest updates on AI copyright policies in 2025β
Expected behavior:
- The model calls the Bing Search tool
- Search results are returned
- The model synthesizes a grounded answer with citations
Step 5 β Expose the Agent as a REST API Endpoint
Azure Foundry automatically generates an endpoint.
Navigate to:
Agent β Manage β Endpoints
You will get:
Endpoint URL
https://<project>.models.ai.azure.com/agents/<agent-id>/invocations
Required Headers
Content-Type: application/json
api-key: <YOUR_PROJECT_API_KEY>
Step 6 β How to Invoke the API
6.1. cURL Example
curl -X POST \
"https://<project>.models.ai.azure.com/agents/<agent-id>/invocations" \
-H "Content-Type: application/json" \
-H "api-key: <YOUR_API_KEY>" \
-d '{
"messages": [
{ "role": "user", "content": "Top breakthroughs in Retrieval-Augmented Generation 2025" }
]
}'
6.2. JavaScript (Axios)
import axios from "axios";
const endpoint = "https://<project>.models.ai.azure.com/agents/<agent-id>/invocations";
const apiKey = "<YOUR_API_KEY>";
async function invokeAgent() {
const response = await axios.post(
endpoint,
{
messages: [
{ role: "user", content: "Summaries of latest LLM safety regulation developments" }
]
},
{
headers: {
"Content-Type": "application/json",
"api-key": apiKey
}
}
);
console.log(response.data);
}
invokeAgent();
6.3. Python
import requests
endpoint = "https://<project>.models.ai.azure.com/agents/<agent-id>/invocations"
api_key = "<YOUR_API_KEY>"
payload = {
"messages": [
{"role": "user", "content": "Recent updates on generative AI security benchmarks"}
]
}
headers = {
"Content-Type": "application/json",
"api-key": api_key
}
res = requests.post(endpoint, headers=headers, json=payload)
print(res.json())
Step 7 β Optional: Publish via API Management
Use Azure API Management if:
- You want public APIs
- You need secure routing
- You want logging, throttling, or tenant isolation
Key Configurations
- Backend: Agent Endpoint
- Auth: API Keys or OAuth
- Rate Limits
- Logging & monitoring
Error Handling
| Error Code | Cause | Resolution |
|---|---|---|
| 401 | Invalid/missing API key | Regenerate keys |
| 403 | VNet restrictions | Use private endpoint or allowlist IP |
| 429 | Rate limit exceeded | Add retry logic or increase quota |
| ToolError | Bing Search API issues | Check subscription, region, or quota |
Security Best Practices
- Store all keys in Azure Key Vault
- Use Managed Identities when possible
- Enable monitoring via Azure Monitor
- Wrap endpoints behind API Management for added control
Appendix
Example Bing Search Tool Response
{
"webPages": {
"totalEstimatedMatches": 12,
"value": [
{
"name": "AI Safety Regulation 2025",
"url": "https://example.com/ai-policy",
"snippet": "Governments are accelerating..."
}
]
}
}
Example Grounded Answer
Here are the latest updates on AI regulation:
- The EU updated the AI Act with new risk-tier rules (2025).
- The US released draft high-risk LLM regulations for healthcare and finance.
- Japan & Singapore jointly released frontier model safety benchmarks.