API reference for Azure SRE Agent

REST API 操作用於程式化管理與互動 Azure SRE 代理。

概觀

Azure SRE 代理提供兩層的 REST API。 使用 控制平面(ARM) 來建立、設定及刪除代理及其子資源。 使用 資料平面 進行執行時操作,如聊天、管理和知識上傳。

飛機 基底 URL Auth 用途
控制平面 management.azure.com Standard 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"

Note

代理端點是每個代理唯一的。 它遵循模式 https://{name}--{id}.{hash}.{region}.azuresre.ai ,ARM GET 操作會回傳此端點於 properties.agentEndpoint

RBAC 角色

角色 說明 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

Note

控制平面與資料平面 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 GET (無)
Delete DELETE (無)
開始 POST /start
停止 POST /stop
取得使用量 GET /usages
取得每日使用量 GET /dailyusages

代理人性質

房產 類型 說明
provisioningState 字串 SucceededFailed, , InProgressCanceled, ( Deleting 唯讀)
agentEndpoint 字串 資料平面 URL(唯讀)
powerState 字串 RunningStopped (唯讀)
outboundIpAddresses string[] 允許清單的外發 IP(唯讀)
actionConfiguration.mode 字串 ReviewAutomaticReadOnly
actionConfiguration.accessLevel 字串 LowHigh
defaultModel.provider 字串 AnthropicMicrosoftFoundry(開放 AI)
defaultModel.name 字串 型號名稱(例如, Automatic
upgradeChannel 字串 StablePreview
monthlyAgentUnitLimit number 每月主動流量AAU上限(不包含持續開啟的流量)
knowledgeGraphConfiguration.identity 字串 受管理身份資源識別碼
knowledgeGraphConfiguration.managedResources string[] 代理可存取的資源群組 ID
logConfiguration 物件 Application Insights 組態
incidentManagementConfiguration.type 字串 PagerDutyAzMonitorServiceNowNone
mcpServers string[] MCP 伺服器網址
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 (建立/更新) GETDELETE 操作。

子資源體格式

連接器 使用直接性質:

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 Data Explorer Kusto 查詢 ADX 叢集
Application Insights Kusto 查詢應用程式洞察
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/...開頭。

討論串與聊天室

方法 路徑 說明
GET /api/v1/threads 列表對話串
GET /api/v1/threads/{threadId} 找一個特定的討論串
POST /api/v1/threads/{threadId}/messages 發送訊息(開始對話)
GET /api/v1/threads/{threadId}/messages 在討論串中取得訊息

核准

方法 路徑 說明
GET /api/v1/approvals/{threadId} 待審核清單
POST /api/v1/approvals/{threadId}/{id}/decision 批准或拒絕一項行動

程式碼儲存庫

方法 路徑 說明
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 測試倉庫連接性

知識(代理記憶)

方法 路徑 說明
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 觸發程序

方法 路徑 說明
POST /api/v1/httptriggers/create 建立 HTTP 觸發器
GET /api/v1/httptriggers 列表觸發條件
POST /api/v1/httptriggers/{triggerId}/execute 執行觸發器
POST /api/v1/httptriggers/trigger/{triggerId} 公開 webhook 端點(無需驗證)

勾點

方法 路徑 說明
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}

所有資源都支援 PUTGETPATCHDELETE 方法。

即時串流

該代理使用 SignalR 進行即時聊天串流:

樞紐 路徑 用途
AgentHub /agentHub 即時訊息串流與線程更新

使用相同持有持有標記的 SignalR 用戶端函式庫連接。

Examples

取得經紀人物業

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"
    }
  }'