No subscription were found - VS code - Azure python SDK

Prabhakaran Haribaskar 0 Reputation points
2023-02-07T06:23:28.62+00:00

Hi, I am trying to get resource group list by using Azure python SDK and i used below mentioned code to get the required information

from azure.identity import AzureCliCredential
from azure.mgmt.resource import ResourceManagementClient
credential = AzureCliCredential()
subscription_id = ""   // Here i didn't mention for privacy
esource_mgmt_client = ResourceManagementClient(credential, subscription_id)
resource_group_list=resource_mgmt_client.resource_groups.list()
resource_group_list = resource_mgmt_client.resource_groups.list()
for count, item in enumerate(resource_group_list):
    print(str(count+1)+" : "+item.name+","+item.location)

While running the above code in the terminal, i am getting below mentioned error

azure.identity._exceptions.CredentialUnavailableError: Please run 'az login' to set up an account

And i tried az login command in the terminal and i am getting No subscription were found in my respective mail ID - error but i have a free trial azure account on that ID.
At firstly, the same subscription ID were used in my colleague laptop and he can able to get the resource group list in the terminal level but i am not able to get the details in my laptop.

I am attaching the screenshot of my error for your better clarity.

Could anyone help me find where I am going wrong ? Thanks in advance. Screenshot from 2023-02-07 10-43-18

Screenshot from 2023-02-07 10-49-45

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,929 questions
0 comments No comments
{count} votes