【问题标题】:There is no bot extension file in azure source codeazure 源代码中没有 bot 扩展文件
【发布时间】:2019-10-02 13:16:57
【问题描述】:

我是 azure bot 服务的新手。我第一次创建了新的机器人并从 azure 门户下载了源代码。在源代码中有一个机器人扩展设置文件。放置了所有与机器人相关的设置。我的问题是,我再次创建了新的机器人并从 azure 门户下载了源代码。但源代码中不存在任何 bot 扩展文件。如何获取机器人扩展设置文件。请给出你的建议。

【问题讨论】:

  • V3 还是 V4 模板? V4 有 .bot 文件 - 这些文件需要解锁。 V3 没有机器人文件 - 而是设置在门户设置中。

标签: c# botframework bots azure-bot-service


【解决方案1】:

机器人框架团队不再将机器人信息存储在 .bot 文件中,现在将密钥放在 appsettings.json 中。从 Azure 下载的 Bot 源代码现在遵循这一原则,并且应该包含一个 ConfigurationCredentialProvider.cs,它将在您的 appsettings.json 中查找信息:

public class ConfigurationCredentialProvider : SimpleCredentialProvider
{
    public ConfigurationCredentialProvider(IConfiguration configuration)
        : base(configuration["MicrosoftAppId"], configuration["MicrosoftAppPassword"])
    {
    }
}

此 ConfigurationCredentialProvider 作为单例添加到 Startup.cs 文件中:

// 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);

        if (!string.IsNullOrEmpty(Configuration[BotOpenIdMetadataKey]))
            ChannelValidation.OpenIdMetadataUrl = Configuration[BotOpenIdMetadataKey];

        // Create the credential provider to be used with the Bot Framework Adapter.
        services.AddSingleton<ICredentialProvider, ConfigurationCredentialProvider>();

        // Create the Bot Framework Adapter.
        services.AddSingleton<IBotFrameworkHttpAdapter, BotFrameworkHttpAdapter>();

        // Create the bot as a transient. In this case the ASP Controller is expecting an IBot.
        services.AddTransient<IBot, EchoBot>();
    }

【讨论】:

  • 感谢您的回答。 Bot 模拟器是创建 .bot 扩展文件。我已经保存了机器人文件,只需将 appId 和密码粘贴并修改到我的应用程序。
  • 如果你喜欢我的答案,请选择它作为答案。展望未来,我们也计划更改模拟器,因此它可能不会总是创建 .bot 文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-01-05
  • 2016-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-28
  • 1970-01-01
相关资源
最近更新 更多