Azure-cli: No IoT Hub found with name in current subscription.

Created on 9 Nov 2018  路  15Comments  路  Source: Azure/azure-cli

Describe the bug
'No IoT Hub found with name Hydro-QA-Hub in current subscription.' error when executing
az iot hub device-identity create --device-id "testabe" --hub-name "hubName" --edge-enabled

To Reproduce

  1. az login -u -p
  2. az account set --subscription ""
  3. az iot hub show -n "" --resource-group ""
  4. az iot hub device-identity create --device-id "test" --hub-name "" --edge-enabled

Expected behavior
The edge device 'test' in the hubName should be created.

Environment summary

  1. Installed Azure CLI version 2 in windows machine.

Actual Result:
'No IoT Hub found with name Hydro-QA-Hub in current subscription.' error

IotHub Service Attention question

Most helpful comment

~I'm experiencing the same issue and _cannot_ resolve it with the steps outlined by @tjprescott~

Resolved by leaving out the azure-devices.net suffix

All 15 comments

@c-ryan-k

Hey @binishababu - if you run:
az iot hub show -n "Hydro-QA-Hub" -o table,
...do you get the same error?

Let's see if that hub exists inside the subscription you've set.

Try:
az account show -o table - just to sanity check that you're logged into the correct subscription. The "Name" column should match your subscription.

Once you verify that you're on the correct subscription, you can run:
az iot hub list -o table - to see all hubs in all resource groups that are in your subscription.

Do you see the hub you're looking for in there?

az account show -o table
EnvironmentName IsDefault Name State TenantId


AzureCloud True mysubscription Enabled 3d2d2b6f-061a-48b6-b4b3-9312d687e3a1

and the below command gives

az iot hub show -n "Hydro-QA-Hub" -o table

Operation returned an invalid status code 'Not Found'

Also

'az iot hub show -n "Hydro-QA-Hub" -o table 'gives an error as below

ResourceGroupNotFound - Resource group 'test-UAT-RG' could not be found.

The test-UAT-RG is in another subscription.

If the hub is in a resource group in another subscription you have two options:

1: specify --name NAME --resource-group GROUP and --subscription SUB_ID
2: specify --ids ID

Both of those approaches should work--if they don't it is a bug.

@tjprescott why this ticket is closed?

  1. I tried switching to the subscription
  2. Tried sprcifying the resource group and subscription name.

Nothing works.

Please reopen the ticket

any workaround for this issue?

@c-ryan-k for comment.

@binishababu - So just to make sure I can reproduce this issue, let's verify where your hub lives:

  1. Can you navigate to your hub in the portal? If so, can you verify which Resource Group the IoT Hub belongs to, and which Subscription that Resource Group belongs to?
  2. Can you verify that you have access to that subscription? Does it appear when you run:
    az account list -o table ?
  3. Can you make sure you're logged into that subscription by running:
    az account set --subscription [sub]
  4. Then, when you run az iot hub list -o table - do you see your hub?

If your hub lives inside a different subscription, then like @tjprescott mentioned, you can try to locate it within the RG and Subscription it belongs to:
az iot hub list --resource-group [RG] --subscription [sub]

@binishababu - Are you still encountering this issue? If so, please share your experience after following the steps above.

@binishababu can you let us know if you're still hitting this issue?

This still exists

Try only including the IoT Hub name - not the full name. Ie if the hub hostname is yourname.azure-devices.net - trying using yourname only.

@binishababu we need a bit more detail to continue as per comment from @c-ryan-k above. In the meantime I will close the issue. Please comment back and we can reopen

~I'm experiencing the same issue and _cannot_ resolve it with the steps outlined by @tjprescott~

Resolved by leaving out the azure-devices.net suffix

Was this page helpful?
0 / 5 - 0 ratings