Azure / Azure/azure-functions-java-library

SQL trigger not working for java function apps

Ouverte
#201 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Java
Étoiles
45
Forks
49
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

I try to create a SQL trigger in a java function app. However I get this error:
```txt
Azure Functions Core Tools
Core Tools Version: 4.0.5413 Commit hash: N/A (64-bit)
Function Runtime Version: 4.25.3.21264

[2023-10-23T10:55:58.376Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[2023-10-23T10:55:58.403Z] The 'MySQLTrigger' function is in error: The binding type(s) 'sqlTrigger' were not found in the configured extension bundle. Please ensure the type is correct and the correct version of extension bundle is configured.
For detailed output, run func with --verbose flag.
```

Here is my java code:
```java
@FunctionName("MySQLTrigger")
public void run(
@SQLTrigger(
name = "items",
tableName = "[dbo].[TodoItem]",
connectionStringSetting = "SqlConnectionString")
TodoItems[] items,
final ExecutionContext context) {
...
}
```

Here is my `host.json`:
```json
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
```

---

I also tried removing the extension bundle and installing the sql extension directly by running this command:
```bash
func extensions install --package Microsoft.Azure.WebJobs.Extensions.Sql --version 3.0.396
```
which creates a file named `extensions.csproj` in my root folder and results in this error message:
```txt
[2023-10-23T11:03:11.118Z] Failed to start SQL trigger listener for table: 'partner.kontaktmapping', function ID: '302b12208735c890'. Exception: System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on
this platform.
[2023-10-23T11:03:11.119Z] at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString)
[2023-10-23T11:03:11.120Z] at Microsoft.Azure.WebJobs.Extensions.Sql.SqlTriggerListener`1.StartAsync(CancellationToken cancellationToken)
[2023-10-23T11:03:11.121Z] The listener for function 'Functions.PartnerSenderCosmosDBTrigger' was unable to start.
[2023-10-23T11:03:11.123Z] The listener for function 'Functions.PartnerSenderCosmosDBTrigger' was unable to start. Microsoft.Data.SqlClient: Microsoft.Data.SqlClient is not supported on this platform.
```
This is the output of `dotnet --info`
```txt
dotnet --info
.NET SDK:
Version: 7.0.402
Commit: 791db8e2d8

Laufzeitumgebung:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.402\

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```
I'd expect `SQLTrigger` to work as stated in [this tutorial](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-azure-sql-trigger?tabs=isolated-process%2Cportal&pivots=programming-language-java).

In addition to this tutorial I had to install the additional maven dependencies `azure-functions-java-library-sql` that was not mentioned in the tutorial. I have absolutely no experience working with dotnet and its runtime environment and development kits, so I might have done a mistake somewhere or missed some more steps needed.

If you need some more information on my setup, please let me know. I'm looking forward to any news on this.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez par la fonction Java montrée dans l’issue, host.json et le extensions.csproj généré, puis comparez leur configuration avec le Azure SQL trigger tutorial lié et la dépendance azure-functions-java-library-sql ajoutée. Reproduisez le binding sqlTrigger manquant et l’erreur de plateforme Microsoft.Data.SqlClient avec les versions de Core Tools et de .NET indiquées. C’est terminé lorsque le Java SQL trigger est détecté et que son listener démarre sans aucune des deux erreurs.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
azure, java, sql
Domaine
backend, databases
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.