Can't receive data from Iot hub using azure functions
- Vorherrschende Sprache
- PowerShell
- Sterne
- 1.1k
- Forks
- 215
- Ø Merge
- 4 Std. 2 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne beim Function1 Run-Einstiegspunkt und beim CreateReceiver-Aufruf im bereitgestellten Code. Vergleiche das Azure Functions-Projekt, das Microsoft.NET.Sdk.Function 1.0.13 und WindowsAzure.ServiceBus 4.1.9 verwendet, mit der funktionierenden Konsolenanwendung, und reproduziere den Fehler Method not found. Die Aufgabe ist abgeschlossen, wenn die timergetriggerte Funktion den Receiver erstellt und IoT Hub-Nachrichten empfängt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- azure, csharp
- 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