Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos client does not allow creation of containers #24

Open
hqva opened this issue May 2, 2023 · 2 comments
Open

Cosmos client does not allow creation of containers #24

hqva opened this issue May 2, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@hqva
Copy link

hqva commented May 2, 2023

New containers or databases cannot be created with the cosmos client despite the user having permissions to do so.

This is the case both

  1. when logging in with a DefaultAzureCredential() for a user that has permissions to create a container via the azure portal
  2. when specifying a COSMOSDB_KEY

This bug can be reproduced with the following code:

from app import cosmos_client
client = cosmos_client()

# databases cannot be created
db_name = "db"
db = client.create_database(db_name)

# if a database is created via the azure portal, a container cannot be created within it
container_name = "cont"
database_client = client.get_database_client(db_name)
database_client.create_container(id= container_name, partition_key="/Id")
@hqva hqva added the bug Something isn't working label May 2, 2023
@lawrenceadams
Copy link
Contributor

lawrenceadams commented May 3, 2023

Looks like this is expected behaviour, as the cosmos client with RBAC is only to read/write data and not for resource provisioning - including database or container creation

I think we're gonna have to fart about with azure.mgmt.cosmosdb.CosmosDBManagementClient to actually create containers and databases 🤔 ?like this

@jedheaj314 Have I completely lost the plot?

@hqva
Copy link
Author

hqva commented May 3, 2023

Is it then simplest to make it part of the terraform/ initial provisioning process when the seedlings are initially made? Give app developers a single prescribed database and container that is then used for all state storage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants