你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
用于以编程方式管理和与 Azure SRE 代理交互的 REST API 操作。
Overview
Azure SRE 代理在两个层提供 REST API。 使用 控制平面(ARM) 创建、配置和删除代理及其子资源。 使用 数据平面 执行聊天、存储库管理和知识上传等运行时操作。
| 飞机 | 基 URL | Auth | 用于 |
|---|---|---|---|
| 控制平面 | management.azure.com |
标准Azure RBAC | 创建、更新、删除代理和配置 |
| 数据平面 | 每个代理终结点 |
azuresre.dev 观众 |
聊天, 存储库, 挂钩, 知识, 触发器 |
Authentication
控制平面 (ARM)
标准Azure身份验证 - Azure CLI、服务主体或托管标识:
# Interactive login
az login
# Service principal
az login --service-principal -u $APP_ID -p $SECRET --tenant $TENANT_ID
# Managed identity (from Azure VM or Container App)
az login --identity
数据平面
数据平面需要具有受众 https://azuresre.dev的单独令牌:
# Step 1: Get the agent's data plane endpoint
ENDPOINT=$(az rest -m GET \
--url "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.App/agents/{agentName}?api-version=2025-05-01-preview" \
--query properties.agentEndpoint -o tsv)
# Step 2: Get a data plane token
TOKEN=$(az account get-access-token \
--resource https://azuresre.dev \
--query accessToken -o tsv)
# Step 3: Call the data plane
curl -H "Authorization: Bearer $TOKEN" "$ENDPOINT/api/v1/threads"
注释
每个代理的代理终结点是唯一的。 它遵循模式https://{name}--{id}.{hash}.{region}.azuresre.ai,ARM GET 操作返回此终结点。properties.agentEndpoint
RBAC 角色
| 角色 | Description | Scope |
|---|---|---|
| SRE 代理管理员 | 完全控制代理配置和操作 | 代理资源 |
| SRE 代理用户 | 聊天、批准操作、管理线程 | 代理资源 |
| SRE 代理读取器 | 对代理配置和线程的只读访问 | 代理资源 |
使用 Azure 门户、CLI 或 ARM API 分配角色:
az role assignment create \
--assignee {userOrServicePrincipalId} \
--role "SRE Agent Administrator" \
--scope "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.App/agents/{name}"
控制平面 (ARM) 操作
API 版本
2025-05-01-preview
注释
控制平面和数据平面 API 目前为 预览版。 在正式发布之前,终结点路径、请求和响应架构和行为可能会更改。 将集成固定到此 API 版本,并在升级后进行测试。
基 URL
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.App/agents/{agentName}
追加操作表中的路径后缀,然后添加 ?api-version=2025-05-01-preview 为查询参数。 例如: .../agents/{agentName}/start?api-version=2025-05-01-preview。
代理资源操作
| 操作 | 方法 | 路径后缀 |
|---|---|---|
| 创建或更新 | PUT |
(无) |
| 获取 | GET |
(无) |
| 删除 | DELETE |
(无) |
| Start | POST |
/start |
| 停下 | POST |
/stop |
| 获取使用情况 | GET |
/usages |
| 获取每日使用情况 | GET |
/dailyusages |
代理属性
| 财产 | 类型 | Description |
|---|---|---|
provisioningState |
字符串 |
Succeeded、、FailedInProgress、Canceled、 Deleting (只读) |
agentEndpoint |
字符串 | 数据平面 URL (只读) |
powerState |
字符串 |
Running 或 Stopped (只读) |
outboundIpAddresses |
string[] | 允许列表的出站 IP (只读) |
actionConfiguration.mode |
字符串 |
Review、Automatic 或 ReadOnly |
actionConfiguration.accessLevel |
字符串 |
Low 或 High |
defaultModel.provider |
字符串 |
Anthropic 或 MicrosoftFoundry (Open AI) |
defaultModel.name |
字符串 | 模型名称(例如) Automatic |
upgradeChannel |
字符串 |
Stable 或 Preview |
monthlyAgentUnitLimit |
number | 每月活动流 AAU 上限(不包括 Always-On 流) |
knowledgeGraphConfiguration.identity |
字符串 | 托管标识资源 ID |
knowledgeGraphConfiguration.managedResources |
string[] | 代理可以访问的资源组 ID |
logConfiguration |
对象 | Application Insights 配置 |
incidentManagementConfiguration.type |
字符串 |
PagerDuty、AzMonitor、ServiceNow 或 None |
mcpServers |
string[] | MCP 服务器 URL |
vnetConfiguration.subnetResourceId |
字符串 | VNet 注入子网 |
experimentalSettings |
对象 | 功能标志替代 |
子资源
| 子资源 | ARM 类型 | 路径 |
|---|---|---|
| 连接器 | Microsoft.App/agents/DataConnectors |
/DataConnectors/{name} |
| 技能 | Microsoft.App/agents/skills |
/skills/{name} |
| 子代理 | Microsoft.App/agents/subagents |
/subagents/{name} |
| 工具 | Microsoft.App/agents/tools |
/tools/{name} |
| 计划任务 | Microsoft.App/agents/scheduledTasks |
/scheduledTasks/{name} |
| 事件筛选器 | Microsoft.App/agents/incidentFilters |
/incidentFilters/{name} |
| 钩子 | Microsoft.App/agents/hooks |
/hooks/{name} |
| 常见提示 | Microsoft.App/agents/commonPrompts |
/commonPrompts/{name} |
所有子资源都支持 PUT (创建/更新) GET和 DELETE 操作。
子资源正文格式
连接器 使用直接属性:
az rest -m PUT \
--url "https://management.azure.com/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.App/agents/{agent}/DataConnectors/my-kusto?api-version=2025-05-01-preview" \
--body '{
"properties": {
"name": "my-kusto",
"dataConnectorType": "Kusto",
"dataSource": "https://mycluster.eastus2.kusto.windows.net",
"identity": "system"
}
}'
其他子资源 (技能、子代理、工具等)使用 base64 编码的信封:
# The spec is base64-encoded inside properties.value
SPEC='{"name":"my-tool","description":"Query Azure Resource Graph"}'
ENCODED=$(echo -n "$SPEC" | base64)
az rest -m PUT \
--url "...Microsoft.App/agents/{agent}/tools/my-tool?api-version=2025-05-01-preview" \
--body "{\"properties\":{\"value\":\"$ENCODED\"}}"
连接器类型
| 类型 | 价值 | 用例 |
|---|---|---|
| Azure 数据资源管理器 | Kusto |
查询 ADX 群集 |
| Application Insights | Kusto |
查询 App Insights |
| Log Analytics | Kusto |
查询Log Analytics |
| MCP | Mcp |
MCP 兼容的连接器(Datadog、Splunk 等) |
| PagerDuty | Mcp |
PagerDuty 事件 |
| ServiceNow | Mcp |
ServiceNow 事件 |
| Outlook | Outlook |
电子邮件通知 |
| 团队 | Teams |
Teams 频道通知 |
数据平面操作
使用数据平面 API 与正在运行的代理进行交互,包括发送消息、管理审批、上传知识以及配置存储库、挂钩和触发器。
基 URL
从 ARM 获取:
ENDPOINT=$(az rest -m GET \
--url "...Microsoft.App/agents/{name}?api-version=2025-05-01-preview" \
--query properties.agentEndpoint -o tsv)
所有数据平面路径都以 $ENDPOINT/api/....
线程和聊天
| 方法 | 路径 | Description |
|---|---|---|
GET |
/api/v1/threads |
列出会话线程 |
GET |
/api/v1/threads/{threadId} |
获取特定线程 |
POST |
/api/v1/threads/{threadId}/messages |
发送消息(开始对话) |
GET |
/api/v1/threads/{threadId}/messages |
获取线程中的消息 |
审核
| 方法 | 路径 | Description |
|---|---|---|
GET |
/api/v1/approvals/{threadId} |
列出待批准的审批 |
POST |
/api/v1/approvals/{threadId}/{id}/decision |
批准或拒绝操作 |
代码存储库
| 方法 | 路径 | Description |
|---|---|---|
PUT |
/api/v2/repos/{repoName} |
添加代码存储库 |
GET |
/api/v2/repos |
列出存储库 |
GET |
/api/v2/repos/{repoName} |
获取存储库详细信息 |
DELETE |
/api/v2/repos/{repoName} |
删除存储库 |
POST |
/api/v2/repos/{repoName}/test |
测试存储库连接 |
知识(代理内存)
| 方法 | 路径 | Description |
|---|---|---|
POST |
/api/v1/agentmemory/upload |
上传文档(多部分,总计最多 100 MB,每个文件 16 MB) |
GET |
/api/v1/agentmemory/status |
检查内存状态 |
DELETE |
/api/v1/agentmemory/document/{fileName} |
删除文档 |
DELETE |
/api/v1/agentmemory/documents |
批量删除文档 |
GET |
/api/v1/agentmemory/indexer-status |
检查索引器进度 |
HTTP 触发器
| 方法 | 路径 | Description |
|---|---|---|
POST |
/api/v1/httptriggers/create |
创建 HTTP 触发器 |
GET |
/api/v1/httptriggers |
列表触发器 |
POST |
/api/v1/httptriggers/{triggerId}/execute |
执行触发器 |
POST |
/api/v1/httptriggers/trigger/{triggerId} |
公共 Webhook 终结点(无需身份验证) |
钩子
| 方法 | 路径 | Description |
|---|---|---|
PUT |
/api/v2/extendedAgent/hooks/{hookName} |
创建或更新挂钩 |
GET |
/api/v2/extendedAgent/hooks |
列表挂钩 |
DELETE |
/api/v2/extendedAgent/hooks/{hookName} |
删除挂钩 |
扩展代理配置
通过数据平面管理子代理、工具、连接器、技能、提示和插件:
| 资源 | 路径模式 |
|---|---|
| 子代理 | /api/v2/extendedAgent/agents/{name} |
| 工具 | /api/v2/extendedAgent/tools/{name} |
| 连接器 | /api/v2/extendedAgent/connectors/{name} |
| 技能 | /api/v2/extendedAgent/skills/{name} |
| 常见提示 | /api/v2/extendedAgent/commonprompts/{name} |
| 计划任务 | /api/v2/extendedAgent/scheduledtasks/{name} |
| Plugins | /api/v2/extendedAgent/plugins/{name} |
所有资源都支持PUT、GETPATCH方法和DELETE方法。
实时流式处理
代理使用 SignalR 进行实时聊天流式处理:
| Hub | 路径 | Purpose |
|---|---|---|
| AgentHub | /agentHub |
实时消息流式处理和线程更新 |
通过使用相同的持有者令牌使用 SignalR 客户端库进行连接。
示例
获取代理属性
az rest -m GET \
--url "https://management.azure.com/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.App/agents/{name}?api-version=2025-05-01-preview" \
-o json
列出所有连接器
az rest -m GET \
--url "https://management.azure.com/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.App/agents/{name}/DataConnectors?api-version=2025-05-01-preview" \
-o json
通过数据平面列出线程
TOKEN=$(az account get-access-token --resource https://azuresre.dev --query accessToken -o tsv)
ENDPOINT="https://{agentEndpoint}"
curl -s -H "Authorization: Bearer $TOKEN" "$ENDPOINT/api/v1/threads"
通过数据平面添加代码存储库
curl -X PUT \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"$ENDPOINT/api/v2/repos/my-repo" \
-d '{
"properties": {
"url": "https://github.com/myorg/myrepo",
"type": "GitHub"
}
}'