Azure / azure-iot-cli-extension

Azure IoT extension for Azure CLI
Other
83 stars 65 forks source link

[bug] CLI fails when trying to delete a message-endpoint #650

Closed sebsmgzz closed 1 year ago

sebsmgzz commented 1 year ago

Describe the bug When trying to run the command to delete a message-endpoint, the CLI throws an error and fails. Then I go to the portal to very if the endpoint was deleted, and the endpoint is still visible in the corresponding part of the portal.

To Reproduce

  1. Setup and iothub in azure. Name it whatever you want
  2. Setup a message-route in azure
  3. Try to delete it by running the following command:
IOT_HUB_NAME ="<your iot hub name here>"
ENDPOINT_NAME ="<your endpoint name here>"
az iot hub message-endpoint delete --hub-name $IOT_HUB_NAME --endpoint-name $ENDPOINT_NAME -y
  1. Watch the command fail

Expected behavior The command should fail and the endpoint should be gone after running the command.

Example

IOT_HUB_NAME="omitted-because-irrelevant"
ENDPOINT_NAME="SasTokenRequestsEndpoint"
$ az iot hub message-endpoint delete --hub-name $IOT_HUB_NAME --endpoint-name $ENDPOINT_NAME -y
Command group 'iot hub message-endpoint' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
(400131) Enrichment has an undefined endpoint, Enrichment Key:iothub-connection-iothub-id, EndpointName:SasTokenRequestsEndpoint. If you contact a support representative please include this correlation identifier: 798865e0-fcbf-42c4-a1e6-7eca7713cb5a, timestamp: 2023-03-30 18:17:40Z, errorcode: IH400131.
Code: 400131
Message: Enrichment has an undefined endpoint, Enrichment Key:iothub-connection-iothub-id, EndpointName:SasTokenRequestsEndpoint. If you contact a support representative please include this correlation identifier: 798865e0-fcbf-42c4-a1e6-7eca7713cb5a, timestamp: 2023-03-30 18:17:40Z, errorcode: IH400131.
digimaun commented 1 year ago

Hi @sebsmgzz , to delete a message endpoint first the routes and msg enrichments associated with the endpoint need to be deleted. You can use the az iot hub message-enrichment delete command to delete existing enrichments.

After ensuring the removal of these associations, please let us know if deleting the message endpoint works.

sebsmgzz commented 1 year ago

Hi @digimaun, you are correct. The endpoint had both, a message route and enrichment associations, after deleting does, the command deletes the endpoint as expected. I am running an automated script which isn't taking that into consideration. Thanks for the help.

digimaun commented 1 year ago

Cool very glad you got things working. Will close this issue.