When using AKS I had this error when I missed kubelogin. I ran 'az aks install-cli', closed and opened terminal and voila, it worked :)