简体   繁体   English

az bot create 命令失败,请求正文中的参数“schemaTransformationVersion”设置为“0.0”- 为什么会发生这种情况? 怎么修?

[英]az bot create command failing with parameter "schemaTransformationVersion" set to "0.0" in request body - why is this occurring? How to fix?

I am trying to get the command az bot create to run inside of a docker container.我正在尝试让命令az bot create在 docker 容器内运行。 More specifically, this is the full command:更具体地说,这是完整的命令:

az bot create `
    --app-type $appType `
    --appid $appInfo.AppId `
    --name $botName `
    --resource-group $resourceGroupName `
    --endpoint $messagingEndpoint `
    --sku $sku

Where $appType is equal to "MultiTenant" ;其中$appType等于"MultiTenant" $appInfo.AppId comes from using the command Get-AzADApplication on a valid application registration and its object id; $appInfo.AppId来自在有效的应用程序注册及其 object id 上使用命令Get-AzADApplication $botName is set to "TestingScriptBot" ; $botName设置为"TestingScriptBot" $resourceGroupName is set to the name of a valid resource group; $resourceGroupName设置为有效资源组的名称; $messagingEndpoint is set to a valid url; $messagingEndpoint设置为有效的 url; $sku is set to "FO" . $sku设置为"FO"

However, I receive a rather strange error inside of the docker container:但是,我在 docker 容器中收到一个相当奇怪的错误:

(InvalidBotData) Bot is not valid. Errors: The schema transformation version is not supported.  See https://docs.microsoft.com/azure/bot-service/bot-service-resources-bot-framework-faq?view=azure-bot-service-4.0 for detailed requirements.
Code: InvalidBotData
Message: Bot is not valid. Errors: The schema transformation version is not supported.  See https://docs.microsoft.com/azure/bot-service/bot-service-resources-bot-framework-faq?view=azure-bot-service-4.0 for detailed requirements.

Furthermore, when enabling the --debug flag on the command above, I notice the following parameter " schemaTransformationVersion" inside of the request body is set to "0.0" :此外,在上述命令中启用--debug标志时,我注意到请求正文中的以下参数“ schemaTransformationVersion"设置为"0.0"

cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"location": "global", "sku": {"name": "F0"}, "kind": "azurebot", "properties": {"displayName": "AutomationTestingScriptBot", "iconUrl": "", "endpoint": <working_endpoint>, "msaAppType": "MultiTenant", "msaAppId": <working_app_id>, "isCmekEnabled": false, "publicNetworkAccess": "Enabled", "isStreamingSupported": false, "schemaTransformationVersion": "0.0"}}

However, when I run this same command on local, this parameter is not even inside of the request body.但是,当我在本地运行相同的命令时,此参数甚至不在请求正文中。 The az bot create command does not even allow me to change this parameter - so I am at a bit of a loss of what to do here. az bot create命令甚至不允许我更改此参数 - 所以我有点不知所措。 I have tried re-building the container with different versions of the Azure CLI as well (starting from 2.38.0 to the latest version of 2.43.0 ) and the same behavior occurs.我也尝试过使用不同版本的 Azure CLI 重新构建容器(从2.38.0到最新版本的2.43.0 )并且发生相同的行为。

Since I originally thought this was a module version issue I have tried re-building the container with different versions of Powershell and Azure CLI.因为我最初认为这是模块版本问题,所以我尝试使用不同版本的 Powershell 和 Azure CLI 重新构建容器。 Furthermore, I have tried different versions of Python as well.此外,我也尝试过不同版本的 Python。

I have also tried to login into each respective client (Powershell and Azure CLI) with the tenant id, as I had a shared token/refresh token warning - but that did not seem to help either.我还尝试使用租户 ID 登录到每个相应的客户端(Powershell 和 Azure CLI),因为我有一个共享令牌/刷新令牌警告 - 但这似乎也没有帮助。

Regardless of what I attempted, the same error occurred.无论我尝试什么,都会发生同样的错误。

This command was working for me inside of the docker container up until recently - this past Friday (12/2/22) was when I rebuilt the container and this behavior started.直到最近,此命令在 docker 容器内为我工作 - 上周五 (12/2/22) 是我重建容器并开始此行为的时间。

So I do not really understand why this parameter is suddenly in the request body of this command and am currently at a loss of how to fix it.所以我真的不明白为什么这个参数突然出现在这个命令的请求体中并且我目前不知道如何修复它。 I thought it might have been a module version issue, but after playing around with different versions of the Azure CLI and updating software inside of the container, I am not really sure how/why this behavior is occurring and what I need to do to fix it.我认为这可能是模块版本问题,但在试用了不同版本的 Azure CLI 并更新了容器内的软件之后,我不太确定这种行为是如何/为什么发生的,以及我需要做什么来修复它。

** Here are all of the versions/packages I have:** ** 以下是我拥有的所有版本/包:**

The docker container is running with the following version: Alpine Linux v3.16 . docker 容器使用以下版本运行: Alpine Linux v3.16

I am running the latest version of Powershell: 7.3.0 .我正在运行最新版本的 Powershell: 7.3.0

I am running the latest version of Azure CLI:我正在运行最新版本的 Azure CLI:

{               
  "azure-cli": "2.43.0",
  "azure-cli-core": "2.43.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {}
}

I installed the latest version of the Az module via Install-Module -name Az and the latest version of the Az.BotService module via Install-Module -Name Az.BotService .我通过Install-Module -name Az安装了最新版本的Az模块,通过Install-Module -Name Az.BotService了最新版本的Az.BotService模块。

I have libffi installed and OpenSSL version 1.1.1s .我安装了 libffi 和 OpenSSL 版本1.1.1s

I have Python version 3.10.8 installed.我安装了 Python 版本3.10.8

This is the powershell script I have been testing with:这是我一直在测试的 powershell 脚本:

$appInfo = Get-AzADApplication -ObjectId <valid_obj_id>

$appType = "MultiTenant"
$botName = "TestingScriptBot"
$resourceGroupName = <valid_resource_group_name>
$messagingEndpoint = <valid_endpoint>
$sku = "F0"

az bot create `
    --app-type $appType `
    --appid $appInfo.AppId `
    --name $botName `
    --resource-group $resourceGroupName `
    --endpoint $messagingEndpoint `
    --sku $sku `
    --debug

I am running the same script locally and inside of the docker container and have compared the commands with the --debug flag enabled and from a text compare of the two outputs, the two major differences I see are:我在本地和 docker 容器内部运行相同的脚本,并将命令与启用的--debug标志进行比较,并从两个输出的文本比较中,我看到的两个主要区别是:

  1. The " schemaTransformationVersion" parameter inside of the request body is set to "0.0" - but only when the command is run within the docker container - this parameter is not in the request body of the command when the command is run locally请求主体内的“ schemaTransformationVersion"参数设置为"0.0" - 但仅当命令在 docker 容器内运行时 - 当命令在本地运行时,此参数不在命令的请求主体中
  2. The docker container uses the auth token before making the request with the az bot create command, whereas local uses a refresh token - although I do not suspect this is causing the problem, as this occurred in the past when the command was working inside of the docker container for me docker 容器在使用az bot create命令发出请求之前使用 auth 令牌,而 local 使用刷新令牌 - 虽然我不怀疑这是导致问题的原因,因为这发生在过去命令在内部运行时docker 容器给我

Please let me know if any further information is needed.如果需要任何进一步的信息,请告诉我。

Looking into it some more, I was able to find an alternative solution that does work.进一步研究后,我找到了一个可行的替代解决方案。 Granted, I do not love this solution as it feels like a bit of a hack, but I think it can hold until I can dig further into what is going wrong with the az bot create command.诚然,我不喜欢这个解决方案,因为它感觉有点像 hack,但我认为它可以坚持下去,直到我可以进一步深入了解az bot create命令出了什么问题。

After doing some more research, I think I might know the issue, or this is another difference I noticed.在做了更多研究之后,我想我可能知道这个问题,或者这是我注意到的另一个不同之处。 The api-version when running this command for local is the following: 2021-05-01-preview .为本地运行此命令时的 api 版本如下: 2021-05-01-preview On the other hand, the docker container api-version when running this command is 2022-06-15-preview .另一方面,运行此命令时的 docker 容器 api-version 是2022-06-15-preview

So, I used az rest command with the same request url (including the api-version) as local and used the same body as local.因此,我将az rest命令与与本地相同的请求 url(包括 api 版本)一起使用,并使用与本地相同的主体。 As a result, bot creation worked for me.结果,机器人创建对我有用。 This did allow me to circumvent the failure of the az bot create command.这确实让我避免了az bot create命令的失败。 Here is the script I tested that allowed me to do what I wanted to with az bot create :这是我测试过的脚本,它允许我使用az bot create做我想做的事:

$body = '{\"location\": \"global\", \"sku\": {\"name\": \"F0\"}, \"kind\": \"azurebot\", \"properties\": {\"displayName\": \"TestingScriptBot\", \"endpoint\": \"<valid_endpoint>\", \"msaAppType\": \"MultiTenant\", \"msaAppId\": \"<valid_app_id>\", \"isCmekEnabled\": false, \"publicNetworkAccess\": \"Enabled\", \"isStreamingSupported\": false}}'

$uri = "/subscriptions/<subscription_id>/resourceGroups/<resoure_group_name>/providers/Microsoft.BotService/botServices/<bot_name>?api-version=2021-05-01-preview"

az rest --uri $uri `
    --method put `
    --body $body `
    --debug

Note that you may need to adapt your json body depending on what os you are using.请注意,您可能需要根据您使用的操作系统调整您的 json 主体。 This specific body worked on my macos.这个特定的身体在我的 macOS 上工作。 To get it to work in the docker container I removed the escape character ( \ before each double quote in the json body).为了让它在 docker 容器中工作,我删除了转义字符( json 正文中每个双引号之前的\ )。

However, I do not think using az rest is a great solution to the problem and would still appreciate some insight into why az bot create command is failing for me inside of the docker container.但是,我不认为使用az rest是解决问题的好方法,并且仍然希望深入了解为什么az bot create命令在 docker 容器内对我来说失败。

My guess as of now is that the api version difference in the request url might be why the "schemaTransformationVersion" parameter is included and has an invalid value, especially since I do not have control over its value in this command.我现在的猜测是请求 url 中的 api 版本差异可能是包含“schemaTransformationVersion”参数并且具有无效值的原因,特别是因为我无法控制此命令中的值。

Does anyone know if there is a way I can change what version of the api is being used for Azure CLI commands?有谁知道是否有办法更改 api 的哪个版本用于 Azure CLI 命令? Because if that is possible I would like to test the az bot create command with the older api version, rather than just mimicking what I would like the call to do via az rest .因为如果可能的话,我想用较旧的 api 版本测试az bot create命令,而不是仅仅模仿我希望通过az rest进行的调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM