MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.2k stars 21.35k forks source link

Getting error : Error registering device for DPS : Resolved after performing few additional steps in IoT central Application which seem to be currently missing in the document #48511

Closed isagrwl closed 4 years ago

isagrwl commented 4 years ago

Although the document specifies : "Complete the Create an Azure IoT Central application quickstart to create an IoT Central application using the Custom app > Custom application template." , it is not evident if we need to go to the next step of creating a 'simulated device' or not. I initially only created an application and did not add 'simulated device'. After this I was getting error specified in point#4 under 'Build the code'. Even after several retries I was still getting the same error. To fix this, I added a device in my IOTC application, with device id mxchip-001 and then clicked Approved. This fixed the issue.

Request you to please look into this and update the documentation if needed.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

AshokPeddakotla-MSFT commented 4 years ago

@isagrwl Thanks for the feedback! We are currently investigating and will update you shortly.

dominicbetts commented 4 years ago

Hi @isagrwl - thanks for getting in touch. You shouldn't need to add a device template to complete this tutorial. I just stepped through it and although the first time I ran the device code I saw the DPS error, the second time I ran it (as per the note in the article), it worked as expected. Can you confirm that in your IoT Central application Auto approve is enabled on the Administration > Device connection page?

For reference, here's what I saw when I ran the client code (some parameters redacted):

c:\temp\central-app\devkit_device\cmake>.\Release\devkit_device.exe mxchip-001 -myscopeid- -myprimarykey-
Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_device_ll_client.c Func:_prov_transport_process_json_reply Line:658 Provisioning Failure: OperationId: 4.22d9be6e95a09645.5f6b2530-1db4-4135-b3c7-51a52cb631d8 - Date: 2020-02-20T14:27:58.0656187Z - Msg: Custom allocation failed with status code: 404
Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_transport_mqtt_common.c Func:_prov_transport_common_mqtt_dowork Line:1014 Unable to process registration reply.
Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_device_ll_client.c Func:_on_transport_registration_data Line:770 Failure retrieving data from the provisioning service
Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\central-app\devkit_device\main.c Func:_provisioningRegisterCallback Line:82 DPS Provisioning callback called with error state 7
Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\central-app\devkit_device\main.c Func:_registerDevice Line:165 Error registering device for DPS

c:\temp\central-app\devkit_device\cmake>.\Release\devkit_device.exe mxchip-001 -myscopeid- -myprimarykey-
Info: Provisioning callback indicates success.  iothubUri=iotc-........7.azure-devices.net, deviceId=mxchip-001
Info: DPS successfully registered.  Continuing on to creation of IoTHub device client handle.
Info: Successfully created DigitalTwin device with connectionString=<****>, deviceHandle=<00FA0B08>
Info: DigitalTwin Interface : Changing interface state on interface deviceinfo from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED
Info: DEVICEINFO_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=<urn:azureiot:DeviceManagement:DeviceInformation:1>, interfaceInstanceName=<deviceinfo>, handle=<00FA5800>
Info: DigitalTwin Interface : Changing interface state on interface sensors from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED
Info: SENSORS_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=<urn:mxchip:built_in_sensors:1>, interfaceInstanceName=<sensors>, handle=<00FA5A80>
Info: DigitalTwin Interface : Changing interface state on interface leds from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED
Info: LEDS_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=<urn:mxchip:built_in_leds:1>, interfaceInstanceName=<leds>, handle=<00FA5350>
Info: DigitalTwin Interface : Changing interface state on interface screen from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED
Info: SCREEN_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=<urn:mxchip:screen:1>, interfaceInstanceName=<screen>, handle=<00FA5710>
Info: DigitalTwin Interface : Changing interface state on interface settings from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED
Info: SETTINGS_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=<urn:mxchip:settings:1>, interfaceInstanceName=<settings>, handle=<00FA5670>
Info: DigitalTwin Interface : Changing interface state on interface deviceinfo from DT_INTERFACE_STATE_CREATED to DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE
Info: DigitalTwin Interface : Changing interface state on interface sensors from DT_INTERFACE_STATE_CREATED to DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE
Info: DigitalTwin Interface : Changing interface state on interface leds from DT_INTERFACE_STATE_CREATED to DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE
isagrwl commented 4 years ago

Thanks Dominic for trying it out. It’s good to know that the setup is working for you. Yes, I do have Auto approve selected by default. I tried to follow the document as is but still facing the issue after multiple tries.

Few other observations: The error I receive is different from yours: E:\CSS\SDKs\central_app\devkit_device\cmake>.\Release\devkit_device.exe mxchip-001 --scope id-- --primary key-- Error: Time:Thu Feb 20 11:49:28 2020 File:E:\CSS\SDKs\vcpkg\vcpkg_pnp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_device_ll_client.c Func:_prov_transport_process_json_reply Line:670 Unsuccessful json encountered: {"errorCode":401000,"trackingId":"42a2c6b6-75b3-4ba8-9a34-09c345d0f2bb","message":"Unauthorized","timestampUtc":"2020-02-20T19:49:28.2529747Z"} Error: Time:Thu Feb 20 11:49:28 2020 File:E:\CSS\SDKs\vcpkg\vcpkg_pnp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_transport_mqtt_common.c Func:_prov_transport_common_mqtt_dowork Line:1014 Unable to process registration reply. Error: Time:Thu Feb 20 11:49:28 2020 File:E:\CSS\SDKs\vcpkg\vcpkg_pnp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_device_ll_client.c Func:_on_transport_registration_data Line:770 Failure retrieving data from the provisioning service Error: Time:Thu Feb 20 11:49:28 2020 File:E:\CSS\SDKs\central_app\devkit_device\main.c Func:_provisioningRegisterCallback Line:82 DPS Provisioning callback called with error state 7 Error: Time:Thu Feb 20 11:49:28 2020 File:E:\CSS\SDKs\central_app\devkit_device\main.c Func:_registerDevice Line:165 Error registering device for DPS

Few other observations: If I use the ‘primary key’, I get the above error but Device templates and Devices section in IOTC is still blank. I replaced ‘primary key’ with ‘device key’, I do get the same error as above but Devices and Device templates now show the device and template. But I see that the device is not Simulated and am not getting any data.

I got the ‘Primary key’ after clicking the link ‘View Keys’ on the Device connection page.

I selected ‘CMake Project on Windows’ as the project type instead of ‘MXChip IoT DevKit Project’ as suggested in the documentation.

The documentation seems pretty straightforward but somehow I am missing something.

Thanks, Ishu

From: Dominic Betts notifications@github.com Sent: Thursday, February 20, 2020 8:12 AM To: MicrosoftDocs/azure-docs azure-docs@noreply.github.com Cc: Ishu Agarwal Ishu.Agarwal@microsoft.com; Mention mention@noreply.github.com Subject: Re: [MicrosoftDocs/azure-docs] Getting error : Error registering device for DPS : Resolved after performing few additional steps in IoT central Application which seem to be currently missing in the document (#48511)

Hi @isagrwlhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fisagrwl&data=02%7C01%7CIshu.Agarwal%40microsoft.com%7C523e7473cfb14a34fa3208d7b61f9f31%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637178119238177102&sdata=aXEtFnhBTBYfRRonegrAaZmTg%2BUcxstKjZy8nLpTKz8%3D&reserved=0 - thanks for getting in touch. You shouldn't need to add a device template to complete this tutorial. I just stepped through it and although the first time I ran the device code I saw the DPS error, the second time I ran it (as per the note in the article), it worked as expected. Can you confirm that in your IoT Central application Auto approve is enabled on the Administration > Device connection page?

For reference, here's what I saw when I ran the client code (some parameters redacted):

c:\temp\central-app\devkit_device\cmake>.\Release\devkit_device.exe mxchip-001 -myscopeid- -myprimarykey-

Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_device_ll_client.c Func:_prov_transport_process_json_reply Line:658 Provisioning Failure: OperationId: 4.22d9be6e95a09645.5f6b2530-1db4-4135-b3c7-51a52cb631d8 - Date: 2020-02-20T14:27:58.0656187Z - Msg: Custom allocation failed with status code: 404

Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_transport_mqtt_common.c Func:_prov_transport_common_mqtt_dowork Line:1014 Unable to process registration reply.

Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\vcpkg\buildtrees\azure-iot-sdk-c\src\8ff96160cc-bd25b8f0be\provisioning_client\src\prov_device_ll_client.c Func:_on_transport_registration_data Line:770 Failure retrieving data from the provisioning service

Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\central-app\devkit_device\main.c Func:_provisioningRegisterCallback Line:82 DPS Provisioning callback called with error state 7

Error: Time:Thu Feb 20 14:28:01 2020 File:C:\temp\central-app\devkit_device\main.c Func:_registerDevice Line:165 Error registering device for DPS

c:\temp\central-app\devkit_device\cmake>.\Release\devkit_device.exe mxchip-001 -myscopeid- -myprimarykey-

Info: Provisioning callback indicates success. iothubUri=iotc-........7.azure-devices.net, deviceId=mxchip-001

Info: DPS successfully registered. Continuing on to creation of IoTHub device client handle.

Info: Successfully created DigitalTwin device with connectionString=<****>, deviceHandle=<00FA0B08>

Info: DigitalTwin Interface : Changing interface state on interface deviceinfo from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED

Info: DEVICEINFO_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=, interfaceInstanceName=, handle=<00FA5800>

Info: DigitalTwin Interface : Changing interface state on interface sensors from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED

Info: SENSORS_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=, interfaceInstanceName=, handle=<00FA5A80>

Info: DigitalTwin Interface : Changing interface state on interface leds from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED

Info: LEDS_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=, interfaceInstanceName=, handle=<00FA5350>

Info: DigitalTwin Interface : Changing interface state on interface screen from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED

Info: SCREEN_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=, interfaceInstanceName=, handle=<00FA5710>

Info: DigitalTwin Interface : Changing interface state on interface settings from DT_INTERFACE_STATE_INVALID to DT_INTERFACE_STATE_CREATED

Info: SETTINGS_INTERFACE: Created DIGITALTWIN_INTERFACE_CLIENT_HANDLE successfully for interfaceId=, interfaceInstanceName=, handle=<00FA5670>

Info: DigitalTwin Interface : Changing interface state on interface deviceinfo from DT_INTERFACE_STATE_CREATED to DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE

Info: DigitalTwin Interface : Changing interface state on interface sensors from DT_INTERFACE_STATE_CREATED to DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE

Info: DigitalTwin Interface : Changing interface state on interface leds from DT_INTERFACE_STATE_CREATED to DT_INTERFACE_STATE_BOUND_TO_CLIENT_HANDLE

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoftDocs%2Fazure-docs%2Fissues%2F48511%3Femail_source%3Dnotifications%26email_token%3DAOL3I6HK6CBS3EXMCE44ECDRD2TVFA5CNFSM4KYDQWX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMO5ZVY%23issuecomment-589159639&data=02%7C01%7CIshu.Agarwal%40microsoft.com%7C523e7473cfb14a34fa3208d7b61f9f31%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637178119238187101&sdata=J%2FegUDumcuUw7lakiZpbwkDfx%2FM3rYTm7pnuYOhmYpc%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAOL3I6CTWZB3K3A3O2WXCUDRD2TVFANCNFSM4KYDQWXQ&data=02%7C01%7CIshu.Agarwal%40microsoft.com%7C523e7473cfb14a34fa3208d7b61f9f31%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637178119238187101&sdata=Ligv3rBooII6Vt6%2B6aRwDlX44zlT0GRXtNWjBBCI2Mc%3D&reserved=0.

dominicbetts commented 4 years ago

Hi @isagrwl - I'm investigating further as to why you're seeing different results - I'll be back with an update shortly. Thanks for your patience.

dominicbetts commented 4 years ago

Thanks again for your patience.

At present, IoT Central applications created using the Custom application template do not support IoT Plug and Play devices - IoT Plug and Play is currently in public preview. For the time being, if you want to connect a PnP device to your IoT Central application you should contact technical support and request that PnP support is enabled in your application (follow the Technical support link from the help menu in your application). I hadn't realized that support for PnP had been enabled in the application I was using to test.

If you want to try out connecting a non-PnP client to your IoT Central app, we have a new tutorial: https://docs.microsoft.com/azure/iot-central/core/tutorial-connect-device

I hope that explains everything! I'll close this issue now, but feel free to reopen it if you have any follow-up questions.

please-close

isagrwl commented 4 years ago

Thanks @donimicbetts, that does explain why it doesn't work. But shouldn't that be mentioned as part of the document? The document asks to create a Custom application for Connecting a PnP device but in reality Custom applications are not supporting PnP devices. So, nobody will be able to get this working. I have spent hours to get this working and there will be other Customers trying to use PnP and will face the same issue. The only limitation the document states is that of the Region (Will be good to have a link here to : https://docs.microsoft.com/en-us/azure/iot-pnp/overview-iot-plug-and-play#regional-availability ). Also, how will one ensure that the IOTC application gets created in one of the supported Regions as it just provides United States while creating the application. May be if I am able to create the application in the supported region, it may work for me.

dominicbetts commented 4 years ago

Hi @isagrwl - thanks for the comments. We added a note the article last week explaining that it's currently necessary to contact technical support to enable PnP functionality in an IoT Central application. I'll update the article (and leave a comment here) as soon as this restriction is removed and you can use the PnP functionality directly. Thanks for your patience.

dominicbetts commented 4 years ago

Hi @isagrwl - just to follow up on a couple of items. PnP should be enabled on IoT Hub in all regions now - and there's no longer a need to contact support to have PnP enabled on any new IoT Central applications you create. Thank you.