Error while trying to connect to a device on azure using Visual Studio

Nitesh 20 Reputation points
2023-07-16T17:43:26.5633333+00:00

Hello Team,
I am trying to connect to a device which is created on Azure portal using visual studio for this i am using the basic code which visual studio provides for azure connection
Primary connection string on Azure : HostName=Androidio.azure-devices.net;DeviceId=Androidnew;SharedAccessKey=[secret]
Screenshot (611)

Screenshot (608)

Above image is code
Screenshot (609)

While building i am having warning saying
C:\Users\vn3.nuget\packages\microsoft.net.sdk.functions\4.2.0\build\Microsoft.NET.Sdk.Functions.Build.targets(32,5): warning : Function [Function1]: cannot find value named 'HostName=Androidio.azure-devices.net;DeviceId=Androidnew;SharedAccessKey=[secret]' in local.settings.json that matches 'connection' property set on 'eventHubTrigger'

If i go ahead and try running the project i am getting this errorScreenshot (612)

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
{count} votes

Answer accepted by question author
  1. Sander van de Velde | MVP 36,951 Reputation points MVP Volunteer Moderator
    2023-07-16T22:03:15.5+00:00

    Hello @Nitesh,

    great to see you are starting with Azure IoT.

    It seems you are combining two completely different pieces of code which will never fit together.

    The IoT Hub triggered Azure Function is designed to listen to incoming device messages coming from the IoT Hub.

    A device is normally an application running on an actual device like this one written in C# or this one written in Python.

    Please, take some time and learn about Azure IoT Device SDKs using the learning module, part of a complete Azure IoT learing path.

    Next to that, the Azure Functions training is also a perfect way to start learning about that topic.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.