From b0501eae45de5dcf6e0f3008829ee52d1220715b Mon Sep 17 00:00:00 2001 From: Vikram Singh Date: Wed, 18 Mar 2026 16:37:25 +0530 Subject: [PATCH 1/6] Upgrade .Net target and Remove Obsolete BotFramework Adapter. --- .../relay-bot/AdapterWithErrorHandler.cs | 8 +++--- .../agents-sdk/relay-bot/SampleBot.csproj | 8 +++--- extensibility/agents-sdk/relay-bot/Startup.cs | 26 +++++++++++++------ .../agents-sdk/relay-bot/appsettings.json | 4 +++ 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/extensibility/agents-sdk/relay-bot/AdapterWithErrorHandler.cs b/extensibility/agents-sdk/relay-bot/AdapterWithErrorHandler.cs index 57a27b15..f9741868 100644 --- a/extensibility/agents-sdk/relay-bot/AdapterWithErrorHandler.cs +++ b/extensibility/agents-sdk/relay-bot/AdapterWithErrorHandler.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Extensions.Configuration; +using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.Logging; namespace Microsoft.PowerVirtualAgents.Samples.RelayBotSample { - public class AdapterWithErrorHandler : BotFrameworkHttpAdapter + public class AdapterWithErrorHandler : CloudAdapter { - public AdapterWithErrorHandler(IConfiguration configuration, ILogger logger) - : base(configuration, logger) + public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger logger) + : base(auth, logger) { OnTurnError = async (turnContext, exception) => { diff --git a/extensibility/agents-sdk/relay-bot/SampleBot.csproj b/extensibility/agents-sdk/relay-bot/SampleBot.csproj index cefada66..77e347d6 100644 --- a/extensibility/agents-sdk/relay-bot/SampleBot.csproj +++ b/extensibility/agents-sdk/relay-bot/SampleBot.csproj @@ -1,14 +1,14 @@ - netcoreapp2.1 + net10.0 latest - - - + + + diff --git a/extensibility/agents-sdk/relay-bot/Startup.cs b/extensibility/agents-sdk/relay-bot/Startup.cs index c23b24c0..d61b993f 100644 --- a/extensibility/agents-sdk/relay-bot/Startup.cs +++ b/extensibility/agents-sdk/relay-bot/Startup.cs @@ -3,11 +3,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.PowerVirtualAgents.Samples.RelayBotSample.Bots; namespace Microsoft.PowerVirtualAgents.Samples.RelayBotSample @@ -24,9 +24,15 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddHttpClient(); + services.AddControllers() + .AddNewtonsoftJson(options => + { + options.SerializerSettings.MaxDepth = HttpHelper.BotMessageSerializerSettings.MaxDepth; + }); - // Create the Bot Framework Adapter with error handling enabled. + + // Create the Bot Adapter with error handling enabled. services.AddSingleton(); // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. @@ -44,7 +50,7 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { @@ -55,10 +61,14 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseHsts(); } - app.UseDefaultFiles(); - app.UseStaticFiles(); - - app.UseMvc(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseWebSockets() + .UseRouting() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } } } diff --git a/extensibility/agents-sdk/relay-bot/appsettings.json b/extensibility/agents-sdk/relay-bot/appsettings.json index 5d1da922..7b78987e 100644 --- a/extensibility/agents-sdk/relay-bot/appsettings.json +++ b/extensibility/agents-sdk/relay-bot/appsettings.json @@ -1,6 +1,10 @@ { + // Configuration for Azure bot service + "MicrosoftAppType": "", "MicrosoftAppId": "", "MicrosoftAppPassword": "", + + // Configuration for MCS Bot "BotService": { "BotName": "", "BotId": "", From 4da16390709e865e5385435db38f229250d62507 Mon Sep 17 00:00:00 2001 From: Vikram Singh Date: Thu, 19 Mar 2026 11:14:51 +0530 Subject: [PATCH 2/6] update newtonsoft version --- extensibility/agents-sdk/relay-bot/SampleBot.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensibility/agents-sdk/relay-bot/SampleBot.csproj b/extensibility/agents-sdk/relay-bot/SampleBot.csproj index 77e347d6..41a17caf 100644 --- a/extensibility/agents-sdk/relay-bot/SampleBot.csproj +++ b/extensibility/agents-sdk/relay-bot/SampleBot.csproj @@ -6,7 +6,7 @@ - + From dca1bf1abaa96f4296674e31d2242abd69ab7c37 Mon Sep 17 00:00:00 2001 From: Vikram Singh Date: Thu, 19 Mar 2026 11:16:28 +0530 Subject: [PATCH 3/6] add missing tenant property in appsettings.json --- extensibility/agents-sdk/relay-bot/appsettings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/extensibility/agents-sdk/relay-bot/appsettings.json b/extensibility/agents-sdk/relay-bot/appsettings.json index 7b78987e..d366a013 100644 --- a/extensibility/agents-sdk/relay-bot/appsettings.json +++ b/extensibility/agents-sdk/relay-bot/appsettings.json @@ -3,6 +3,7 @@ "MicrosoftAppType": "", "MicrosoftAppId": "", "MicrosoftAppPassword": "", + "MicrosoftAppTenantId": "", // Configuration for MCS Bot "BotService": { From 2ac34b0dd270ce0f92298ebd303a653ad06a4253 Mon Sep 17 00:00:00 2001 From: Vikram Singh Date: Thu, 19 Mar 2026 12:00:58 +0530 Subject: [PATCH 4/6] upgrade the program file with top level statements. --- extensibility/agents-sdk/relay-bot/Program.cs | 72 ++++++++++++++---- extensibility/agents-sdk/relay-bot/Startup.cs | 74 ------------------- 2 files changed, 57 insertions(+), 89 deletions(-) delete mode 100644 extensibility/agents-sdk/relay-bot/Startup.cs diff --git a/extensibility/agents-sdk/relay-bot/Program.cs b/extensibility/agents-sdk/relay-bot/Program.cs index 5ed15a40..17ddf2a8 100644 --- a/extensibility/agents-sdk/relay-bot/Program.cs +++ b/extensibility/agents-sdk/relay-bot/Program.cs @@ -1,20 +1,62 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.Bot.Builder; +using Microsoft.Bot.Builder.Integration.AspNet.Core; +using Microsoft.Bot.Connector.Authentication; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.PowerVirtualAgents.Samples.RelayBotSample; +using Microsoft.PowerVirtualAgents.Samples.RelayBotSample.Bots; -namespace Microsoft.PowerVirtualAgents.Samples.RelayBotSample -{ - public class Program +var builder = WebApplication.CreateBuilder(args); + +//---- Configure services ---- +builder.Services.AddHttpClient(); +builder.Services.AddControllers() + .AddNewtonsoftJson(options => { - public static void Main(string[] args) - { - CreateWebHostBuilder(args).Build().Run(); - } - - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup(); - } + options.SerializerSettings.MaxDepth = HttpHelper.BotMessageSerializerSettings.MaxDepth; + }); + + +builder.Services.AddSingleton(); + +// Create the Bot Adapter with error handling enabled. +builder.Services.AddSingleton(); + +// Create the bot as a transient. In this case the ASP Controller is expecting an IBot. +builder.Services.AddSingleton(); + +// Create the singleton instance of BotService from appsettings +var botService = new BotService(); +builder.Configuration.Bind("BotService", (object)botService); +builder.Services.AddSingleton(botService); + +// Create the singleton instance of ConversationPool from appsettings +var conversationManager = new ConversationManager(); +builder.Configuration.Bind("ConversationPool", conversationManager); +builder.Services.AddSingleton(conversationManager); + +var app = builder.Build(); + +//--- - Configure the HTTP request pipeline ---- +if (app.Environment.IsDevelopment()) +{ + app.UseDeveloperExceptionPage(); +} +else +{ + app.UseHsts(); } + +app.UseDefaultFiles() + .UseStaticFiles() + .UseWebSockets() + .UseRouting(); + +app.MapControllers(); + +app.Run(); diff --git a/extensibility/agents-sdk/relay-bot/Startup.cs b/extensibility/agents-sdk/relay-bot/Startup.cs deleted file mode 100644 index d61b993f..00000000 --- a/extensibility/agents-sdk/relay-bot/Startup.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.PowerVirtualAgents.Samples.RelayBotSample.Bots; - -namespace Microsoft.PowerVirtualAgents.Samples.RelayBotSample -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddHttpClient(); - services.AddControllers() - .AddNewtonsoftJson(options => - { - options.SerializerSettings.MaxDepth = HttpHelper.BotMessageSerializerSettings.MaxDepth; - }); - - - // Create the Bot Adapter with error handling enabled. - services.AddSingleton(); - - // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. - services.AddSingleton(); - - // Create the singleton instance of BotService from appsettings - var botService = new BotService(); - Configuration.Bind("BotService", (object)botService); - services.AddSingleton(botService); - - // Create the singleton instance of ConversationPool from appsettings - var conversationManager = new ConversationManager(); - Configuration.Bind("ConversationPool", conversationManager); - services.AddSingleton(conversationManager); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseHsts(); - } - - app.UseDefaultFiles() - .UseStaticFiles() - .UseWebSockets() - .UseRouting() - .UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} From 810d572b63eea051f9ee899fa41bdd239134423c Mon Sep 17 00:00:00 2001 From: Vikram Singh Date: Thu, 19 Mar 2026 12:16:18 +0530 Subject: [PATCH 5/6] update README.md for .net 10 --- extensibility/agents-sdk/relay-bot/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensibility/agents-sdk/relay-bot/README.md b/extensibility/agents-sdk/relay-bot/README.md index 69641a2c..8ed4996b 100644 --- a/extensibility/agents-sdk/relay-bot/README.md +++ b/extensibility/agents-sdk/relay-bot/README.md @@ -18,7 +18,7 @@ This bot has been created based on [Bot Framework](https://dev.botframework.com) ## Prerequisites -- [.NET Core SDK](https://dotnet.microsoft.com/download) version 2.1 +- [.NET SDK](https://dotnet.microsoft.com/download) version 10.0 ```bash # determine dotnet version @@ -30,10 +30,10 @@ This bot has been created based on [Bot Framework](https://dev.botframework.com) - Clone the repository ```bash - git clone https://github.com/microsoft/PowerVirtualAgentsSample.git + git clone https://github.com/microsoft/CopilotStudioSamples.git ``` -- In a terminal, navigate to `BYOBSample/` +- In a terminal, navigate to `extensibility/agents-sdk/relay-bot` - Update file appsettings.json with your Power Virtual Agent bot id, tenant id, bot name and other settings. To retrieve your bot's bot ID and tenant ID, click on left side pane's ***Manage***, click ***Channels*** and click on the Azure Bot Service channel that you need to connect to. @@ -54,7 +54,7 @@ This bot has been created based on [Bot Framework](https://dev.botframework.com) - Launch Visual Studio - File -> Open -> Project/Solution - - Navigate to `BYOBSample/` folder + - Navigate to `extensibility/agents-sdk/relay-bot` folder - Select `SampleBot.csproj` file - Press `F5` to run the project From a638c3ac37418d089ffb2e9f5b4b0772f1ea961b Mon Sep 17 00:00:00 2001 From: adilei Date: Thu, 19 Mar 2026 12:20:40 +0200 Subject: [PATCH 6/6] Update deprecated notice: clarify archived Bot Framework SDK, fix Copilot Studio naming Co-Authored-By: Claude Opus 4.6 (1M context) --- extensibility/agents-sdk/relay-bot/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensibility/agents-sdk/relay-bot/README.md b/extensibility/agents-sdk/relay-bot/README.md index 8ed4996b..a1092559 100644 --- a/extensibility/agents-sdk/relay-bot/README.md +++ b/extensibility/agents-sdk/relay-bot/README.md @@ -10,11 +10,11 @@ Deprecated {: .label .label-red } {: .caution } -> This sample is deprecated and will be replaced with a modernized M365 Agents SDK sample. +> This sample uses the archived Bot Framework SDK (`Microsoft.Bot.Builder`). It will be replaced with an M365 Agents SDK implementation. -Sample of connecting Bot Framework v4 bot to a Power Virtual Agent bot. +Sample of connecting an Azure Bot Service bot to a Copilot Studio agent using the Direct Line API. -This bot has been created based on [Bot Framework](https://dev.botframework.com), it shows how to create an Azure Bot Service bot that connects to Power Virtual Agents bot +This bot has been created based on [Bot Framework](https://dev.botframework.com), it shows how to create an Azure Bot Service bot that connects to a Copilot Studio agent ## Prerequisites