Reputation: 13
I'm building a Ruby program to connect to Azure cosmos db, using the azure-storage-table gem (rubygems, github).
The microsoft instructions here are pretty simple and clean, but they don't quite explain how I use the connection string properly:
https://learn.microsoft.com/en-us/azure/cosmos-db/table/how-to-use-ruby
To connect to Azure Cosmos DB, copy your primary connection string from the Azure portal, and create a Client object using your copied connection string. You can pass the Client object when you create a TableService object:
common_client = Azure::Storage::Common::Client.create(storage_account_name:'myaccount', storage_access_key:'mykey', storage_table_host:'mycosmosdb_endpoint')
table_client = Azure::Storage::Table::TableService.new(client: common_client)
My connection string looks like the following: screenshot of my cosmos connection strings
The PRIMARY READ-ONLY CONNECTION STRING is:
AccountEndpoint=https://{azureCosmosDBAccount}.documents.azure.com:443/;AccountKey={myAccountKey}
So I'm confused about how to translate this connection string into the format prescribed by microsoft in the example above.
common_client = Azure::Storage::Common::Client.create(storage_account_name:'myaccount', storage_access_key:'mykey', storage_table_host:'mycosmosdb_endpoint')
My connection string doesn't have a 'myaccount' value, what is this, where does this come from?
This instruction doesn't make sense to me, as I'm trying to connect to cosmos db, not an Azure Storage Account.
Or, alternatively, can I pass the connection string into the Client.create object under a different parameter name?
Upvotes: 0
Views: 118
Reputation: 13
From the comment left by @David above, the answer is this:
myaccount
is the unique name you gave to your Cosmos DB Table API account (the first part in that connection string you shared - {azureCosmosDBAccount}
- the name between the braces.storage_table_host
is forUpvotes: 0