PlagueHO / CosmosDB

PowerShell Module for working with Azure Cosmos DB databases, collections, documents, attachments, offers, users, permissions, triggers, stored procedures and user defined functions.
http://dscottraynsford.com
MIT License
154 stars 46 forks source link

Get-CosmosDbAccountConnectionString shows blank output, but the results show in debug mode #408

Open ojasp opened 3 years ago

ojasp commented 3 years ago

Issue

Before submitting your issue for the CosmosDB project, please take a moment to provide the following details:

Thanks for contributing your feedback and support! You can optionally submit a Pull Request against this project, if you have a fix you'd like to share.

I just ran Get-CosmosDbAccountConnectionString agains a cosmosdb account and got no result. However when I run the command with Debug flag, I see that the body returns connectionstrings, however the output still shows no connection string.

ojasp commented 3 years ago

I was looking at the script in the source and noticed the key mapping:

$connectionStringMapping = @{
    'PrimaryMasterKey' = 'Primary SQL Connection String'
    'SecondaryMasterKey' = 'Secondary SQL Connection String'
    'PrimaryReadonlyMasterKey' = 'Primary Read-Only SQL Connection String'
    'SecondaryReadonlyMasterKey' = 'Secondary Read-Only SQL Connection String'
}

This would work if the cosmosdb document is of DocumentDB type, but not if it is set to CosmosDB type. I was querying a database that was set to MongoDB type and the mapping for them would have to be:

$connectionStringMapping = @{
    'PrimaryMasterKey' = 'Primary MongoDB Connection String'
    'SecondaryMasterKey' = 'Secondary MongoDB Connection String'
    'PrimaryReadonlyMasterKey' = 'Primary Read-Only MongoDB Connection String'
    'SecondaryReadonlyMasterKey' = 'Secondary Read-Only MongoDB Connection String'
}

It would help if we could pass a flag to the command that would tell it whether we are querying SQL or MongoDB type of Cosmos DB.