Azure / Azure/azure-functions-java-library
@CosmosDBInput ignores partitionKey
- Lingua principale
- Java
- Stelle
- 45
- Fork
- 49
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
In my [Micronaut Azure Function](https://micronaut-projects.github.io/micronaut-azure/latest/guide/index.html) I am using a binding `@CosmosDBInput` for event-sourcing like this:
```java
public class ChatRoomFunction extends AzureFunction {
@FunctionName("handleCommand")
public HttpResponseMessage handleCommand(
@HttpTrigger(
name = "req",
methods = HttpMethod.POST,
authLevel = AuthorizationLevel.ANONYMOUS)
final HttpRequestMessage request,
@CosmosDBInput(
name = "events",
connectionStringSetting = CONNECTION_STRING,
databaseName = DATABASE_NAME,
collectionName = "events",
partitionKey = "events--{id}") final List 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 `Event`s having a certain `streamId` as matched by the binding parameter of the request body, i.e. `id`.
**Actual**: `events` contains a list of ALL `Event`s present in the `events` collection.
Am I missing something here? This is what the `partitionKey` is for, right?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia con l’annotazione @CosmosDBInput su handleCommand e segui come viene risolto il suo valore partitionKey dal corpo della richiesta. Riproduci l’esempio con la raccolta events, quindi verifica se il binding filtra in base allo streamId richiesto; il lavoro è completato quando il binding restituisce solo gli eventi corrispondenti o documenta chiaramente il comportamento supportato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- azure, java
- Ambito
- backend, cloud
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100