Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.62 KB

File metadata and controls

42 lines (29 loc) · 1.62 KB
title include file
description include file
author SoniaLopezBravo
ms.author sonialopez
ms.service azure-iot-hub
ms.topic include
ms.date 03/28/2025

A device must be registered with your IoT hub before it can connect. In this section, you use Azure CLI to create a device identity.

If you already have a device registered in your IoT hub, you can skip this section.

To create a device identity:

  1. Run the az iot hub device-identity create command in your CLI shell. This command creates the device identity.

    YourIoTHubName. Replace this placeholder and the surrounding braces in the following command, using the name you chose for your IoT hub. An IoT hub name must be globally unique in Azure.

    myDevice. You can use this name for the device ID throughout this article, or provide a different device name.

    az iot hub device-identity create --device-id myDevice --hub-name {YourIoTHubName}
    
  2. Run the az iot hub device-identity connection-string show command.

    az iot hub device-identity connection-string show --device-id myDevice --hub-name {YourIoTHubName}
    

    The connection string output is in the following format:

    HostName=<your IoT Hub name>.azure-devices.net;DeviceId=<your device id>;SharedAccessKey=<some value>
    
  3. Save the connection string in a secure location.

Note

Keep your CLI app open. You use it in later steps.