Skip to content

Commit b99cffb

Browse files
Merge pull request #5982 from MicrosoftDocs/main
Auto Publish – main to live - 2025-07-10 22:06 UTC
2 parents 6ff137a + 523e615 commit b99cffb

21 files changed

+754
-211
lines changed

articles/ai-foundry/agents/how-to/tools/bing-custom-search-samples.md

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Find samples to ground Azure AI Foundry Agents using Custom Bing Se
55
author: aahill
66
ms.author: aahi
77
manager: nitinme
8-
ms.date: 04/15/2025
8+
ms.date: 07/09/2025
99
ms.service: azure-ai-agent-service
1010
ms.topic: how-to
1111
ms.custom:
@@ -16,6 +16,7 @@ zone_pivot_groups: selection-bing-custom-grounding
1616

1717
# How to use Grounding with Bing Custom Search (preview)
1818

19+
Use this article to find step-by-step instructions and code samples for using the Grounding with Bing Custom Search tool in the Azure AI Foundry Agent Service.
1920

2021
::: zone pivot="portal"
2122

@@ -36,18 +37,43 @@ zone_pivot_groups: selection-bing-custom-grounding
3637

3738
:::zone-end
3839

39-
<!--
4040
::: zone pivot="python"
4141

42+
## Prerequisites
43+
44+
* Your Azure AI Foundry Project endpoint.
45+
46+
[!INCLUDE [endpoint-string-portal](../../includes/endpoint-string-portal.md)]
47+
48+
Save this endpoint to an environment variable named `PROJECT_ENDPOINT`.
49+
50+
* The name of your Grounding with Bing Custom Search resource name. You can find it in the Azure AI Foundry portal by selecting **Management center** from the left navigation menu. Then selecting **Connected resources**.
51+
52+
:::image type="content" source="../../media/tools/bing/custom-resource-name.png" alt-text="A screenshot showing the Grounding with Bing Custom Search resource name. " lightbox="../../media/tools/bing/custom-resource-name.png":::
53+
54+
Save this resource name to an environment variable named `BING_CUSTOM_CONNECTION_NAME`.
55+
56+
* The name of your Grounding with Bing Custom Search configuration, which contains the URLs you want to allow or disallow. You can find it by navigating to the overview page for your resource in the [Azure portal](https://portal.azure.com/). Select **Configurations**, then select your configuration.
57+
58+
:::image type="content" source="../../media/tools/bing/custom-connection-name.png" alt-text="A screenshot showing the Grounding with Bing Custom Search connection name. " lightbox="../../media/tools/bing/custom-connection-name.png":::
59+
60+
Save this connection name to an environment variable named `BING_CUSTOM_CONNECTION_NAME`.
61+
62+
* The names of your model's deployment name. You can find it in **Models + Endpoints** in the left navigation menu.
63+
64+
:::image type="content" source="../../media/tools/model-deployment-portal.png" alt-text="A screenshot showing the model deployment screen the AI Foundry portal." lightbox="../../media/tools/model-deployment-portal.png":::
65+
66+
Save the name of your model deployment name as an environment variable named `MODEL_DEPLOYMENT_NAME`.
67+
4268
## Create a project client
4369

4470
Create a client object, which will contain the connection string for connecting to your AI project and other resources.
4571

4672
```python
4773
import os
4874
from azure.ai.projects import AIProjectClient
49-
from azure.ai.projects.models import MessageRole, BingCustomSearchTool
5075
from azure.identity import DefaultAzureCredential
76+
from azure.ai.agents.models import BingCustomSearchTool
5177

5278

5379
# Create an Azure AI Client from an endpoint, copied from your Azure AI Foundry project.
@@ -57,32 +83,34 @@ project_endpoint = os.environ["PROJECT_ENDPOINT"] # Ensure the PROJECT_ENDPOINT
5783
# Create an AIProjectClient instance
5884
project_client = AIProjectClient(
5985
endpoint=project_endpoint,
60-
credential=DefaultAzureCredential(), # Use Azure Default Credential for authentication
61-
api_version="latest",
86+
credential=DefaultAzureCredential(),
6287
)
6388
```
6489

6590

6691
## Create an Agent with the Grounding with Bing Custom Search tool enabled
6792

68-
To make the Grounding with Bing Custom Search tool available to your agent, use a connection to initialize the tool and attach it to the agent. You can find your connection in the **connected resources** section of your project in the [Azure AI Foundry portal](https://ai.azure.com/?cid=learnDocs).
93+
To make the Grounding with Bing Custom Search tool available to your agent, use a connection to initialize the tool and attach it to the agent.
6994

7095
```python
71-
bing_custom_connection = project_client.connections.get(connection_name=os.environ["BING_CUSTOM_CONNECTION_NAME"])
96+
bing_custom_connection = project_client.connections.get(name=os.environ["BING_CUSTOM_CONNECTION_NAME"])
7297
conn_id = bing_custom_connection.id
7398

7499
print(conn_id)
75100

76-
# Initialize agent bing custom search tool and add the connection id
77-
bing_custom_tool = BingCustomSearchTool(connection_id=conn_id, instance_name="<config_instance_name>")
101+
configuration_name = os.environ["BING_CUSTOM_INSTANCE_NAME"]
102+
# Initialize Bing Custom Search tool with connection id and configuration name
103+
bing_custom_tool = BingCustomSearchTool(connection_id=conn_id, instance_name=configuration_name)
78104

79105
# Create agent with the bing custom search tool and process assistant run
80106
with project_client:
81-
agent = project_client.agents.create_agent(
107+
agents_client = project_client.agents
108+
109+
agent = agents_client.create_agent(
82110
model=os.environ["MODEL_DEPLOYMENT_NAME"],
83111
name="my-agent",
84112
instructions="You are a helpful agent",
85-
tools=bing_custom_tool.definitions
113+
tools=bing_custom_tool.definitions,
86114
)
87115
print(f"Created agent, ID: {agent.id}")
88116
```
@@ -91,13 +119,13 @@ with project_client:
91119

92120
```python
93121
# Create thread for communication
94-
thread = project_client.agents.create_thread()
122+
thread = agents_client.threads.create()
95123
print(f"Created thread, ID: {thread.id}")
96124

97125
# Create message to thread
98-
message = project_client.agents.create_message(
126+
message = agents_client.messages.create(
99127
thread_id=thread.id,
100-
role=MessageRole.USER,
128+
role="user",
101129
content="How many medals did the USA win in the 2024 summer olympics?",
102130
)
103131
print(f"Created message, ID: {message.id}")
@@ -109,31 +137,29 @@ Create a run and observe that the model uses the Grounding with Bing Search tool
109137

110138

111139
```python
112-
# Create and process agent run in thread with tools
113-
run = project_client.agents.create_and_process_run(thread_id=thread.id, agent_id=agent.id)
140+
# Create and process Agent run in thread with tools
141+
run = agents_client.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
114142
print(f"Run finished with status: {run.status}")
115143

116144
if run.status == "failed":
117145
print(f"Run failed: {run.last_error}")
118146

119-
# Delete the assistant when done
120-
project_client.agents.delete_agent(agent.id)
121-
print("Deleted agent")
122-
123-
# Print the Agent's response message with optional citation
124-
response_message = project_client.agents.list_messages(thread_id=thread.id).get_last_message_by_role(
125-
MessageRole.AGENT
126-
)
127-
if response_message:
128-
for text_message in response_message.text_messages:
129-
print(f"Agent response: {text_message.text.value}")
130-
for annotation in response_message.url_citation_annotations:
131-
print(f"URL Citation: [{annotation.url_citation.title}]({annotation.url_citation.url})")
147+
# Uncomment these lines to delete the Agent when done
148+
#agents_client.delete_agent(agent.id)
149+
#print("Deleted agent")
150+
151+
# Fetch and log all messages
152+
messages = agents_client.messages.list(thread_id=thread.id)
153+
for msg in messages:
154+
if msg.text_messages:
155+
for text_message in msg.text_messages:
156+
print(f"Agent response: {text_message.text.value}")
157+
for annotation in msg.url_citation_annotations:
158+
print(f"URL Citation: [{annotation.url_citation.title}]({annotation.url_citation.url})")
132159
```
133160

134161

135162
:::zone-end
136-
-->
137163

138164
<!--
139165
::: zone pivot="csharp"

articles/ai-foundry/agents/how-to/tools/deep-research-samples.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,41 @@ services: cognitive-services
66
manager: nitinme
77
ms.service: azure-ai-agent-service
88
ms.topic: how-to
9-
ms.date: 06/30/2025
9+
ms.date: 07/10/2025
1010
author: aahill
1111
ms.author: aahi
12+
ms.custom: references_regions
1213
---
1314

1415
# How to use the Deep Research tool
1516

17+
> [!NOTE]
18+
> * The `o3-deep-research` model is available for use **only with the Deep Research tool**. It is **not** available in the Azure OpenAI Chat Completions and Responses APIs.
19+
> * The **parent** AI Foundry project resource and the contained `o3-deep-research` model and GPT models **must exist** in the same Azure subscription and region. Supported regions are **West US** and **Norway East**.
20+
1621
Use this article to learn how to use the Deep Research tool with the Azure AI Projects SDK, including code examples and setup instructions.
1722

1823
## Prerequisites
1924

20-
> [!NOTE]
21-
> * The `o3-deep-research` model and the GPT model deployments should be part of your AI Foundry project resulting in all three resources in the same Azure subscription and same region. Supported regions are **West US** and **Norway East**.
22-
2325
* The requirements in the [Deep Research overview](./deep-research.md).
24-
* The Deep Research tool requires the latest prerelease versions of the `azure-ai-projects` library. You can install it with the following command:
26+
* The Deep Research tool requires the latest prerelease versions of the `azure-ai-projects` library. First we recommend creating a [virtual environment](https://docs.python.org/3/library/venv.html) to work in:
27+
28+
```console
29+
python -m venv env
30+
# after creating the virtual environment, activate it with:
31+
.\env\Scripts\activate
32+
```
33+
34+
You can install the package with the following command:
2535

2636
```console
2737
pip install --pre azure-ai-projects
2838
```
2939

3040
* Your Azure AI Foundry Project endpoint.
3141

32-
You can find your endpoint in the main project **overview** for your project in the [Azure AI Foundry portal](https://ai.azure.com/?cid=learnDocs), under **Endpoint and keys** > **Libraries** > **Azure AI Foundry**.
33-
34-
:::image type="content" source="../../media/quickstart/portal-endpoint-string.png" alt-text="A screenshot showing the endpoint in the Azure AI Foundry portal." lightbox="../../media/quickstart/portal-endpoint-string.png":::
42+
43+
[!INCLUDE [endpoint-string-portal](../../includes/endpoint-string-portal.md)]
3544

3645
Save this endpoint to an environment variable named `PROJECT_ENDPOINT`.
3746

0 commit comments

Comments
 (0)