Skip to content

Commit

Permalink
Optimises deployment script for CI/CD pipeline; readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ltwlf committed Sep 12, 2020
1 parent 259b394 commit 1aa9d6b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
24 changes: 11 additions & 13 deletions runtime/dotnet/azurewebapp/README.md
Original file line number Diff line number Diff line change
@@ -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", ...
23 changes: 12 additions & 11 deletions runtime/dotnet/azurewebapp/Scripts/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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
Expand Down

0 comments on commit 1aa9d6b

Please sign in to comment.