-
-
Save darrenjrobinson/5792fe0907181ad0eeb6eb3a7b9cbd5b to your computer and use it in GitHub Desktop.
Register a new Azure IoT Device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module AzureIoT | |
Import-Module AzureRM | |
Login-AzureRmAccount | |
# Create New IoT Device | |
# IoT Hub RG & Location | |
$RGName = "MyMongooseIoTHub" | |
$location = "East US" | |
# IoT Hub | |
$IoTHubName = "MyMongooseIoTHub" | |
$IoTKeyName = "iothubowner" | |
$IoTHub = Get-AzureRmIotHub -Name $IoTHubName -ResourceGroupName $RGName | |
$IoTHubKey = Get-AzureRmIotHubKey -ResourceGroupName $iothub.Resourcegroup -Name $IoTHubName -KeyName $IoTKeyName | |
# IoT ConnectionString | |
$IoTConnectionString = "HostName=$($IoTHubName).azure-devices.net;SharedAccessKeyName=$($IoTKeyName);SharedAccessKey=$($IoTHubKey.PrimaryKey)" | |
# New DeviceID | |
$newDeviceID = "ESP8266_12345" | |
$deviceParams = @{ | |
iotConnString = $IoTConnectionString | |
deviceId = $newDeviceID | |
} | |
$device = Register-IoTDevice @deviceParams | |
$device |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment