In today’s fast-paced business environment, automation is no longer a luxury it’s a necessity.
Azure AI Agent Service is Microsoft’s LLM based agent platform, it makes it easy for developers to build scalable, secured and efficient autonomous AI agents.
In this blog post, we'll explore the highlights of Azure AI Agent Service and show you how to interact with it using a search engine (Bing) to streamline grounded search.
What is Azure AI Agent Service?
Organizations often struggle with time-consuming manual processes that hinder productivity. Azure AI Agent Service, launched at Ignite 2024, addresses these challenges by offering a robust set of managed capabilities to create, deploy, and monitor AI agents. These agents can automate tasks across various domains, such as customer service, sales, research, and software development.
Key Features of Azure AI Agent Service:
1. Rapid Development and Automation - Seamlessly integrates with Azure Logic Apps, Azure Functions, and tools like Code Interpreter to enable deterministic or non-deterministic task execution.
2. Knowledge Integration - Combines data from Bing, SharePoint, Fabric, and other sources for accurate, context-aware responses.
3. Flexible Model Selection - Use state-of-the-art models, including GPT-4o, Meta Llama 3.1, and Cohere Command R+, to optimize task-specific scenarios.
4. Enterprise-Ready Security and Scalability - Supports virtual private networks, BYO storage, and advanced observability through OpenTelemetry. For developers, the Azure AI Foundry SDK provides an intuitive interface to build and manage agents, making it easier to unlock productivity gains and operational efficiency.
Getting Started with Azure AI Agent Service
Now, let’s dive into a practical demonstration of how to interact with Azure AI Agent Service This tutorial will guide you through creating an AI agent, connecting it with Bing for data grounding.
Prerequisites
1. An active Azure subscription.
2. Deployed Azure AI Agent - you can use this one-click deployment
Note:Grounding with Bing Search only works with the following Azure OpenAI models: gpt-3.5-turbo-0125, gpt-4-0125-preview, gpt-4-turbo-2024-04-09, gpt-4o-0513, please choose a model from the list above - It is recommended to choose model gpt-4o-0513
3. Create a Grounding with Bing Search resource(Search bar ->Bing resources->add-> Grounding with Bing search), and connect it to your agent, make sure to create the Bing resource under the same agent resource group, follow steps (3-9) .
4. Install Azure CLI
Step 1
Set Up Your Environment First, install the required Python packages:
pip install azure-ai-projects azure-identity
Log into your Azure account
az login
Step 2
Define the connection string in your `.env` file. This connection string can be found in the Azure AI Foundry portal under Project details
It should be in the format "<HostName>;<AzureSubscriptionId>;<ResourceGroup>;<HubName>"
Initialize the Azure AI Client
import os
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
from azure.ai.projects.models import BingGroundingTool
project_client = AIProjectClient.from_connection_string(
credential=DefaultAzureCredential(),
conn_str=os.environ["PROJECT_CONNECTION_STRING"],
)
Create a connection to the Bing resource:
bing_connection = project_client.connections.get(
connection_name="bin"
)
conn_id = bing_connection.id
print(conn_id)
# Initialize agent bing tool and add the connection id
bing = BingGroundingTool(connection_id=conn_id)
Step 3
Create an Azure AI Agent that uses the Bing grounding tool for web data retrieval:
# Create agent with the bing tool and process assistant run
agent = project_client.agents.create_agent(
model="gpt-4o",
name="bing-assistant",
instructions="You are a helpful assistant",
tools=bing.definitions,
headers={"x-ms-enable-preview": "true"}
)
print(f"Created agent, ID: {agent.id}")
thread = project_client.agents.create_thread()
print(f"Created thread, ID: {thread.id}")
# Create message to thread
message = project_client.agents.create_message(
thread_id=thread.id,
role="user",
content="Can you summarize this microsoft report https://www.microsoft.com/en-us/investor/earnings/fy-2023-q2/press-release-webcast" ,#"who is the president of the united states",
)
print(f"Created message, ID: {message.id}")
# Create and process agent run in thread with tools
run = project_client.agents.create_and_process_run(thread_id=thread.id, assistant_id=agent.id)
print(f"Run finished with status: {run.status}")
# Retrieve run step details to get Bing Search query link
run_steps = project_client.agents.list_run_steps(run_id=run.id, thread_id=thread.id)
run_steps_data = run_steps['data']
print(f"Last run step detail: {run_steps_data}")
if run.status == "failed":
print(f"Run failed: {run.last_error}")
# Fetch and log all messages
messages = project_client.agents.list_messages(thread_id=thread.id)
print(f"Messages: {messages}")
print(messages.data)
Step 4
Retrieve and Display Results After the agent processes the query, you can retrieve and display its response:
print(messages.data[0].content[0].text.value)
Step 5
Clean Up Resources When you’re done, don’t forget to delete the agent to free up resources: `
project_client.agents.delete_agent("add asst_id")
print("Deleted agent")
Conclusion
Azure AI Agent Service is a game-changer for businesses looking to automate workflows and unlock new capabilities. With its robust integration ecosystem, enterprise-grade security, and support for advanced models, it provides everything needed to build and deploy autonomous AI agents. By combining Azure AI Agent Service, developers can easily create agents that perform complex tasks, such as summarizing documents, analyzing data, or interacting with external APIs.
1. Check out this Python Notebook
2. Ready to scale - check this Autogen multi agent repository with single line of deployment Dream Team
3. Ready to get started? Check out the Azure AI Foundry SDK documentation
Let us know in the comments how you plan to use Azure AI Agent Service in your projects! 🚀
Updated Jan 28, 2025
Version 2.0yanivva
Microsoft
Joined April 16, 2024
AI - Azure AI services Blog
Follow this blog board to get notified when there's new activity