Microsoft Foundry托管Agent网络排错:五步检查超时
Hosted agents in your own virtual network: five checks when the Agents page times out
Over the last few weeks I have worked with several teams moving hosted agents into their own virtual network. Different industries, same five questions. This post answers each one with the commands I use to check it.
过去几周,我与多个团队合作,将托管代理迁移到他们自己的虚拟网络中。不同行业,同样的五个问题。本文使用我用来检查的命令逐一回答这些问题。
Picture a financial services team running claims agents in a locked-down network. Public access on the Foundry resource is off. The agent subnet sits in a spoke VNet. Azure Cosmos DB, Storage and Azure AI Search sit behind private endpoints, some of them in a hub VNet. All outbound traffic goes through a firewall that inspects TLS. The deployment succeeds. Then the Agents page spins and fails with a timeout.
想象一个金融服务团队在受限网络中运行索赔代理。Foundry 资源的公共访问已关闭。代理子网位于 spoke VNet 中。Azure Cosmos DB、Storage 和 Azure AI Search 位于私有端点之后,其中一些位于 hub VNet 中。所有出站流量都通过检查 TLS 的防火墙。部署成功。然后 Agents 页面旋转并因超时而失败。
Nothing is wrong with the agent. The network around it is missing one piece. Here is how to find it.
代理本身没有问题。它周围的网络缺少一部分。以下是查找方法。
Start with what runs in your agent subnet
从代理子网中运行的内容开始
When you bring your own VNet, the delegated agent subnet is where the agent infrastructure runs: the micro VMs that run hosted agent sessions, and a single-tenant data proxy for each project. Tool calls go through that data proxy, and its outbound traffic reaches your storage, databases and Key Vault through private endpoints. The platform also signs in to Microsoft Entra ID with managed identity from that subnet before it calls your resources.
当你引入自己的 VNet 时,委托的代理子网是代理基础设施运行的地方:运行托管代理会话的微虚拟机,以及每个项目的单租户数据代理。工具调用通过该数据代理进行,其出站流量通过私有端点到达你的存储、数据库和 Key Vault。平台还会从该子网使用托管身份登录 Microsoft Entra ID,然后再调用你的资源。
So every check below asks one question: can the agent subnet resolve and reach what it needs?
因此,下面的每个检查都问一个问题:代理子网能否解析并访问它所需的内容?
1. Find the subnet that matters
1. 找到相关的子网
Teams that set up networking in the portal are often not sure which subnet became the agent subnet. Ask the Foundry account:
在门户中设置网络的团队通常不确定哪个子网成为了代理子网。询问 Foundry 账户:
az cognitiveservices account show \
--name my-foundry --resource-group <rg> \
--query "properties.networkInjections"[
{
"scenario": "agent",
"subnetArmId": "/subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Network/virtualNetworks/<vnet>/subnets/agent-subnet",
"useMicrosoftManagedNetwork": false
}
]Then look at that subnet:
然后查看该子网:
az network vnet subnet show \
--resource-group <rg> --vnet-name <vnet> --name agent-subnet \
--query "{prefix:addressPrefix, delegations:delegations[].serviceName, links:serviceAssociationLinks[].name, routeTable:routeTable.id}"{
"delegations": [ "Microsoft.App/environments" ],
"links": [ "legionservicelink" ],
"prefix": "10.0.4.0/24",
"routeTable": null
}What good looks like:
理想状态如下:
- The subnet is delegated to Microsoft.App/environments.
- It is /27 or larger. Use /24 or larger for production.
- It uses an RFC 1918 range: 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Every region where Agent Service is available supports 10.0.0.0/8.
- Its range does not overlap any peered VNet.
- It belongs to one Foundry resource only. Several Foundry resources can share a VNet, but each one needs its own agent subnet.
- The legionservicelink service association link means the agent environment is using the subnet. You will meet it again in check 5.
- 子网已委托给 Microsoft.App/environments。
- 它是 /27 或更大。生产环境请使用 /24 或更大。
- 它使用 RFC 1918 范围:10.0.0.0/8、172.16.0.0/12 或 192.168.0.0/16。Agent Service 可用的每个区域都支持 10.0.0.0/8。
- 其范围不与任何对等 VNet 重叠。
- 它仅属于一个 Foundry 资源。多个 Foundry 资源可以共享一个 VNet,但每个资源都需要自己的代理子网。
- legionservicelink 服务关联链接表示代理环境正在使用该子网。你将在检查 5 中再次遇到它。
One more thing to get right on day one: for hosted agents, network injection has to be part of the Foundry account when you first create it. You cannot add it to an existing account later.
第一天还需要做对的一件事:对于托管代理,网络注入必须在你首次创建 Foundry 账户时就成为其一部分。你无法稍后将其添加到现有账户中。
2. "Listing agents timed out" means the data proxy cannot read your Cosmos DB
2. “列出代理超时”意味着数据代理无法读取你的 Cosmos DB
This is the error I see most:
这是我看到最多的错误:
Listing agents timed out after 8s while reading the agent index. This usually indicates the project's bring-your-own Cosmos DB endpoint is unreachable or misconfigured.It comes back as 400 invalid_configuration, because the cause sits in your network or Cosmos DB setup, not in the service. In the portal, the same problem can show up as Timeout of 60000ms exceeded on the Agent pages.
返回结果为 400 invalid_configuration,因为问题出在你的网络或 Cosmos DB 设置上,而不是服务本身。在门户中,相同的问题可能会在 Agent 页面上显示为 Timeout of 60000ms exceeded(超时 60000 毫秒已超出)。
The data proxy in your agent subnet could not reach your Cosmos DB account in time. The two causes I see most are DNS and the Entra sign-in in check 3. Start with DNS.
你代理子网中的数据代理无法及时访问你的 Cosmos DB 账户。我看到的两个最常见原因是 DNS 和检查项 3 中的 Entra 登录。先从 DNS 开始排查。
First, confirm the Cosmos DB private endpoint exists and is approved. Look for the Sql group:
首先,确认 Cosmos DB 专用终结点存在且已获批准。查找 Sql 组:
az network private-endpoint list --resource-group <rg> \
--query "[].{name:name, group:privateLinkServiceConnections[0].groupIds[0], status:privateLinkServiceConnections[0].privateLinkServiceConnectionState.status}" \
-o tableNext, check that the privatelink.documents.azure.com zone is linked to the VNet that contains the agent subnet. A private DNS zone only answers for VNets that are linked to it.
接下来,检查 privatelink.documents.azure.com 区域是否链接到包含代理子网的 VNet。专用 DNS 区域仅对链接到它的 VNet 进行响应。
az network private-dns link vnet list --resource-group <dns-rg> \
--zone-name privatelink.documents.azure.com \
--query "[].{name:name, vnet:virtualNetwork.id, state:virtualNetworkLinkState}" -o tableThen check the records. You should see one for the account and one for each region it runs in:
然后检查记录。你应该看到一条针对该账户的记录,以及每条运行区域各一条记录:
az network private-dns record-set a list --resource-group <dns-rg> \
--zone-name privatelink.documents.azure.com \
--query "[].{name:name, ip:aRecords[0].ipv4Address}" -o tableName Ip
----------------- ---------
my-cosmos 10.0.5.9
my-cosmos-westus3 10.0.5.10If your VNet uses custom DNS servers instead of Azure DNS, make sure they forward these zones to the Azure DNS virtual server at 168.63.129.16 from a VNet that is linked to the zones. DNS servers on premises cannot reach that address, so point them at a DNS forwarder or Azure DNS Private Resolver in Azure instead. Last, from a VM in the same VNet, run nslookup <account>.documents.azure.com and confirm it returns your Cosmos DB private endpoint's IP, not just any private IP.
如果你的 VNet 使用自定义 DNS 服务器而不是 Azure DNS,请确保它们将这些区域转发给链接到这些区域的 VNet 中的 Azure DNS 虚拟服务器 168.63.129.16。本地 DNS 服务器无法访问该地址,因此请将它们指向 Azure 中的 DNS 转发器或 Azure DNS Private Resolver。最后,从同一 VNet 中的一台 VM 运行 nslookup <account>.documents.azure.com,并确认它返回的是你的 Cosmos DB 专用终结点的 IP,而不仅仅是任何私有 IP。
The same fix applies when Key Vault or Application Insights resolve to public IPs from your VNet. Key Vault needs the privatelink.vaultcore.azure.net zone. Application Insights goes through an Azure Monitor Private Link Scope, which has its own private DNS zones. In each case the zone has to exist, hold the records and be linked to the agent VNet.
当 Key Vault 或 Application Insights 从你的 VNet 解析为公共 IP 时,同样的修复方法适用。Key Vault 需要 privatelink.vaultcore.azure.net 区域。Application Insights 通过 Azure Monitor Private Link Scope 进行,后者拥有自己的专用 DNS 区域。在每种情况下,该区域必须存在、包含记录并链接到代理 VNet。
3. Your private CA does not cover the platform's Entra sign-in
3. 你的私有 CA 未覆盖平台的 Entra 登录
Teams with a firewall that decrypts and re-signs TLS often register the firewall's CA with private CA trust (public preview) and expect the timeouts to stop. They do not, and that is expected. From the docs:
拥有解密并重签名 TLS 的防火墙的团队通常会将防火墙的 CA 注册到私有 CA 信任(公共预览版),并期望超时停止。但情况并非如此,这是预期的行为。根据文档:
Private CA trust doesn't apply to the platform's own Microsoft Entra ID and managed identity traffic from the agent subnet. If a firewall TLS-inspects that traffic, agent operations such as listing agents or conversations can fail or time out, even after you add the firewall's CA.
私有 CA 信任不适用于平台自身的 Microsoft Entra ID 以及来自代理子网的托管身份流量。如果防火墙对该流量进行 TLS 检查,即使你添加了防火墙的 CA,代理操作(如列出代理或对话)仍可能失败或超时。
When I reproduced this in a test subscription, with the agent subnet's Entra traffic routed through a decrypting proxy, registering the proxy's CA made no difference. A no-decrypt rule for the Entra hosts fixed it.
当我在测试订阅中重现此问题时,将代理子网的 Entra 流量路由到解密代理后,注册该代理的 CA 没有任何区别。为 Entra 主机设置无解密规则解决了这个问题。
The fix has two parts:
修复方法分为两部分:
- Exclude login.microsoftonline.com, {region}.login.microsoft.com and control-{region}.identity.azure.net from TLS inspection.
- Allow those hosts on the firewall, plus the managed identity FQDNs from the Azure Container Apps firewall guidance or the AzureActiveDirectory service tag. If you put an NSG on the agent subnet, add a matching outbound rule for the AzureActiveDirectory service tag.
- 将 login.microsoftonline.com、{region}.login.microsoft.com 和 control-{region}.identity.azure.net 排除在 TLS 检查之外。
- 在防火墙中允许这些主机,以及来自 Azure Container Apps 防火墙指南或 AzureActiveDirectory 服务标签的托管标识 FQDN。如果在代理子网上放置了 NSG,请为 AzureActiveDirectory 服务标签添加匹配的出站规则。
Keep private CA trust on for what it is built for: letting tools, model gateways and your own agent code call internal services that use your company's certificates, with certificate checks still on. I covered that in the hosted agents Ignite 2026 post.
保持私有 CA 信任开启,以发挥其设计用途:允许工具、模型网关和自有代理代码调用使用公司证书的内部服务,同时仍启用证书检查。我在 Ignite 2026 托管代理文章中对此进行了介绍。
4. Resources in a peered hub VNet work, but DNS follows the agent subnet
4. 对等连接中心 VNet 中的资源可以正常工作,但 DNS 遵循代理子网
Can Cosmos DB, Storage or Search sit in a peered VNet? Yes. The docs say peered virtual networks are supported, and note that data transfer costs can increase.
Cosmos DB、存储或搜索服务能否位于对等连接的 VNet 中?可以。文档说明支持对等虚拟网络,并指出数据传输成本可能会增加。
Do you need a route table on the agent subnet for peering? No. When you peer two VNets, Azure adds a system route for each address range of the other VNet. Add a route table only if your design sends traffic through a firewall. If it does, check two things: that your user-defined routes do not override the peering routes to your private endpoints by mistake, and that the firewall allows the Entra hosts from check 3.
是否需要在代理子网上配置路由表以实现对等连接?不需要。当你对两个 VNet 进行对等连接时,Azure 会为另一个 VNet 的每个地址范围添加系统路由。仅当你的设计将流量通过防火墙时才需要添加路由表。如果确实如此,请检查两点:确保用户定义的路由没有意外覆盖指向你私有端点的对等连接路由,并确保防火墙允许来自第 3 步检查的 Entra 主机。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力