Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Composer/plugins/runtimes/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export default async (composer: any): Promise<void> => {
let csproj = '';
// find publishing profile in list
const profile = project.settings.publishTargets.find((p) => p.name === profileName);
if (profile.type === 'plugin-azure-publish') {
if (profile.type === 'azurePublish') {
csproj = 'Microsoft.BotFramework.Composer.WebApp.csproj';
} else if (profile.type === 'plugin-azure-functions-publish') {
} else if (profile.type === 'azureFunctionsPublish') {
csproj = 'Microsoft.BotFramework.Composer.Functions.csproj';
}
const publishFolder = path.join(runtimePath, 'bin', 'Release', 'netcoreapp3.1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
</None>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.Deployment.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
11 changes: 4 additions & 7 deletions runtime/dotnet/azurefunctions/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,16 @@ private IConfigurationRoot BuildConfiguration(string rootDirectory)
var config = new ConfigurationBuilder();

// Config precedence 1: root app.settings
config
.SetBasePath(rootDirectory)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.UseLuisConfigAdapter()
.UseLuisSettings();
config.SetBasePath(rootDirectory);
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

// Config precedence 2: ComposerDialogs/settings settings which are injected by the composer publish
// Hard code the settings path to 'ComposerDialogs' for deployment

var configFile = Path.GetFullPath(Path.Combine(rootDirectory, @"ComposerDialogs/settings/appsettings.json"));
config.AddJsonFile(configFile, optional: true, reloadOnChange: true);

// Config Precedence 3: Deployment specific config
config.AddJsonFile("appsettings.deployment.json", optional: true, reloadOnChange: true);
config.UseComposerLuisSettings();

if (!Debugger.IsAttached)
{
Expand Down
4 changes: 0 additions & 4 deletions runtime/dotnet/azurefunctions/appsettings.Deployment.json

This file was deleted.

4 changes: 0 additions & 4 deletions runtime/dotnet/azurefunctions/appsettings.Development.json

This file was deleted.

23 changes: 0 additions & 23 deletions runtime/dotnet/azurefunctions/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,2 @@
{
"feature": {
"UseShowTypingMiddleware": false,
"UseInspectionMiddleware": false,
"RemoveRecipientMention": false
},
"microsoftAppId": "",
"cosmosDb": {
"authKey": "",
"collectionId": "botstate-collection",
"cosmosDBEndpoint": "",
"databaseId": "botstate-db"
},
"applicationInsights": {
"InstrumentationKey": ""
},
"telemetry": {
"logPersonalInformation": false,
"logActivities": true
},
"blobStorage": {
"connectionString": "",
"container": "transcripts"
}
}
26 changes: 5 additions & 21 deletions runtime/dotnet/azurewebapp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Bot.Builder.AI.Luis;
using Microsoft.BotFramework.Composer.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
Expand All @@ -27,31 +22,20 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
{
var env = hostingContext.HostingEnvironment;

builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

if (env.IsDevelopment())
{
// Local Debug
builder.AddJsonFile("appsettings.development.json", optional: true, reloadOnChange: true);
}
// Use Composer bot path adapter
builder.UseBotPathConverter(env.IsDevelopment());

var configuration = builder.Build();
builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

// Hard code the settings path to 'ComposerDialogs' while deployment
var botRoot = configuration.GetValue<string>("bot") ?? "ComposerDialogs";
var configFile = Path.GetFullPath(Path.Combine(botRoot, @"settings/appsettings.json"));

builder.AddJsonFile(configFile, optional: true, reloadOnChange: true);

// Need to put this part here to override the any customized settings
if (!env.IsDevelopment())
{
//Azure Deploy
builder.AddJsonFile("appsettings.deployment.json", optional: true, reloadOnChange: true);
}

builder.UseLuisConfigAdapter()
.UseLuisSettings();
// Use Composer luis settings extensions
builder.UseComposerLuisSettings();

builder.AddEnvironmentVariables()
.AddCommandLine(args);
Expand Down
4 changes: 0 additions & 4 deletions runtime/dotnet/azurewebapp/appsettings.Deployment.json

This file was deleted.

4 changes: 0 additions & 4 deletions runtime/dotnet/azurewebapp/appsettings.Development.json

This file was deleted.

23 changes: 0 additions & 23 deletions runtime/dotnet/azurewebapp/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,2 @@
{
"feature": {
"UseShowTypingMiddleware": false,
"UseInspectionMiddleware": false,
"RemoveRecipientMention": false
},
"microsoftAppId": "",
"cosmosDb": {
"authKey": "",
"collectionId": "botstate-collection",
"cosmosDBEndpoint": "",
"databaseId": "botstate-db"
},
"applicationInsights": {
"InstrumentationKey": ""
},
"telemetry": {
"logPersonalInformation": false,
"logActivities": true
},
"blobStorage": {
"connectionString": "",
"container": "transcripts"
}
}
29 changes: 29 additions & 0 deletions runtime/dotnet/core/ComposerBotPathExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Extensions.Configuration;
using System.Collections.Generic;

namespace Microsoft.BotFramework.Composer.Core
{
/// <summary>
/// Bot path adapter, for development environment, use '../../' as the bot path, for deployment and production environment, use 'ComposerDialogs' as bot path
/// </summary>
public static class ComposerBotPathExtensions
{
public static IConfigurationBuilder UseBotPathConverter(this IConfigurationBuilder builder, bool isDevelopment = true)
{
var settings = new Dictionary<string, string>();
if (isDevelopment)
{
settings["bot"] = "../../";
}
else
{
settings["bot"] = "ComposerDialogs";
}
builder.AddInMemoryCollection(settings);
return builder;
}
}
}
48 changes: 48 additions & 0 deletions runtime/dotnet/core/ComposerLuisExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;

namespace Microsoft.BotFramework.Composer.Core
{
public static class ComposerLuisExtensions
{
/// <summary>
/// Setup configuration to utilize the settings file generated by bf luis:build. This is a luis settings extensions adapter aligning with Composer customized settings.
/// </summary>
/// <remarks>
/// This will pick up LUIS_AUTHORING_REGION or --region settings as the setting to target.
/// This will pick up --environment as the environment to target. If environment is Development it will use the name of the logged in user.
/// This will pick up --root as the root folder to run in.
/// </remarks>
/// <param name="builder">Configuration builder to modify.</param>
/// <returns>Modified configuration builder.</returns>
public static IConfigurationBuilder UseComposerLuisSettings(this IConfigurationBuilder builder)
{
var configuration = builder.Build();
var botRoot = configuration.GetValue<string>("bot") ?? ".";
var luisRegion = configuration.GetValue<string>("LUIS_AUTHORING_REGION") ?? configuration.GetValue<string>("luis:authoringRegion") ?? configuration.GetValue<string>("luis:region") ?? "westus";
var environment = configuration.GetValue<string>("luis:environment") ?? Environment.UserName;
var settings = new Dictionary<string, string>();
settings["luis:endpoint"] = configuration.GetValue<string>("luis:endpoint") ?? $"https://{luisRegion}.api.cognitive.microsoft.com";
settings["BotRoot"] = botRoot;
builder.AddInMemoryCollection(settings);
if (environment == "Development")
{
environment = Environment.UserName;
}

var settingsPath = Path.GetFullPath(Path.Combine(botRoot, "generated", $"luis.settings.{environment.ToLower()}.{luisRegion}.json"));
var settingsFile = new FileInfo(settingsPath);
if (settingsFile.Exists)
{
builder.AddJsonFile(settingsFile.FullName, optional: false, reloadOnChange: true);
}

return builder;
}
}
}
21 changes: 0 additions & 21 deletions runtime/dotnet/core/LuisConfigAdapter.cs

This file was deleted.