Azure / Azure/azure-functions-java-library

@CosmosDBInput ignores partitionKey

Offen
#134 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:java-functions
Vorherrschende Sprache
Java
Sterne
45
Forks
49
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit der @CosmosDBInput-Annotation auf handleCommand und verfolge, wie ihr partitionKey-Wert aus dem Request-Body aufgelöst wird. Reproduziere das Beispiel mit der events collection und überprüfe anschließend, ob das Binding nach der angeforderten streamId filtert; als erledigt gilt dies, wenn das Binding nur übereinstimmende Events zurückgibt oder das unterstützte Verhalten eindeutig dokumentiert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, java
Bereich
backend, cloud
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.