- Steps 1 through 4 are the REST equivalent of the one-click Publish to Teams and Microsoft 365 Copilot button in the Foundry portal, and they work for any project.
- Step 5 (firewall and networking) is required only when your project disables public network access (PNA) and runs behind a private endpoint. In that case, the portal button isn’t available because the Microsoft channel adapters that deliver Teams and Copilot messages run outside your network and can’t reach your agent’s private IP address.
Prerequisites
- Access to the Microsoft Foundry portal.
- A Foundry project configured with private networking: the project’s Foundry resource uses a private endpoint, and public network access is disabled.
- An agent in that project that you tested and want to publish. Test the agent thoroughly and select the active version that consumers interact with. For more information, see Configure your agent endpoint and settings.
-
The following role assignments:
- Foundry User role on the Foundry project to create, manage, and publish agents.
- Permission to create an Azure Bot Service resource and configure its channels in the target resource group (for example, the Azure Bot Service Contributor Role, or the broader Contributor or Owner role).
- Permission to manage the firewall, DNS, and reverse proxy that route inbound traffic to your network.
-
Azure CLI installed and signed in with
az loginto the subscription that contains your Foundry resource. -
The
Microsoft.BotServiceresource provider registered in your subscription:
What happens when you publish?
When you publish an agent, Foundry performs the following steps:- Validates the properties you submit, such as the display name, description, and version.
- Compiles a Teams app manifest as a
.zippackage. For more information, see App manifest schema for Microsoft Teams. - Submits the manifest to the Microsoft 365 Copilot and Teams agent catalogs on your behalf.
- Enables the
activityprotocol, which the agent needs to exchange messages with Microsoft 365 and Teams. - Enables an authorization scheme, either
BotServiceRbacorBotServiceTenant, that controls who can call the agent, based on the scope you select.
Who can see and call the agent
The scope you select controls visibility — who can discover the agent in the Microsoft 365 Copilot and Teams stores. Foundry sets the matching authorization scheme, which controls who can call the agent:- Just you (Foundry portal) or
publishScopeset toShared(REST API): EnablesBotServiceRbacand requires no admin approval. The agent appears in the stores only for you. If you add it to a Teams chat, participants who have the required Foundry permissions on the project can use it. - People in your organization (Foundry portal) or
publishScopeset toTenant(REST API): EnablesBotServiceTenantand requires admin approval in the Microsoft 365 admin center. After approval, the agent appears for everyone in your tenant under Built by your org, and anyone in the tenant can discover and use it.
Steps
- Get your agent’s identity and tenant ID.
- Create an Azure Bot Service resource.
- Optionally, enable the activity protocol and add BotServiceRbac or BotServiceTenant as an authorization scheme on the agent. The publish API in the next step also does this automatically.
- Call Foundry’s Microsoft 365 publish API.
- Configure your network for inbound and outbound traffic.
Step 1: Get the agent identity and tenant ID
Before creating the Azure Bot Service resource, collect two values you’ll need in Step 2:- Agent identity principal ID — the agent identity of your Foundry agent
- Tenant ID — your Microsoft Entra ID tenant
1.1 Get a bearer token
The steps authenticate with a bearer token for thehttps://ai.azure.com audience. Get a token once and reuse it:
{{token}} in the requests that follow.
1.2 Get the agent identity principal ID
Get the principal ID by calling the Agents - Get agent API. Your{{endpoint}} is the project endpoint, in the form https://<resource-name>.services.ai.azure.com/api/projects/<project-name>.
instance_identity.principal_id. You use it in the next step when you create the Azure Bot Service resource.
1.3 Get your tenant ID
To get your tenant ID, run the command:Step 2: Create the Azure Bot Service resource
The Azure Bot Service resource proxies messages between the Microsoft channel adapters (Teams and Copilot) and your agent. Create the bot with public network access disabled and connect it to the Microsoft Teams channel. The bot’sendpoint is the agent’s activity protocol endpoint, in this form:
-
Save the following template as
bot-service.bicep: -
Deploy the template to the resource group that contains your Foundry resource:
-
Capture the Azure Bot Service resource ID. You pass it as
botServiceArmIdwhen you publish in Step 4:
Step 3: Enable the activity protocol and Bot Service authorization
This step is optional. The Microsoft 365 publish API in Step 4 automatically adds the
activity protocol and sets the bot-service authorization scheme that matches your publishScope. Complete this step to configure them explicitly, for example to test message delivery before you publish. Choose the scheme that matches the publishScope you use in Step 4, because publishing updates the scheme to match.activity protocol, which lets the channel adapters deliver messages, and a Bot Service authorization scheme, which controls who can call the agent.
Choose one authorization scheme:
The
publishScope value in the publish request (step 4) determines both the agent’s store visibility and its authorization scheme. Tenant maps to BotServiceTenant, and Shared or Personal maps to BotServiceRbac. Publishing sets the matching scheme for you, so the scheme you choose here must match the publishScope you use in step 4.
In the Foundry portal, the Who can use this agent option applies these pairings: Just you applies BotServiceRbac with Shared visibility, and People in your organization applies BotServiceTenant with Tenant visibility. For more information, see Publish agents to Microsoft 365 Copilot and Microsoft Teams.
Keep
responses and Entra in the lists as well — removing them will break chatting with the agent from the Foundry portal or SDK.activity and BotServiceRbac to the agent’s existing schemes:
Step 4: Publish the agent to Microsoft 365
Publish the agent by calling the Microsoft 365 publish API with the{{token}} from the first step. Replace the placeholders using these values:
The agent name is part of the request URL. The service resolves the agent and its identity from that name, so you no longer pass the agent GUID or bot ID in the request body.
agentDisplayName: the display name shown in Teams and Microsoft 365 Copilot. Optional; when omitted, the agent name is used.botServiceArmId: the ARM resource ID of the Azure Bot Service resource you created in Step 2. Required.publishScope:Shared(the portal’s Just you) makes the agent available only to you. It appears under Your agents in the agent store, and you share it with a link.Tenant(the portal’s People in your organization) submits the agent for Microsoft 365 admin approval and, once approved, makes it available to your whole organization under Built by your org.Personalis also accepted and treated asShared.appVersion: a semantic version string such as1.0.0. Increment it to update the user-facing properties; republishing an existing version returns aversion already existserror. To roll out a new agent version, update the agent version receiving traffic instead.shortDescriptionandfullDescription: descriptions shown in the agent store.developerName,developerWebsiteUrl,privacyUrl, andtermsOfUseUrl: developer metadata shown to users.publishAsAutopilot: set tofalse. To publish as an autopilot agent, see Foundry agents in Microsoft Agent 365.canRespondWithoutMention,colorIconBase64, andoutlineIconBase64: optional. Control whether an autopilot responds to all messages on its Teams surfaces or only when @mentioned, and set custom color (192×192 PNG) and outline (32×32 PNG) app icons.
titleId). The agent isn’t reachable from Teams or Copilot until you configure networking in step 5.
Step 5: Configure networking and secure inbound traffic
After publishing your agent to Microsoft 365, you need to ensure that Microsoft’s Bot Channel Adapters can reach your agent’s messaging endpoint. Because your agent is deployed behind a private endpoint, it isn’t directly reachable from the public internet. This section covers the inbound network path you need to establish, and the security controls available to you at each layer.Understanding the inbound traffic flow
When a user sends a message in Teams or Microsoft 365 Copilot, Microsoft’s Bot Channel Adapter POSTs the message to your agent’s messaging endpoint. Because your agent’s endpoint resolves to a private IP address inside your network, two things need to be true before traffic can reach it:- A publicly reachable entry point — something in your architecture must be accessible from the public internet on an endpoint you control, and able to route traffic inward.
- TLS termination and proxying — something in your architecture must terminate TLS and forward the request on to your agent’s private endpoint.
5.1 Inbound network requirements
- A publicly reachable entry point: You need at least one component in your architecture with a public-facing IP that you control, capable of routing inbound traffic toward your private network. This might be a firewall, load balancer, CDN, or other network appliance, depending on your organization’s existing architecture.
- TLS termination: Something in your architecture must terminate TLS and present a valid certificate for the hostname the Bot Channel Adapter is connecting to. This might be a component you manage directly, or one provided by your platform. For example, Azure Application Gateway can present a certificate against a public IP without requiring you to supply your own. If your public entry point doesn’t terminate TLS, you need a component behind it that does.
- Source IP ranges: Microsoft publishes the IP ranges used by the Bot Channel Adapters as part of the Microsoft 365 URLs and IP address ranges. Restricting inbound traffic to these ranges reduces your attack surface at the network perimeter before any application-layer controls are applied.
5.2 Authenticating inbound requests
Establishing a network path is necessary but not sufficient. Every request from the Bot Channel Adapter includes a signed JWT in theAuthorization header. Foundry validates this token on your behalf and also authorizes the end user. In most cases, no additional configuration is required.
However, if your network security requirements mean that traffic must be authenticated before it crosses a security boundary — for example before it reaches Foundry — you can perform JWT validation at your TLS-terminating component independently. The full authentication specification is documented in Bot Framework REST API authentication.
5.3 Validate the caller’s tenant as a lighter-weight alternative
Validating the JWT is the strongest control, but it requires a component that can verify a signed token. If you don’t have infrastructure that can validate a JWT, you can still reduce risk with two simpler checks at your inbound component:- Restrict the source IP ranges to the Teams Required ranges (see Source IP ranges in 5.1), so that only the Bot Channel Adapter can reach your entry point.
- Validate the caller’s tenant ID. The Bot Channel Adapter includes the caller’s tenant ID in the
x-tenant-idheader. Reject any request whose tenant ID isn’t your own.
Verify the published agent
- In Microsoft 365 Copilot or Microsoft Teams, open the agent store and find your agent. With
Sharedscope, it appears under Your agents. WithTenantscope, it appears under Built by your org after a Microsoft 365 admin approves it in the Microsoft 365 admin center. - Start a conversation and send a message.
- Confirm the agent replies. A reply confirms that both the inbound path (channel adapter to agent) and the outbound path (agent reply to the channel) work.
Limitations
Troubleshooting
After you publish, problems generally fall into three types: an error while publishing, not finding the agent in the agent store, or an error when you chat with the agent.Publishing issues
These errors occur when you publish through the Microsoft 365 publish API.
The following issues are specific to publishing behind a virtual network:
Find your published agent
If you can’t find your agent in the Microsoft 365 Copilot or Microsoft Teams agent store, use the following table.Runtime issues
Use the following table for errors when you chat with a published agent in Microsoft 365 Copilot or Microsoft Teams.End users don’t need a Microsoft 365 Copilot license to use a published agent in Microsoft 365 Copilot Chat. Without a Copilot license, usage that accesses shared tenant data, such as SharePoint or Copilot connectors, might incur usage-based charges. For more information, see Licensing and cost considerations for Copilot extensibility.
Reset a conversation
If a published agent stops responding, or returns an error such asno tool output found, the conversation can enter a state where later messages keep failing. To recover, start a fresh conversation with the agent:
- Microsoft 365 Copilot: Start a new chat with the agent.
- Microsoft Teams: Teams doesn’t yet provide a way to start a new session, so send the agent the message
/foundry_new_previewto reset the conversation.