components-contrib
components-contrib copied to clipboard
How to use Cosmos DB when container name is only known at runtime?
I'm working on a SaaS solution, and the users are allowed to create workspaces. Each workspace uses several CosmosDB containers pre-fixed with the workspace ID:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: invitations-store
namespace: default
spec:
type: state.azure.cosmosdb
version: v1
metadata:
- name: url
value: "https://xxxxxx.documents.azure.com:443/"
- name: masterKey
secretKeyRef:
name: "cosmosMasterKey"
- name: database
value: "xxxxxx"
- name: collection
value: "<WORKSPACE-ID>.environments" <-- HERE
- name: partitionKey
value: "id"
Is there a way to connect to a container without declaring a component? Can the component be declared at runtime?
I found a solution: Use partition keys instead of prefixed container names. However, could be able to use bindings that are only known at runtime be a real use case in some scenarios?
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.
would be nice if the collection name can be part of the metadata when invoking the component. i have multiple microservices and just want to have a single component to dapr and allow each microservice to define the collection. with the current approach need multiple components