diff --git a/runtime/dotnet/azurewebapp/README.md b/runtime/dotnet/azurewebapp/README.md index 356528b3d7..0139518b13 100644 --- a/runtime/dotnet/azurewebapp/README.md +++ b/runtime/dotnet/azurewebapp/README.md @@ -1,21 +1,19 @@ ## Bot Project + Bot project is the launcher project for the bots written in declarative form (JSON), using the Composer, for the Bot Framework SDK. -## Instructions for setting up the Bot Project runtime -The Bot Project is a regular Bot Framework SDK V4 project. Before you can launch it from the emulator, you need to make sure you can run the bot. +### CI/CD Deployment + +You can deploy your bot to an Azure Web App with the following script from an Azure pipeline or GitHub workflow using an [Azure CLI task](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-cli). -### Prerequisite: -* Install .Netcore 3.1 +```bash +./scripts/deploy.ps1 -name my-bot -environment prod -luisAuthoringKey XXXXXXXXX -luisAuthoringRegion westeurope +``` -### Commands: +The Azure CLI task needs contribution permission to the corresponding resource group. Follow this [article](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/connect-to-azure) to setup a service connection between Azure DevOps and your Azure Subscription. -* from root folder -* cd templates/dotnet/Microsoft.BotFramework.Composer.WebAppTemplate -* dotnet user-secrets init // init the user secret id -* dotnet build // build -* dotnet run // start the bot -* It will start a web server and listening at http://localhost:3979. +Initially you can provision the resources with the provisionComposer.js script, which you can find in the boot root folder under scripts. -### Test bot -* You can set you emulator to connect to http://localhost:3979/api/messages. +The environment, bot name and authoring region must match the arguments, that you used for for the provisioning with the provisionComposer.js script. +For security reasons we don't deploy any settings or secrets from the bot project. Please ensure that required settings for your bit are configured in the [Azure Web App configuration](https://docs.microsoft.com/en-us/azure/app-service/configure-common), for example "MicrosoftAppPassword", "luis\_\_endpointKey", "cosmosDB\_\_authKey", ... diff --git a/runtime/dotnet/azurewebapp/Scripts/deploy.ps1 b/runtime/dotnet/azurewebapp/Scripts/deploy.ps1 index 71d2abd197..bb6dc8aaaa 100644 --- a/runtime/dotnet/azurewebapp/Scripts/deploy.ps1 +++ b/runtime/dotnet/azurewebapp/Scripts/deploy.ps1 @@ -118,20 +118,22 @@ if ($luisAuthoringKey -and $luisAuthoringRegion) { $luconfigjson | ConvertTo-Json -Depth 100 | Out-File $(Join-Path $remoteBotPath luconfig.json) - # Execute bf luis:build command - if (Get-Command bf -errorAction SilentlyContinue) { - # create generated folder if not - if (!(Test-Path generated)) { - $null = New-Item -ItemType Directory -Force -Path generated - } - bf luis:build --luConfig $(Join-Path $remoteBotPath luconfig.json) --botName $name --authoringKey $luisAuthoringKey --dialog crosstrained --out ./generated --suffix $environment -f --region $luisAuthoringRegion + # create generated folder if not + if (!(Test-Path generated)) { + $null = New-Item -ItemType Directory -Force -Path generated } + + # ensure bot cli is installed + if (Get-Command bf -errorAction SilentlyContinue) {} else { - Write-Host "bf luis:build does not exist, use the following command to install:" - Write-Host "npm install -g @microsoft/botframework-cli" - Break + Write-Host "bf luis:build does not exist. Start installation..." + npm i -g @microsoft/botframework-cli + Write-Host "successfully" } + # Execute bf luis:build command + bf luis:build --luConfig $(Join-Path $remoteBotPath luconfig.json) --botName $name --authoringKey $luisAuthoringKey --dialog crosstrained --out ./generated --suffix $environment -f --region $luisAuthoringRegion + if ($?) { Write-Host "lubuild succeeded" } @@ -142,7 +144,6 @@ if ($luisAuthoringKey -and $luisAuthoringRegion) { Set-Location -Path $projFolder - # clear the settings; we don't want to unintentionally copy secrets to the remote web app $settings = New-Object PSObject $luisConfigFiles = Get-ChildItem -Path $publishFolder -Include "luis.settings*" -Recurse -Force