Skip to content

referencenull/websearchagent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

websearchagent

Agent to do websearch, built with agent framework

What this sample demonstrates

This sample demonstrates how to build a web search agent using Bing Grounding, hosted using Azure AI AgentServer SDK and deploy it to Microsoft Foundry using the Azure Developer CLI ai agent extension.

How It Works

Web Search Agent

The agent uses Bing Grounding to search the web for current information and provide accurate, well-sourced answers. This demonstrates:

  • How to integrate Bing Grounding as a tool in an AI agent
  • How to use the HostedWebSearchTool from the Agent Framework

Agent Hosting

The agent is hosted using the Azure AI AgentServer SDK, which provisions a REST API endpoint compatible with the OpenAI Responses protocol. This allows interaction with the agent using OpenAI Responses compatible clients.

Agent Deployment

The hosted agent can be seamlessly deployed to Microsoft Foundry using the Azure Developer CLI ai agent extension. The extension builds a container image into Azure Container Registry (ACR), and creates a hosted agent version and deployment on Microsoft Foundry.

Running the Agent Locally

Prerequisites

Before running this sample, ensure you have:

  1. An Azure AI Foundry project configured
  2. A deployment of a chat model (e.g., gpt-4.1-mini)
  3. A Bing Grounding connection in your project
  4. Azure CLI installed and authenticated (az login)
  5. Python 3.10+ installed

Environment Variables

Create a .env file with the following environment variables:

Note: The .env file is for local development only. When deploying to Azure AI Foundry, remove the .env file and configure environment variables in agent.yaml instead.

AZURE_AI_PROJECT_ENDPOINT=https://<your-foundry-account>.services.ai.azure.com/api/projects/<your-project>
AZURE_AI_MODEL_DEPLOYMENT_NAME=<your-model-deployment>  # e.g., gpt-4.1-mini
BING_GROUNDING_CONNECTION_ID=/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.CognitiveServices/accounts/<foundry-account>/projects/<project>/connections/<bing-connection-name>

Installing Dependencies

Install the required Python dependencies using pip:

pip install -r requirements.txt

Running the Sample

To run the agent, execute the following command in your terminal:

python main.py

This will start the hosted agent locally on http://localhost:8088/.

Interacting with the Agent

curl -X POST http://localhost:8088/responses \
  -H "Content-Type: application/json" \
  -d '{"input": "What is the latest news in AI?"}' | jq .

Deploying the Agent to Microsoft Foundry

To deploy your agent to Microsoft Foundry, follow the comprehensive deployment guide at https://aka.ms/azdaiagent/docs

Troubleshooting

Images built on Apple Silicon or other ARM64 machines do not work on our service

We recommend using azd cloud build, which always builds images with the correct architecture.

If you choose to build locally, and your machine is not linux/amd64 (for example, an Apple Silicon Mac), the image will not be compatible with our service, causing runtime failures.

Fix for local builds

Use this command to build the image locally:

docker build --platform=linux/amd64 -t image .

This forces the image to be built for the required amd64 architecture.

About

Agent to do websearch, built with agent framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors