In my Micronaut Azure Function I am using a binding @CosmosDBInput for event-sourcing like this:
public class ChatRoomFunction extends AzureFunction {
@FunctionName("handleCommand")
public HttpResponseMessage handleCommand(
@HttpTrigger(
name = "req",
methods = HttpMethod.POST,
authLevel = AuthorizationLevel.ANONYMOUS)
final HttpRequestMessage<Command> request,
@CosmosDBInput(
name = "events",
connectionStringSetting = CONNECTION_STRING,
databaseName = DATABASE_NAME,
collectionName = "events",
partitionKey = "events--{id}") final List<Event> events,
final ExecutionContext context
) {
// function body intentionally left out
}
}
// with
public class Command {
private UUID id;
// more fields, getters, setters
}
// and
public class Event {
private String streamId; // this is the CosmosDB partition key
// more fields, getters, setters
}
Before, I tried doing this using @TableInput which seemed to worked fine.
Now I've switched to CosmosDB and for some reason it seems to ignore my @CosmosDBInput's partitionKey value.
Expected: events should contain a list of only Events having a certain streamId as matched by the binding parameter of the request body, i.e. id.
Actual: events contains a list of ALL Events present in the events collection.
Am I missing something here? This is what the partitionKey is for, right?
In my Micronaut Azure Function I am using a binding
@CosmosDBInput
for event-sourcing like this:Before, I tried doing this using
@TableInput
which seemed to worked fine. Now I've switched to CosmosDB and for some reason it seems to ignore my@CosmosDBInput
'spartitionKey
value.Expected:
events
should contain a list of onlyEvent
s having a certainstreamId
as matched by the binding parameter of the request body, i.e.id
.Actual:
events
contains a list of ALLEvent
s present in theevents
collection.Am I missing something here? This is what the
partitionKey
is for, right?