How to link an IoT Hub from a different subscription to the Device Provisioning Service

JV 0 Reputation points
2023-06-26T10:35:23.95+00:00

UPDATE: Assigning an enrollment to the newly added IoT Hub seems to work, a new device is created on the corresponding IoT Hub after the first provisioning request has been made by a client. The problem seems to be confined to the details display on the Azure portal.


We have IoT Hubs in multiple subscriptions (development, testing, production) and want to link them to a central Device Provisioning Service instance which is in a separate subscription.

Adding the IoT Hub to the DPS using az cli goes through without an error and the new IoT Hub is shown in the summary:

$ az iot dps linked-hub create --dps-name <DPS name> --resource-group <resource group name> --connection-string <current iothubowner connection string> --location <location string from Export template on the IoT Hub page>
[
  {
    "allocationWeight": null,
    "applyAllocationPolicy": null,
    "connectionString": "HostName=xxxxxxxx.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=****",
    "location": "westeurope",
    "name": "xxxxxxxx.azure-devices.net"
  },
  {
    "allocationWeight": null,
    "applyAllocationPolicy": null,
    "connectionString": "HostName=xxxxxxxx.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=****",
    "location": "westeurope",
    "name": "xxxxxxxx.azure-devices.net"
  },
  {
    "allocationWeight": null,
    "applyAllocationPolicy": null,
    "connectionString": "HostName=xxxxxxxx.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=****",
    "location": "westeurope",
    "name": "xxxxxxxx.azure-devices.net"
  }
]

The first two entries are IoT Hubs which are in the same subscription as the DPS and were added via the portal, the third entry is the newly added IoT Hub from the other subscription.

The newly added IoT Hub is also shown in the "Linked IoT hubs" table on the portal, but opening the IoT Hub's details page shows the following error:

image.png

Also, only the values available from the connection string are shown on the details page, the Tier value is empty.

According to the portal, the IoT Hub is reachable from all networks

image.png

and connecting via shared access policies is also permitted. We are using the same iothubowner connection string to manipulate device twins from different locations inside and outside the Azure network.

image.png

The only maybe related issue we have found on the internet is https://github.com/Azure/azure-cli/issues/22257 but we have verified that the provided location string exactly matches that of the resource.

Are there any other permissions required on the DPS, IoT Hub or subscription level to make such a setup work?

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 17,866 Reputation points Moderator
    2023-06-26T22:57:54.6066667+00:00

    Hi @JV Greetings! Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    I would like you to check if you got a chance to try and access the IoT Hub from the Azure portal before linking the IoT Hub to the DPS. I have created an IoT Hub through Azure portal on a different subscription and validated the IoT Hub is behaving as expected on the portal before linking with DPS.

    The command you have executed should only establish a connection between Azure DPS and IoT Hub. It should not alter the behavior of IoT Hub in any way. I recommend you check the IoT Hub before establishing a connection and let us know your observations.

    I have tested the same command to establish a connection to IoT Hub on a different subscription. I have got the similar output from the command execution as you pointed. Please find the below image for reference.

    User's image

    I have made sure that the Azure CLI, core and extensions are on latest versions by verifying az --version command. Here are the details on the command.

    User's image

    If you notice your CLI is not up to date, you can execute the az upgrade command to upgrade any dependencies.

    Please find the below image showing information on the Device Provisioning Service information

    User's image

    Here is my IoT Hub displaying correct data on the portal after being linked.

    User's image

    Kindly note that I did not explicitly provide any additional configuration information on either DPS or IoT Hub.

    Hope this helps.

    0 comments No comments

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.