"az aks list" gives "(ResourceGroupNotFound) Resource group 'akstest-rg1' could not be found."

Mark Neves 106 Reputation points
2021-08-03T09:56:46.043+00:00

I created an AKS cluster in an RG called "akstest-rg1". I then deleted the cluster, including the RG "akstest-rg1".

I then created a new AKS cluster with the same name in a different RG.

Since then I get the error (ResourceGroupNotFound) Resource group 'akstest-rg1' could not be found for some commands, "az aks list" being one of them.

It's as if the API is thinking the new cluster has an association with the deleted RG, possibly because it has the same name?

Any idea how to fix this?

Azure Kubernetes Service
Azure Kubernetes Service
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,457 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mark Neves 106 Reputation points
    2021-08-10T10:11:01.077+00:00

    Hi @shiva patpi

    Solved!

    Uninstalling and reinstalling az cli didn't do anything. Then I had a brain wave and looked in the c:\users***.azure folder and found this in the config file:

    [defaults]
    group = akstest-rg1

    I must have set that at some point during my playing around with Azure. Anyway, I just deleted the group setting and the error has gone.

    Top tip trying it out in the cloud shell when you have issues like this.

    Thanks,
    Mark

    2 people found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. shiva patpi 13,366 Reputation points Microsoft Employee Moderator
    2021-08-03T14:24:16.65+00:00

    Hello @Mark Neves ,
    Thanks for your query . I just tried to repro your exact scenario locally but it's working fine for me .
    Did you delete the AKS cluster first and then RG ? Or directly RG itself ? ( Either way it should not matter)
    Can you provide relevant screen shots with outputs for which commands you are getting the error (Just for validation)
    Do you see that resource group under resources.azure.com ?

    Couple of options:

    1. If you have multiple subscriptions , try to set the right context:
      az account set --subscription <subscription-id>
      Run those previous commands which shows that error (i.e. ResourceGroupNotFound)
    2. Can you try creating a new RG with same name akstest-rg1 and the Try deleting the RG ?
    3. Try to create the same cluster under the same RG akstest-rg1 and then delete the RG directly instead of deleting AKS cluster followed by RG.
    1 person found this answer helpful.
    0 comments No comments

  2. chrisw 81 Reputation points
    2022-03-12T13:52:17.48+00:00

    The default resource group can also be removed with the "az configure" command:

    az configure --defaults group=''

    This worked better for me since I am using a different OS and couldn't readily locate the config file.

    1 person found this answer helpful.

  3. Mark Neves 106 Reputation points
    2021-08-05T09:59:04.523+00:00

    Thanks for getting back to me @shiva patpi . Sounds like I may have something peculiar to my subscription.

    I used terraform to create the cluster in akstest-rg1, and then used "terraform destroy" to delete it, including RG "aktest-rg1"

    I then created a new AKS cluster using the same terraform template, but with the RG name change.

    In the screen shot you can see I do the following:

    • List the current RGs
    • Show that I have a running cluster called "globoticketcluster" in a new RG called "aks-globoticket-rg".
    • Show that "az aks list" is still giving the "ResourceGroupNotFound" error
    • Create a new RG called "akstest-rg1"
    • Now "az aks list" no longer errors, but it's not showing my AKS cluster either
    • Delete "akstest-rg1"
    • "az aks list" is giving the "ResourceGroupNotFound" error again

    Regards,
    Mark

    120730-image.png


  4. Mark Neves 106 Reputation points
    2021-08-09T10:06:09.02+00:00

    Hi @shiva patpi ,

    I destroyed the AKS cluster before I saw your reply. Anyway, still have an interesting issue.

    I still get "(ResourceGroupNotFound) Resource group 'akstest-rg1' could not be found" when I do "az aks list" on my workstation.

    In the cloud shell I get "[]" as expected (now that I no longer have an AKS cluster).

    So do I have some strange cached state locally? If so how would I solve that? Uninstall then reinstall the azure CLI? I'll hold off trying anything until I hear from you.

    Cheers,
    Mark

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.