Add-AzIotHubDevice

Create a device in an IoT Hub.

Syntax

Add-AzIotHubDevice
   [-ResourceGroupName] <String>
   [-IotHubName] <String>
   [-DeviceId] <String>
   [-AuthMethod <PSDeviceAuthType>]
   [-Status <PSDeviceStatus>]
   [-StatusReason <String>]
   [-EdgeEnabled]
   [-Children <String[]>]
   [-ParentDeviceId <String>]
   [-Force]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-AzIotHubDevice
   [-InputObject] <PSIotHub>
   [-DeviceId] <String>
   [-AuthMethod <PSDeviceAuthType>]
   [-Status <PSDeviceStatus>]
   [-StatusReason <String>]
   [-EdgeEnabled]
   [-Children <String[]>]
   [-ParentDeviceId <String>]
   [-Force]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-AzIotHubDevice
   [-ResourceId] <String>
   [-DeviceId] <String>
   [-AuthMethod <PSDeviceAuthType>]
   [-Status <PSDeviceStatus>]
   [-StatusReason <String>]
   [-EdgeEnabled]
   [-Children <String[]>]
   [-ParentDeviceId <String>]
   [-Force]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Create a device with different authorization type in an IoT Hub.

Examples

Example 1

Add-AzIotHubDevice -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -DeviceId "myDevice1" -AuthMethod "shared_private_key" -EdgeEnabled

Create an edge enabled IoT device with default authorization (shared private key).

Example 2

Add-AzIotHubDevice -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -DeviceId "myDevice2" -AuthMethod "x509_ca" -Status Disabled -StatusReason "Some Reason"

Create an IoT device with root CA authorization with disabled status and reason.

Example 3

Add-AzIotHubDevice -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -DeviceId "myDevice1" -AuthMethod "shared_private_key" -EdgeEnabled -Children device1,device2

Create an edge enabled IoT device and add child devices to it.

Example 4

Add-AzIotHubDevice -ResourceGroupName "myresourcegroup" -IotHubName "myiothub" -DeviceId "myDevice1" -AuthMethod "shared_private_key" -ParentDeviceId parentDevice1

Create an IoT device and set its parent device.

Parameters

-AuthMethod

The authorization type an entity is to be created with.

Type:PSDeviceAuthType
Accepted values:shared_private_key, x509_thumbprint, x509_ca
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Children

Add child device list (comma separated) includes only non-edge devices.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DeviceId

Target Device Id.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-EdgeEnabled

Flag indicating edge enablement.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Overwrites the non-edge device's parent device.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

IotHub object

Type:PSIotHub
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-IotHubName

Name of the Iot Hub

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ParentDeviceId

Id of edge device.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PrimaryThumbprint

Explicit self-signed certificate thumbprint to use for primary key.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Name of the Resource Group

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceId

IotHub Resource Id

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SecondaryThumbprint

Explicit self-signed certificate thumbprint to use for secondary key.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Status

Set device status upon creation.

Type:PSDeviceStatus
Accepted values:Enabled, Disabled
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-StatusReason

Description for device status.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

PSIotHub

String

Outputs

PSDevice