Azure / Azure/data-api-builder

[Bug]: Issue adding Stored Procedures (Azure Cosmos DB / NoSQL / GraphQL)

Abierto
#1,915 4 comentarios 0 reacciones 1 asignado Reclamado por @sajeetharan Ver en GitHub
bug cosmos nosql triage
Lenguaje dominante
C#
Estrellas
1.5k
Forks
370
Merge medio
3 d 22 h
PR fusionados (30 d)
9

Descripción

### What happened?

Following the instructions [here](https://learn.microsoft.com/en-us/azure/data-api-builder/views-and-stored-procedures#graphql-support-for-stored-procedures), we've run into issues registering a stored procedure with DAB.

Within Azure Cosmos DB, NoSQL, there's a container called "Persons"
Attached to the container is a Stored Process called "DefaultStoredProc"

We've the following command to register the Stored Proc:

```bash
dab add DefaultStoredProc --source Persons.DefaultStoredProc --source.type "stored-procedure" --source.params "searchType:s" --permissions "anonymous:execute" --rest.methods "get" --graphql.operation "query" -c "[locationOfConfigFile].json"
```

That command populates the config file with the below:
```json
"DefaultStoredProc": {
"source": {
"object": "Persons.DefaultStoredProc",
"type": "stored-procedure",
"parameters": {
"searchType": "s"
}
},
"graphql": {
"enabled": true,
"operation": "query",
"type": {
"singular": "DefaultStoredProc",
"plural": "DefaultStoredProcs"
}
},
"rest": {
"enabled": false,
"methods": [
"post"
]
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "execute"
}
]
}
]
}
```

Nothing is created in the schema.gql file.

When we run this, using `dab start` (or `swa start`) we get the following error - `System.Collections.Generic.KeyNotFoundException: The given key 'DefaultStoredProc' was not present in the dictionary.`

Any and all advice greatly appreciated!

TY, Rich

### Version

0.9.7

### What database are you using?

CosmosDB NoSQL

### What hosting model are you using?

Local (including CLI)

### Which API approach are you accessing DAB through?

GraphQL

### Relevant log output

```Text
$ dab start -c .\staticwebapp.database.config.json

Information: Microsoft.DataApiBuilder 0.9.7+e560142426d1c080b9fd7b7fabff51a276f6bf61
Information: User provided config file: .\staticwebapp.database.config.json
Loading config file from .\staticwebapp.database.config.json.
Information: Loaded config file: .\staticwebapp.database.config.json
Information: Setting default minimum LogLevel: Error for Production mode.
Starting the runtime engine...
Loading config file from .\staticwebapp.database.config.json.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[63]
User profile is available. Using 'C:\Users\jacks\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
fail: Azure.DataApiBuilder.Service.Startup[0]
Unable to complete runtime initialization. Refer to exception for error details.
System.Collections.Generic.KeyNotFoundException: The given key 'DefaultStoredProc' was not present in the dictionary.
at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.ValidateStoredProceduresInConfig(RuntimeConfig runtimeConfig, ISqlMetadataProvider sqlMetadataProvider)
at Azure.DataApiBuilder.Service.Startup.PerformOnConfigChangeAsync(IApplicationBuilder app)
fail: Azure.DataApiBuilder.Service.Startup[0]
Could not initialize the engine with the runtime config file: .\staticwebapp.database.config.json
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
Unable to launch the Data API builder engine.
Error: Failed to start the engine.
```

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.