Can't receive data from Iot hub using azure functions
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 215
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.