Azure / Azure/Azure-Functions

Can't receive data from Iot hub using azure functions

Aperta
#800 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
PowerShell
Stelle
1.1k
Fork
215
Merge medio
4h 2m
PR unite (30g)
1

Descrizione

Hello,

I'm trying to create azure function which receive messages from Iot hub and I get error
"Method not found" when I'm trying to create the receiver for Iot hub.
When I'm running the same project using console application instead of azure function project It's working.

I'm running on visual studio 2017 15.7.1, azure functions and web jobs version 15.0.40424.0.

To simulate the problem this is the code simplified to generate the error (there are some connections and variables you need to apply):

Create azure function project V1 from visual studio

(Im having microsoft.NET.Sdk.Function (1.0.13) and WindowsAzure.ServiceBus(4.1.9) nuggets)

```
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");

ServiceBusConnectionStringBuilder connectionStringBuilder =
new ServiceBusConnectionStringBuilder(IothubConnectionString) { TransportType = TransportType.Amqp };

MessagingFactory messagingFactory = MessagingFactory.CreateFromConnectionString(connectionStringBuilder.ToString());
eventHubClient = messagingFactory.CreateEventHubClient(IotHubD2CEndpoint);
d2CPartitions = eventHubClient.GetRuntimeInformation().PartitionIds;

List taskList = new List();

foreach (string partition in d2CPartitions)
{
var eventHubReceiver = eventHubClient.GetConsumerGroup(ConsumerGroup).
CreateReceiver(partition, DateTime.Now.AddDays(-5));
}
}
```

The function will not run and the line causing the error is the CreateReceiver method.

Creating console application with same code will run successfully.

How can I make it work and receive messages from Iot hub?

Thanks.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia dal punto di ingresso Function1 Run e dalla chiamata CreateReceiver nel codice fornito. Confronta il progetto Azure Functions che usa Microsoft.NET.Sdk.Function 1.0.13 e WindowsAzure.ServiceBus 4.1.9 con l’applicazione console funzionante, quindi riproduci l’errore Method not found. Il lavoro è completato quando la funzione attivata dal timer crea il receiver e riceve i messaggi di IoT Hub.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
azure, csharp
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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.