question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to persist bot state to CosmosDB using CI/CD?

See original GitHub issue

We have a Composer bot that we are not deploying manually via a publish profile, but instead followed the documentation here: https://docs.microsoft.com/en-us/composer/how-to-cicd

However, that documentation does not describe how to get the Composer bot to write bot state to an existing CosmosDB container. I have tried setting app settings in the Azure App Service for cosmosDb:authKey, cosmosDb:cosmosDbEndpoint, cosmosDb:containerId, etc., and equivalents replacing “:” with “__”, but to no avail. We simply never see state in CosmosDB. I figured these app settings would be valid per the documentation here showing how the app settings are defined in the publish profile (plus, this is how the C# templates structure the app settings OOTB as well): https://docs.microsoft.com/en-us/composer/how-to-provision-azure-resources#share-resource-details

Incidentally, I have also tried setting these app settings in Composer’s configuration advanced editor locally to write to my CosmosDB Emulator but also to no avail.

Please don’t tell me to configure the publish profile as the answer - that is not the answer for many enterprise scenarios and the Bot Framework team should well know it. Similarly, please don’t simply link me to Bot Framework C# documentation about setting bot state, because I’ve authored several C# Bot Framework solutions and know very, very, very well how to get that to work.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
nicolas-martin-dtecommented, Dec 21, 2021

Ok, finally got this working. It seems value CosmosDbPartitionedStorage is the proper incantation needed for runtimeSettings:storage with the connection details defined in a config section of the same name.

Here’s the snippet from the ARM template’s app settings I have that is now finally writing bot state to CosmosDB:

            "CosmosDbPartitionedStorage:authKey": "[concat('@Microsoft.KeyVault(SecretUri=', reference(resourceId('Microsoft.KeyVault/vaults/secrets', parameters('keyVaultName'), 'CosmosDbAuthKey')).secretUriWithVersion, ')')]",
            "CosmosDbPartitionedStorage:containerId": "[variables('cosmosDbBotStateContainerName')]",
            "CosmosDbPartitionedStorage:cosmosDBEndpoint": "[variables('cosmosDbBotStateEndpoint')]",
            "CosmosDbPartitionedStorage:databaseId": "[variables('cosmosDbBotStateDatabaseName')]",
            "runtimeSettings:storage": "CosmosDbPartitionedStorage",

I only found this because I created another bot from a template and provisioned/deployed to a personal Azure subscription and dug into the publish files to find how it was actually configured in the settings file from the publish profile.

Please document this sort of thing. All the various app settings / configuration options as loaded by Composer should be fully documented.

0reactions
dmvtechcommented, Dec 30, 2021

Yeah, my bad. CosmosDB was an older, allowed config option. Looks like it is only CosmosDbPartitionedStorage now. Glad you got it working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Persist Bot Conversation States in Azure Cosmos DB with Bot ...
Create Cosmos DB Azure Resource firstly. Open Bot Composer. Click Configuration, and choose the default bot, please choose the root bot if there ......
Read more >
Cosmos DB | Programmatic Ponderings
In this post, we will explore the development of a machine learning-based LUIS-enabled chatbot using the Azure Bot Service and the BotBuilder SDK....
Read more >
Managing state and logging chat history in Microsoft bot ...
Store more than 32 kb of data. In order to enable our bot to use Cosmos DB for managing its state we need...
Read more >
DevOps for Bots – Rapid Development, Continuous ...
DevOps for Bots – Rapid Development, Continuous Integration and Delivery (CI/CD) with Azure Bot Service & Visual Studio Team Services (VSTS).
Read more >
Microsoft Azure Cosmos DB spoke - ServiceNow Docs
Known synonyms are applied. The most relevant topics (based on weighting and matching to search terms) are listed first in search results. Topics...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found