Azure AI Agent Service: A Quick-Start Guide

Sannidhi Siva
3 min readFeb 9, 2025

--

Azure AI Agent Service is a platform that makes it easy to create, deploy, and scale AI agents. These agents can answer questions, perform tasks, and automate workflows by using AI models and tools to interact with real-world data.

Example Use Cases

  • 🛎️ Customer Support: AI agents handle common queries and escalate complex issues, improving response times.
  • 📊 Data Analysis: AI agents gather data, perform analysis, and generate reports for better decision-making.

These use cases show how Azure AI Agent Service can be applied in various industries to enhance efficiency and productivity.

Compared to Azure OpenAI Assistants, this service offers more flexibility in model selection, better data integrations, and strong security.

Azure AI Agent Service: Revolutionizing AI Agent Development and Deployment

What is Azure AI Agent Service? — Azure AI services | Microsoft Learn

In this article, we’ll explore how to harness Azure AI Agent Service to create a Healthcare AI Agent that can extract insights from healthcare data.

HealthCare AI Agent is a comprehensive, AI-powered system that seamlessly integrates the sophisticated capabilities of Azure AI agents with the advanced language understanding of OpenAI Models to deliver health data extraction.

By combining these powerful technologies, HealthCare AI Agent goes beyond simple keyword detection to provide in-depth insights into both medical information (e.g., symptoms, diagnoses, and treatments)

By way of a brief introduction, I’ll Walk through a straightforward example to illustrate how to summarize clinical data.

AI Generated

Below is a complete guide to setting up Azure AI Agent Service, which lays the groundwork for our next steps in orchestrating the agent service.

Quickstart — Create a new Azure AI Agent Service project — Azure AI services | Microsoft Learn

Create Project Client

Link: Azure AI Projects client library for Python | Microsoft Learn

# Initialize Project Client
project_client = AIProjectClient.from_connection_string(
credential=DefaultAzureCredential(),
conn_str=PROJECT_CONNECTION_STRING
)

Create Agents

with project_client:
# ------------------------------------------------------------------------
# A) Create Agent #1 (Healthcare Data Analysis)
# ------------------------------------------------------------------------

code_interpreter = CodeInterpreterTool()

health_data_agent = project_client.agents.create_agent(
model="MODEL_NAME",
name="HealthDataAgent",
instructions=(
"You are an AI agent specialized in analyzing health data from text. "
"Extract relevant medical details such as symptoms, diagnoses, treatments, "
"and social determinants of health, and provide a concise summary."
),
tools=code_interpreter.definitions, # Remove if not needed
tool_resources=code_interpreter.resources # Remove if not needed
)

print(f"Created HealthDataAgent, agent ID: {health_data_agent.id}")


# ------------------------------------------------------------------------
# B) Create Agent #2
# ------------------------------------------------------------------------
healthcare_summarize_agent = project_client.agents.create_agent(
model="MODEL_NAME",
name="HealthcareSummarizeAgent",
instructions=(
"You are an AI agent specialized in summarizing healthcare data "
)
)
print(f"Created HealthcareSummarizeAgent, agent ID: {healthcare_summarize_agent.id}")

Create Thread

A conversation session occurs between an Assistant and a user, with Threads organizing Messages and automatically managing truncation to ensure they fit within the model’s context.

    hc_agent_thread = project_client.agents.create_thread()
print(f"Created thread for HealthcareAgent, thread ID: {hc_agent_thread.id}")

Run Thread

# Create a message with sample clinical text
hc_message = project_client.agents.create_message(
thread_id=hc_thread.id,
role="user",
content=(
"Patient states they have experienced headaches and fatigue for the past two weeks. "
"They report difficulty affording healthy meals and occasionally forget to take "
"their prescribed blood pressure medication."
),
)
print(f"Healthcare message created, message ID: {hc_message.id}")

# Run the HealthcareAgent
hc_run = project_client.agents.create_and_process_run(
thread_id=hc_agent_thread.id,
assistant_id=health_data_agent.id
)
print(f"Healthcare run finished with status: {hc_run.status}")

if hc_run.status == "failed":
print(f"Healthcare run failed: {hc_run.last_error}")

Read Thread Messages

   # Retrieve messages from the healthcare data extraction thread
hc_messages = project_client.agents.list_messages(thread_id=hc_agent_thread.id)
print(f"Healthcare thread messages: {hc_messages}")

# Print last message
hc_last_msg = hc_messages.get_last_text_message_by_role("assistant")
if hc_last_msg:
print(f"Healthcare Agent last message:\n{hc_last_msg.text.value}")

In conclusion, this straightforward demonstration only scratches the surface of what Azure AI Agent Service can achieve.

Azure AI Agent Service works right away with multi-agent orchestration frameworks that work with the Assistants API.

--

--

No responses yet