Reputation: 847
I just stood up the Azure CosmosDB emulator on a Mac OS X (and linux) box with the provided docker container following instructions here https://learn.microsoft.com/en-us/azure/cosmos-db/linux-emulator
I took a peek inside the container and located "default.sslcert.pfx" under the "/tmp/cosmos/appdata" folder. I am thinking this is the certificate being used by the emulator and needs to be trusted on the client machine connecting to the emulator. Is this a good assumption? Is this generated on startup? What password is used for this PFX file?
Now, I am trying to connect to it from the host using the Azure CLI. I am unable to find out how to go about connecting to the emulator cosmos instance using the Azure CLI which seems to require an Azure account name and doesn't seem to support connections with a connection string that contains the account key and account endpoint https://learn.microsoft.com/en-us/cli/azure/cosmosdb/sql/database?view=azure-cli-latest#az_cosmosdb_sql_database_list How would I go about connecting to the cosmosdb emulator running on linux from the azure cli also on linux?
Upvotes: 4
Views: 1457
Reputation: 222582
There is no AccountName when you run it using Emulator, you can use the Key in combination with dbname/partitionKey. Try creating a database using the key provided in the emulator as follows
az cosmosdb database create --key "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" --db-name "Families" --url-connection "https://localhost:8081"
Output:
and execute queries as follows,
az cosmosdb collection list --query "[].{CollectionName:id,PartitionKey:'address/zipCode'}" --key "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" --db-name "Families" --url-connection "https://localhost:8081" -o json
Upvotes: 0