Delete registered devices with IoT

You could use the sdk RemoveDeviceAsync(String), try the code below, it works on my side. The connection string you can find in your IoT Hub in the portal -> Shared access policies -> click iothubowner.

Delete registered devices with IoT

You could use the sdk  RemoveDeviceAsync(String), try the code below, it works on my side.

The connection string you can find in your IoT Hub in the portal -> Shared access policies -> click iothubowner.

 public static async Task DeleteDevice()
    {
        try
        {
            var registryManager = RegistryManager.CreateFromConnectionString("HostName=xxxx.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=xxxxxxxx");
            await registryManager.RemoveDeviceAsync("");

        }
        catch (Exception ex)
        {
            Console.WriteLine();
            Console.WriteLine("Error in sample: {0}", ex.Message);
        }

    }