Overview
This article provides step-by-step guidance on how to:
- Create a Grounding with Bing Search resource in Azure.
- Connect it to an Azure AI Foundry Agent.
- Interact with the grounded agent programmatically using REST APIs (Threads, Messages, Runs).
Once configured, your agent will be able to use Bing Search results to provide accurate, grounded, citation-based answers.
Part 1 — Configure Bing Grounding in Azure
Step 1: Create a “Grounding with Bing Search” Resource
-
Open the Azure Portal.
-
In the search bar, type “Grounding with Bing Search”.
-
Select Create.
-
Provide the required details:
- Subscription
- Resource Group (recommended: same as your AI agent)
- Name for the grounding resource
-
Choose a pricing tier.
-
Click Review + create → Create.
Your Bing grounding resource is now deployed.
Step 2: Add the Grounding Tool to Your Agent
- Open the Azure AI Foundry portal.
- Navigate to Agents.
- Select your agent.
- On the right-side Setup panel, select Knowledge.
- Click Add.
- From the tool list, choose Grounding with Bing Search.
- When prompted, click Add connection.
- Select the Bing grounding resource created in Step 1.
- Click Add connection to finalize.
Your agent is now configured to perform Bing-grounded search queries.
Part 2 — Interacting with the Grounded Agent Using REST APIs
Azure Agents follow a Threads → Messages → Runs model.
Before sending requests, authenticate using Azure CLI.
Step 3: Authenticate and Obtain an Access Token
1. Log in to Azure
az login
2. Fetch access token for Azure AI Foundry
az account get-access-token --resource 'https://ai.azure.com' | jq -r .accessToken | tr -d '"'
Use this token as your Bearer token in all API calls.
Part 3 — Using the API
Below are the endpoints to create a thread, add a message, run it, and retrieve the output.
Use your actual project name and agent resource name in URLs:
https://<your-agent-resource>.services.ai.azure.com/api/projects/<project>
Step 4: Create a Thread
curl --request POST \
--url 'https://search-agent-resource.services.ai.azure.com/api/projects/search-agent/threads?api-version=2025-05-01' \
-H "Authorization: Bearer <bearer>" \
-H "Content-Type: application/json" \
-d ''
Example Response
{
"id": "thread_oNLMlAS6UEely1dYXnZobrA5",
"object": "thread",
"created_at": 1763553651,
"metadata": {},
"tool_resources": {}
}
Step 5: Add a User Message to the Thread
curl --request POST \
--url 'https://search-agent-resource.services.ai.azure.com/api/projects/search-agent/threads/thread_oNLMlAS6UEely1dYXnZobrA5/messages?api-version=2025-05-01' \
-H "Authorization: Bearer <bearer>" \
-H "Content-Type: application/json" \
-d '{
"role": "user",
"content": "Get me the latest news on the stock market"
}'
Step 6: Run the Thread (Trigger the Agent)
curl --request POST \
--url 'https://search-agent-resource.services.ai.azure.com/api/projects/search-agent/threads/thread_oNLMlAS6UEely1dYXnZobrA5/runs?api-version=2025-05-01' \
-H "Authorization: Bearer <bearer>" \
-d '{
"assistant_id": "asst_DG0ojfEdfF85p8NEkkr8Lkqn"
}'
The response shows:
- run ID
- status
- grounding tool configuration attached to the agent
Step 7: Check Run Status
curl --request GET \
--url 'https://search-agent-resource.services.ai.azure.com/api/projects/search-agent/threads/thread_oNLMlAS6UEely1dYXnZobrA5/runs/run_SlmNzVexTdclCDm5Q2UXchvv?api-version=2025-05-01' \
-H "Authorization: Bearer <bearer>"
Example response:
"status": "completed"
Step 8: Retrieve the Agent’s Output
curl --request GET \
--url 'https://search-agent-resource.services.ai.azure.com/api/projects/search-agent/threads/thread_oNLMlAS6UEely1dYXnZobrA5/messages?api-version=2025-05-01' \
-H "Authorization: Bearer <bearer>"
This returns:
- user message(s)
- assistant response
- grounded citations from Bing Search
Summary
You have now:
Created a Grounding with Bing Search resource
Connected it to your Azure AI Foundry agent
Used authentication and REST API calls to:
- Create a thread
- Add user messages
- Run the agent
- Retrieve grounded responses with citations
Your agent can now answer any factual queries using real-time Bing Search grounding.
