Azure / azure-cli

Azure Command-Line Interface
MIT License
4.04k stars 3.01k forks source link

"az bot create" provides no way to specify pre-existing QnAmaker, Web App, Service plan etc ... #11433

Closed archmangler closed 5 years ago

archmangler commented 5 years ago

Describe the bug

Incomplete azure bot cli utility:

We can create the dependent services like qnamaker and web app service for the azure bot service using az cli, but there is no way to create a bot and specify these dependency services at creation time, or even using the "az bot update" command.

To Reproduce

# Create resource group.
az group create --name devexp-qnamaker --location westus

# Create Search instance and get admin key.
# in this example, the key is "B044183F2450193E26751DC20423DFE4"
az search service create -g devexp-qnamaker -n devexp-qnamaker-search --sku standard
az search admin-key show -g devexp-qnamaker --service-name devexp-qnamaker-search

# Create App Service plan and Web App
# in this example, Web App endpoint will be https://devexp-qnamaker-webapp.azurewebsites.net
az appservice plan create -g devexp-qnamaker -n devexp-qnamaker-webapp-plan --sku S1
az webapp create -g devexp-qnamaker -n devexp-qnamaker-webapp --plan devexp-qnamaker-webapp-plan

# Configure Web App
az webapp config appsettings set -g devexp-qnamaker -n devexp-qnamaker-webapp --settings \
    AzureSearchName=devexp-qnamaker-search \
    AzureSearchAdminKey=B044183F2450193E26751DC20423DFE4 \
    PrimaryEndpointKey=devexp-qnamaker-webapp-PrimaryEndpointKey \
    SecondaryEndpointKey=devexp-qnamaker-webapp-SecondaryEndpointKey \
    DefaultAnswer="No good match found in KB." \
    QNAMAKER_EXTENSION_VERSION="latest"
az webapp cors add -g devexp-qnamaker -n devexp-qnamaker-webapp -a "*"

# Create QnAMaker account
az cognitiveservices account create -g devexp-qnamaker -n devexp-qnamaker-account --kind QnAMaker --sku S0 --location westus --api-properties qnaRuntimeEndpoint=https://devexp-qnamaker-webapp.azurewebsites.net
https://docs.microsoft.com/en-us/cli/azure/bot?view=azure-cli-latest#az-bot-create

Result: Nothing available in the documentation.

Impact:

No means to completely script bot creation using these elements without resorting to the portal. This means that for our large scale enterprise requirements we cannot smoothly automate bot creation via ci/cd pipelines at speed without substantial manual work in the portal. Due to the high rate of iteration required to develop bots to meet requirements, this is a blocker.

Expected behavior

Environment summary

Additional context

ghost commented 5 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc

archmangler commented 5 years ago

Any feedback ?

stevengum commented 5 years ago

@archmangler you should use az webapp config appsettings to configure the App Service hosting your bot.

az bot update affects the Bot Registration, whether it is a Web App Bot or a Bot Channels Registration. It does not affect the settings on the App Service.

archmangler commented 5 years ago

@stevengum - would you be able to provide an example please?

stevengum commented 5 years ago

Instead of the commands you used above, you would do the following:

Create App Service plan and Web App for hosting the bot:

az appservice plan create -g devexp-bot-n devexp-bot-webapp-plan --sku S1
az webapp create -g devexp-bot -n devexp-bot-webapp --plan devexp-bot-webapp-plan

As an example we'll use these keys from the QnAMaker sample. You should use the keys that your bot/app looks for in the Application Settings.

Configure Web App:

az webapp config appsettings set -g devexp-bot -n devexp-bot-webapp --settings \
    QnAKnowledgebaseId=devexp-qnamaker-knowledgebaseid \
    QnAEndpointKey=devexp-qnamaker-webapp-PrimaryEndpointKey \
    QnAEndpointHostName="https://devexp-qnamaker-webapp.azurewebsites.net" \
stevengum commented 5 years ago

Closing issue. If the provided answer does not solve your ask, please @-mention me in this issue.

archmangler commented 4 years ago

Hi @stevengum I've tested the command sequence you provided earlier. This does not result in an actual chatbot that can be tested via the webchat feature. It does result in the following resources being created in my resource group:

  1. A service plan
  2. an App service
  3. Cognitive search service

But no resource of type "Web app Bot". To obtain the web app bot I have to run the command:

az bot create --resource-group "rsg-whatever" \
 --appid  "xxxxwhatever" \
 --display-name "Support-Bot" \
 --kind webapp \
 --name \"supportbot\" \
 --password "somepasword" \
 --lang "Csharp" \
 --sku "S1"

This creates a resource of type "Web App Bot". However, it also creates along with it the following two new resources:

  1. An "App Service Plan"
  2. An "App Service"

I did not specify these resources and would like to configure the chat bot to use the separately create app service plan and service. However, as mentioned before looking at the manual for "az bot create" and "az bot update" there is nothing to allow one to specify pre-existing app service or app service plans. This is a problem because:

a) These resources are created in a region we do not operate (West US) and we'd prefer it to operate in the region where the rest of our resources exist (SE Asia) b) Our automation scripting would be more efficient if it could update/delete/destroy only the resource in question instead of the entire set of bot+app-service+app-service-plan

For completeness sake this is the current sequence of commands I'm using to create a bot + search service (I've put the knowledgebase component on hold for now as it seems impossible to automate using the cli):

az search service create --resource-group "rsg-lolcorp-uat-az1-seccode" --name "mybot-search" --sku "standard"

az search admin-key show --resource-group "rsg-lolcorp-uat-az1-seccode" --service-name "mybot-search"

az appservice plan create  -g "rsg-lolcorp-uat-az1-seccode"  -n "mybot-service-plan"  --sku "S1"

az webapp create --resource-group "rsg-lolcorp-uat-az1-seccode" --name "mybot-webapp" --plan "mybot-service-plan"

az webapp config appsettings set \
--resource-group "rsg-lolcorp-uat-az1-seccode" \
--name "mybot-webapp" \
--settings \
AzureSearchName="mybot-search" \
AzureSearchAdminKey="xxxxx" \
PrimaryEndpointKey="mybot-webapp-PrimaryEndpointKey"  \
SecondaryEndpointKey="mybot-webapp-SecondaryEndpointKey" \
DefaultAnswer="No good match found in KB." \
QNAMAKER_EXTENSION_VERSION="latest"

az webapp cors add --resource-group "rsg-lolcorp-uat-az1-seccode" --name "mybot-webapp" -a "*"

az cognitiveservices account create \
--resource-group "rsg-lolcorp-uat-az2-seccode" \
--name "mybot-qnamaker" \
--kind QnAMaker \
--sku "S0" \
--location "westus" \
--api-properties qnaRuntimeEndpoint="https://mybot-webapp.azurewebsites.net"

az bot create --resource-group "rsg-lolcorp-uat-az1-seccode" \
 --appid  "xyz" \
 --display-name "mybot-Support-Bot" \
 --kind webapp \
 --name "mybot" \
 --password "yyyyyyy" \
 --lang "Csharp" \
 --sku "S1"