2
votes

I am unsure if the format of my connections string is correct when I am trying to connect to Cosmos DB from Bot Framework 4.6:

        IStorage memoryStorage = null;
        // memoryStorage = new MemoryStorage();
        memoryStorage = new CosmosDbPartitionedStorage(
            new CosmosDbPartitionedStorageOptions
            {
                CosmosDbEndpoint = "https://myDB.mongo.cosmos.azure.com:443/",
                AuthKey = "MyKey",
                DatabaseId = "dev",
                ContainerId = "conversation-state"
            }
            );

        var conversationState = new Models.ConversationState(memoryStorage);
        var UserState = new UserState(memoryStorage);


        services.AddSingleton(conversationState);
        services.AddSingleton(UserState);

enter image description here

Cosmos service URL seem to be correct using the documentation here: https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-storage?view=azure-bot-service-4.0&tabs=csharp#memory-storage

It say to use SSL, so I used port 443, but the port on the connection string say 10255

What am I missing?

This is the error message I am getting:

The bot encounted an error or bug: Response status code does not indicate success: 404 Substatus: 0 Reason: (, Request URI: /, RequestStats: , SDK: Windows/10.0.17763 cosmos-netstandard-sdk/3.2.1).

1

1 Answers

2
votes

Judging by your endpoint and your screenshot, it looks like you selected the "Azure Cosmos DB for MongoDB API" when creating your CosmosDB. You instead need to select Core.

The API Type determines "how" you interact with your CosmosDB service and CosmosDbPartitionedStorage uses the "Core" CosmosDB API as opposed to MongoDB API.


It's a little "buried", so I'll call it out. This is described in the docs (emphasis mine):

  1. On the New account page, provide Subscription, Resource group information. Create a unique name for your Account Name field - this eventually becomes part of your data access URL name. For API, select Core(SQL), and provide a nearby Location to improve data access times.