azure.mgmt.cosmosdb database_accounts.list_connection_strings() does not list connection strings
I was trying to use the azure.mgmt.cosmosdb API to retrieve connection strings for each of the databases with a resource group. I can retrieve the auth keys but not the connection strings.
I wrote the following test harness to verify my assumptions. Note, it verifies that I'm getting a master key but not connection strings.
#!/usr/bin/env python
import sys
import json
from azure.mgmt.cosmosdb import CosmosDB
from azure.common.client_factory import get_client_from_json_dict
creds_file, group = sys.argv[1:]
with open(creds_file, "rb") as fh:
creds = json.load(fh)
client = get_client_from_json_dict(CosmosDB, creds)
for db in client.database_accounts.list_by_resource_group(group):
db_keys = client.database_accounts.list_keys(group, db.name)
assert len(db_keys.primary_master_key) > 0
strings = client.database_accounts.list_connection_strings(group, db.name)
assert strings.connection_strings is not None
Running this POC, I get the following output:
$ ./poc.py management.json my-test-group
Traceback (most recent call last):
File "./poc.py", line 19, in <module>
assert strings.connection_strings is not None
AssertionError
$
I checked, and list_connection_strings doesn't appear to be tested in the unit tests for azure.mgmt.cosmosdb.
Hi @bmc-msft I double-checked the CLI testing and it works as expected.
Could you print strings.serialize() and post it here?
Hi @bmc-msft, thank you for identifying this issue. In January of this year, we altered the response of our "list connection strings" API to include all connection strings for all account API kinds. The requests should now include the connection strings. Before this change, only Mongo account connection strings were included in the response.