Freigeben über


Test agents built using the Microsoft 365 Agents SDK (preview)

[This article is prerelease documentation and is subject to change.]

Once you're finished creating your agent, you need to test the agent to ensure it's working as expected. You can test your agent in several ways.

Debug locally using the Emulator

Before you begin, install the Bot Framework Emulator

To debug locally using the Emulator, perform the following steps:

  1. Run your code and confirm the network port you're using.
  2. Starting with the port number, create the endpoint portion for the URL (for example, :8080 for port 8080).
  3. Append /app/messages to the end of the endpoint URL string (for example, :8080/app/messages/).
  4. Open Bot Framework Emulator and add this URL endpoint into the agent URL: http://localhost:<port number>/api/messages.
  5. Select Connect.

You should now be able to talk to your agent.

Debug locally using dev tunnels

Before you begin, you need:

To debug locally using dev tunnels, perform the following steps:

  1. Open a terminal with access to the devtunnel CLI.
  2. Run devtunnel to create a new tunnel.
  3. Install dev tunnels and obtain a URL from a dev tunnel.
  4. When the tunnel is created, copy and save the public forwarding URL for later.
  5. Make sure your tenant ID and app settings reflect the required settings.
  6. Copy and paste the devtunnel forwarding URL in your app service configuration via Azure.
  7. Run your code without debugging so that it's running.
  8. Select Test in Web Chat.

Your agent should now be operational, and you can have multi-turn conversations.

Deploy to your client (channel)

When you're ready to test your agent on the client channel, you need adapter logic to connect to your client. You can create your own adapter logic using the Agents SDK. However, the Azure Bot Service (ABS) makes this step easy so you don't have to create and maintain code for every channel you want to connect to.

The ABS resource acts as the connector to your client (channel). Because channels can be complex and unique in some scenarios, with their own language, specifications, and connections, ABS simplifies this process. ABS requires a URL, which can be provided in web apps, container apps, or localhost and dev tunnel.

You can speed up the deployment process by deploying using Docker. Throughout the preview, we will add documentation on other ways to test your agent.

Deploy your agent by setting up the following three components:

  1. Create an app registration in Microsoft Entra.
  2. Create an Azure web app for your code.
  3. Create an Azure Bot Service resource in Azure.

Create an app registration

You need to create an app registration that has your app (client) ID and your directory (tenant) ID. The Agents SDK can use various authorization types. The choice depends on your client and functionality of your agent.

The following example uses client secrets with environment variables. You can configure your client secret in your app registration.

Learn more about how to use app registration in Register applications.

Read the Microsoft Authentication Library (MSAL) provider documentation to learn more about other auth types.

Create a web application and publish your code

You can create a web application in Azure in different ways. Learn more in Host a web application with Azure App Service.

You can also publish your code to the web application using various methods, including directly from Visual Studio. Right click your project and select Publish to navigate through the workflow and push your code to your new web app in Azure.

Note

If you're using environment variables, you need to add your environment IDs for the app ID and the app password in your web application. You get these from your app registration in the previous step. You need to update your code to retrieve the environment variable details when running as a web app in Azure. If you are not using environment variables, configure and set up a solution for storing and managing secrets, for example in Azure Key Vault.

Create your Azure Bot Service resource

Create your Azure Bot Service resource in Azure and configure as follows:

  1. Navigate to the Azure portal and create a new Azure Bot Service resource by typing Azure bot and selecting Azure bot from the marketplace.

  2. Ensure your app ID is the same as in the app registration you created previously. Don't select to make a new app ID.

    Your Bot Service resource is automatically created to support web chat.

  3. Add the messaging endpoint under the configuration section to be <your website>/api/messages.

Add other channels

Using the Azure Bot Service resource in created in the previous step, you can configure your agent to work with other channels by selecting the channel and completing the setup for each channel.