0

I can invoke device methods using ServiceClient (Microsoft.Azure.Devices.ServiceClient) from a function app in azure. That require IoTHubConnectionString being directly used when building the ServiceClient. However, this is the wrong approach because I provision devices using Device Provisioning Service using group enrollment therefore, I should not use the IoTHubConnectionString directly to build ServiceClient rather, I should be getting the IoTHubConnectionString from Device Provisioning Service Client (Microsoft.Azure.Devices.Provisioning.Service). Because, I would not know in which IoTHub the device is enrolled to.

I saw few examples where I can get the AssignedHub from Device Provisioning Service Client but do not know how to build a ServiceClient from the AssignedHub.

I successfully got the AssignedHub from DPS Service Client but failing to get IotHubConnectionString or a ServiceClient (Microsoft.Azure.Devices.ServiceClient), so that I can invoke Device Methods from my Function app.

hafij
  • 208
  • 2
  • 10
  • Hi @Hafij, can u share what kind of framework/devLangs is getting used in the local environment? – Sourav Mar 09 '23 at 10:15
  • I am using DotNet 6 and C# – hafij Mar 09 '23 at 10:17
  • In azure functions which trigger you are using? – Sourav Mar 09 '23 at 11:16
  • I am using service bus trigger by which I get the iothub device id, but the question I asked here is related to how I can invoke device methods for a particular device (in this case the deviceId I get from the trigger) not using the serviceClient which requires a predefined IotHubConnectionString (which I am doing now) but using the DPS ServiceClient so that I can be ignorant of the IotHub associated with the device. – hafij Mar 09 '23 at 13:02

0 Answers0