Botframework 如何以编程方式获取Microsoft Bot Framework聊天机器人应用程序的DirectLine机密?

Botframework 如何以编程方式获取Microsoft Bot Framework聊天机器人应用程序的DirectLine机密?,botframework,azure-cli,azure-bot-service,direct-line-botframework,Botframework,Azure Cli,Azure Bot Service,Direct Line Botframework,我正在尝试使用Microsoft Bot Framework和Azure Bot服务自动化chatbot应用程序的创建和部署过程 我有一个与我的服务对话的自定义模板,我只需要为要部署的每个聊天机器人自定义Web.config文件。我还想使用default.htm来主持一个基本的网络聊天,该聊天使用已部署聊天机器人的DirectLine秘密 我能够使用Azure CLI 2.0创建一个WebApp聊天机器人应用程序,并将聊天机器人与DirectLine频道集成。但是,我无法使用Azure CLI

我正在尝试使用Microsoft Bot Framework和Azure Bot服务自动化chatbot应用程序的创建和部署过程

我有一个与我的服务对话的自定义模板,我只需要为要部署的每个聊天机器人自定义Web.config文件。我还想使用default.htm来主持一个基本的网络聊天,该聊天使用已部署聊天机器人的DirectLine秘密

我能够使用Azure CLI 2.0创建一个WebApp聊天机器人应用程序,并将聊天机器人与DirectLine频道集成。但是,我无法使用Azure CLI 2.0获取DirectLine密钥

我使用以下说明将通过CLI创建的聊天机器人与DirectLine频道集成:

az bot directline create --name
                         --resource-group
                         [--add-disabled {false, true}]
                         [--disablev1 {false, true}]
                         [--disablev3 {false, true}]
                         [--site-name]
但是,当我使用show命令时,我没有得到需要添加到default.htm文件中的网络聊天中的秘密:

az bot directline show --name
                       --resource-group
我可以使用Azure CLI.NET SDK实现这一点吗?我正在使用Azure CLI进行测试,但最后我想使用.NET SDK来创建一个REST web服务,该服务创建聊天机器人(基于我的自定义模板)并将URL返回给调用者。当调用方转到URL时,我希望default.htm承载webchat

无法使用Azure CLI 2.0获取DirectLine密钥

根据我的测试,命令
az bot directline show
将发出以下请求,以检索有关directline频道的详细信息

GET https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resourcegroup_name}/providers/Microsoft.BotService/botServices
/{bot_id}/channels/DirectLineChannel?api-version=2017-12-01
但是
键2
在通过GET返回的响应中始终为空

    //
    // Summary:
    //     Gets primary key. Value only returned through POST to the action Channel List
    //     API, otherwise empty.
    [JsonProperty(PropertyName = "key")]
    public string Key { get; }
    //
    // Summary:
    //     Gets secondary key. Value only returned through POST to the action Channel List
    //     API, otherwise empty.
    [JsonProperty(PropertyName = "key2")]
    public string Key2 { get; }

要在az bot cli中返回/获取
键2
,我们可以使用create命令:

az bot directline create --name MyBotName  --resource-group MyResourceGroup --site-name site2

此外,要在.NET应用程序中管理botservice,您可以尝试使用

您还可以在.NET应用程序中使用Azure管理api来检索botservice的directline密钥。以下示例请求供您参考

请求主体示例:

注意:

在中,我们可以找到:获取主键(辅键)。值仅通过POST到操作通道列表API返回,否则为空

    //
    // Summary:
    //     Gets primary key. Value only returned through POST to the action Channel List
    //     API, otherwise empty.
    [JsonProperty(PropertyName = "key")]
    public string Key { get; }
    //
    // Summary:
    //     Gets secondary key. Value only returned through POST to the action Channel List
    //     API, otherwise empty.
    [JsonProperty(PropertyName = "key2")]
    public string Key2 { get; }
无法使用Azure CLI 2.0获取DirectLine密钥

根据我的测试,命令
az bot directline show
将发出以下请求,以检索有关directline频道的详细信息

GET https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resourcegroup_name}/providers/Microsoft.BotService/botServices
/{bot_id}/channels/DirectLineChannel?api-version=2017-12-01
但是
键2
在通过GET返回的响应中始终为空

    //
    // Summary:
    //     Gets primary key. Value only returned through POST to the action Channel List
    //     API, otherwise empty.
    [JsonProperty(PropertyName = "key")]
    public string Key { get; }
    //
    // Summary:
    //     Gets secondary key. Value only returned through POST to the action Channel List
    //     API, otherwise empty.
    [JsonProperty(PropertyName = "key2")]
    public string Key2 { get; }

要在az bot cli中返回/获取
键2
,我们可以使用create命令:

az bot directline create --name MyBotName  --resource-group MyResourceGroup --site-name site2

此外,要在.NET应用程序中管理botservice,您可以尝试使用

您还可以在.NET应用程序中使用Azure管理api来检索botservice的directline密钥。以下示例请求供您参考

请求主体示例:

注意:

在中,我们可以找到:获取主键(辅键)。值仅通过POST到操作通道列表API返回,否则为空

    //
    // Summary:
    //     Gets primary key. Value only returned through POST to the action Channel List
    //     API, otherwise empty.
    [JsonProperty(PropertyName = "key")]
    public string Key { get; }
    //
    // Summary:
    //     Gets secondary key. Value only returned through POST to the action Channel List
    //     API, otherwise empty.
    [JsonProperty(PropertyName = "key2")]
    public string Key2 { get; }

帮助会通知您关于获取机密的另一个参数

PS C:\> az bot directline show --help

Command
    az bot directline show : Get details of the Directline Channel on a bot.

Arguments
    --name -n           [Required] : The resource name of the bot.
    --resource-group -g [Required] : Name of resource group. You can configure the default group
                                     using `az configure --defaults group=<name>`.
    --with-secrets                 : Show secrets in response for the channel.  Allowed values:
                                     false, true.

Global Arguments
    --debug                        : Increase logging verbosity to show all debug logs.
    --help -h                      : Show this help message and exit.
    --output -o                    : Output format.  Allowed values: json, jsonc, table, tsv, yaml.
                                     Default: json.
    --query                        : JMESPath query string. See http://jmespath.org/ for more
                                     information and examples.
    --subscription                 : Name or ID of subscription. You can configure the default
                                     subscription using `az account set -s NAME_OR_ID`.
    --verbose                      : Increase logging verbosity. Use --debug for full debug logs.
PS C:\>az bot directline show--帮助
命令
az bot directline show:获取bot上directline频道的详细信息。
论据
--name-n[必需]:bot的资源名称。
--资源组-g[必需]:资源组的名称。您可以配置默认组
使用'az configure--defaults group=`。
--with secrets:显示机密以响应频道。允许值:
假,真。
全局参数
--调试:增加日志详细度以显示所有调试日志。
--帮助-h:显示此帮助消息并退出。
--输出-o:输出格式。允许的值:json、jsonc、table、tsv、yaml。
默认值:json。
--查询:JMESPath查询字符串。看见http://jmespath.org/ 更多
资料和例子。
--订阅:订阅的名称或ID。您可以配置默认值
使用“az帐户集-s NAME\u或\u ID”进行订阅。
--详细:增加日志记录的详细程度。使用--debug获取完整的调试日志。
使用以下命令,您可以获取directline频道的秘密:

az bot目录行显示-n“{botId}”-g“{resourceGroupName}”--带有秘密--订阅“{subscriptionId}”


我对它进行了测试,它成功地工作了。

帮助会通知您关于获取秘密的另一个参数

PS C:\> az bot directline show --help

Command
    az bot directline show : Get details of the Directline Channel on a bot.

Arguments
    --name -n           [Required] : The resource name of the bot.
    --resource-group -g [Required] : Name of resource group. You can configure the default group
                                     using `az configure --defaults group=<name>`.
    --with-secrets                 : Show secrets in response for the channel.  Allowed values:
                                     false, true.

Global Arguments
    --debug                        : Increase logging verbosity to show all debug logs.
    --help -h                      : Show this help message and exit.
    --output -o                    : Output format.  Allowed values: json, jsonc, table, tsv, yaml.
                                     Default: json.
    --query                        : JMESPath query string. See http://jmespath.org/ for more
                                     information and examples.
    --subscription                 : Name or ID of subscription. You can configure the default
                                     subscription using `az account set -s NAME_OR_ID`.
    --verbose                      : Increase logging verbosity. Use --debug for full debug logs.
PS C:\>az bot directline show--帮助
命令
az bot directline show:获取bot上directline频道的详细信息。
论据
--name-n[必需]:bot的资源名称。
--资源组-g[必需]:资源组的名称。您可以配置默认组
使用'az configure--defaults group=`。
--with secrets:显示机密以响应频道。允许值:
假,真。
全局参数
--调试:增加日志详细度以显示所有调试日志。
--帮助-h:显示此帮助消息并退出。
--输出-o:输出格式。允许