简体   繁体   中英

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. 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" ; $appInfo.AppId comes from using the command Get-AzADApplication on a valid application registration and its object id; $botName is set to "TestingScriptBot" ; $resourceGroupName is set to the name of a valid resource group; $messagingEndpoint is set to a valid url; $sku is set to "FO" .

However, I receive a rather strange error inside of the docker container:

(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" :

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. 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.

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. Furthermore, I have tried different versions of Python as well.

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.

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.

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.

** Here are all of the versions/packages I have:**

The docker container is running with the following version: Alpine Linux v3.16 .

I am running the latest version of Powershell: 7.3.0 .

I am running the latest version of 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 .

I have libffi installed and OpenSSL version 1.1.1s .

I have Python version 3.10.8 installed.

This is the powershell script I have been testing with:

$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:

  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
  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

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.

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 . On the other hand, the docker container api-version when running this command is 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. As a result, bot creation worked for me. This did allow me to circumvent the failure of the az bot create command. Here is the script I tested that allowed me to do what I wanted to with 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. This specific body worked on my macos. To get it to work in the docker container I removed the escape character ( \ before each double quote in the json body).

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.

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.

Does anyone know if there is a way I can change what version of the api is being used for Azure CLI commands? 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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