Azure源代码中没有bot扩展文件

时间:2019-05-15 11:45:09

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

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

1 个答案:

答案 0 :(得分:0)

bot框架团队正在远离将bot信息存储在.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>();
    }