Troubleshooting > Troubleshooting Device-Related Issues > Errors Caused by Device Deleted or Missing in Azure IoT
Errors Caused by Device Deleted or Missing in Azure IoT
Errors can occur for deleted or missing Things in the following situations:
A device is deleted from Azure IoT but still exists in ThingWorx.
A Thing is created in ThingWorx but not in Azure IoT.
* 
Although v.2.0 of the Azure IoT Hub Extension supported creation and deletion of devices in Azure IoT, v.3.0 of the Extension does NOT currently support these features. Given changes on both sides, the original implementation no longer works reliably with Azure IoT.
The rest of this topic describes situations and errors that may occur when a Thing or device is deleted or missing from Azure IoT. The solutions are the same in every case, so they are provided as the last section:
Updating a Property
If a device does not exist in Azure IoT when a property update is attempted, ThingWorx Composer displays a REST service failure. The message contains the ThingName only.
In the Connector log, the following exceptions/errors are written:

14:53:19.607 [pool-8-thread-2] WARN c.t.p.azure.iot.IotEgressHandler - Error writing to device;
device=testthing moduleId=null
java.util.concurrent.CompletionException:
com.microsoft.azure.sdk.iot.service.exceptions.IotHubNotFoundException: testthing
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:769)
at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
at com.microsoft.azure.sdk.iot.service.ServiceClient.lambda$sendAsync$2(ServiceClient.java:208)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.microsoft.azure.sdk.iot.service.exceptions.IotHubNotFoundException: testthing
at com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification.
amqpResponseVerifier(AmqpResponseVerification.java:72)
at com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification.
<init>(AmqpResponseVerification.java:43)
at com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler.
onDelivery(AmqpSendHandler.java:358)
at org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:185)
at org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)
at org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:324)
at org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:291)
at org.apache.qpid.proton.reactor.impl.ReactorImpl.run(ReactorImpl.java:357)
at com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSend.send(AmqpSend.java:133)
at com.microsoft.azure.sdk.iot.service.ServiceClient.send(ServiceClient.java:143)
at com.microsoft.azure.sdk.iot.service.ServiceClient.send(ServiceClient.java:123)
at com.microsoft.azure.sdk.iot.service.ServiceClient.lambda$sendAsync$2(ServiceClient.java:204)
... 5 common frames omitted
Updating the Twin/Module Twin
If a device does not exist in Azure IoT when a device twin or module twin update is attempted, ThingWorx Composer displays a REST service failure message. The message contains Error Code.
In the Connector log, the following error appears:

14:54:29.710 [ForkJoinPool.commonPool-worker-7] WARN c.t.p.azure.iot.IotEgressHandler -
Error writing to device; device=testthing moduleId=null
java.util.concurrent.CompletionException: com.microsoft.azure.sdk.iot.service.exceptions.IotHubNotFoundException:
ErrorCode:DeviceNotFound;testthing Tracking ID:45408cb17ee8469cb118330c5adac23f-TimeStamp:07/30/2019 18:54:29
at com.thingworx.protocol.azure.iot.util.TwinUtils.lambda$setTwinPropertyAsync$1(TwinUtils.java:153)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1582)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.microsoft.azure.sdk.iot.service.exceptions.IotHubNotFoundException: ErrorCode:DeviceNotFound;
testthing Tracking ID:45408cb17ee8469cb118330c5adac23f-TimeStamp:07/30/2019 18:54:29
at com.microsoft.azure.sdk.iot.service.exceptions.IotHubExceptionManager.
httpResponseVerification(IotHubExceptionManager.java:71)
at com.microsoft.azure.sdk.iot.service.devicetwin.DeviceOperations.request(DeviceOperations.java:137)
at com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin.getTwinOperation(DeviceTwin.java:107)
at com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin.getTwin(DeviceTwin.java:88)
at com.thingworx.protocol.azure.iot.util.TwinUtils.lambda$setTwinPropertyAsync$1(TwinUtils.java:147)
... 6 common frames omitted
Direct Methods
If a device does not exist in Azure IoT when a direct method is called, ThingWorx Composer displays the following message.

Unable to Invoke Service DeviceMethodServiceName on test_with_1_service_input_of_type_INTEGER-1564519522776 :
Device is not connected
In the Connector logs, the following error messages and exceptions appear:

16:47:00.948 [cxthing-remote-service-handler-1] WARN c.t.p.a.i.s.RemoteServiceHandler -
Error handling remote service request; service=DeviceMethodServiceName,
entityName=djc-hub::test_with_1_service_input_of_type_INTEGER-1564519522776,
params={param=com.thingworx.types.primitives.IntegerPrimitive@14d}, timeout=5
com.microsoft.azure.sdk.iot.service.exceptions.IotHubNotFoundException:
{"errorCode":404001,"trackingId":"be4fc44c0c6e458d9289ea75c2468bef-TimeStamp:07/30/2019 20:47:00",
"message":"test_with_1_service_input_of_type_INTEGER-1564519522776",
"timestampUtc":"2019-07-30T20:47:00.917639Z"}
at com.microsoft.azure.sdk.iot.service.exceptions.IotHubExceptionManager.
httpResponseVerification(IotHubExceptionManager.java:71)
at com.microsoft.azure.sdk.iot.service.devicetwin.DeviceOperations.
request(DeviceOperations.java:137)
at com.microsoft.azure.sdk.iot.service.devicetwin.DeviceMethod.
invokeMethod(DeviceMethod.java:175)
at com.microsoft.azure.sdk.iot.service.devicetwin.DeviceMethod.
invoke(DeviceMethod.java:81)
at com.thingworx.protocol.azure.iot.services.RemoteServiceHandler.
doInvokeRemoteService(RemoteServiceHandler.java:155)
at com.thingworx.protocol.azure.iot.services.RemoteServiceHandler.
genericInvokeRemoteService(RemoteServiceHandler.java:119)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.
invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.
invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.thingworx.connectionserver.ReflectiveApiRequestHandler.
test(ReflectiveApiRequestHandler.java:42)
at com.thingworx.connectionserver.ReflectiveApiRequestHandler.
test(ReflectiveApiRequestHandler.java:16)
at com.thingworx.connectionserver.CXThingImpl.
requestHandlerSync(CXThingImpl.java:224)
at com.thingworx.connectionserver.CXThingImpl.
lambda$requestHandler$0(CXThingImpl.java:201)
at java.util.concurrent.ThreadPoolExecutor.
runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.
run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Solutions
These errors occur because the device was not found. Check that the device still exists in Azure IoT, is active and connected to the Azure IoT Hub. If the device still exists, restart it and check its connection to the Azure IoT Hub. Then retry the package.
If the device does not exist in Azure, your next action depends on your needs. If appropriate, add the device again. Alternatively, remove it from ThingWorx, using one of the following ways:
Through ThingWorx Composer, manually invoke the DeleteThing service on the Thing.
Through the ThingWorx Java API, use the DeleteThing method of the EntityServices class. Refer to DeleteThing method description in the Javadoc for the API.
Through the REST API, use the DELETE HTTP method. Refer to Updating, Deleting, and Executing Through the API.