-1

While Running Chaos Toolkit Azure related Playbooks , i am getting an error as " failed: AttributeError: 'ServicePrincipalCredentials' object has no attribute 'get_token" though i have passed in the correct Secret ID , Tenant ID , Client ID , SUbscription ID and Client Secret ID.. Even the Subscription has full permission to Service Principal.

Ayan
  • 1
  • 1

1 Answers1

0

Short answer: It would have helped to check the exact code you're trying to run, but from the mentioned error, it looks like you're trying to use the newer libraries in the older ways. When using newer SDK libraries based on azure.core, use the ClientSecretCredential object from the azure.identity library. When using older SDK libraries, use ServicePrincipalCredentials from the azure.common library.

Long answer: The Azure libraries for Python are currently being updated to share common cloud patterns such as authentication protocols, logging, tracing, transport protocols, buffered responses, and retries.

In the newer version, the authentication mechanism has been re-designed and replaced by azure-identity library in order to provide unified authentication based on Azure Identity for all Azure SDKs. Run pip install azure-identity to get the package.

So instead of using the ServicePrincipalCredentials class from the azure.common library, switch to using ClientSecretCredential as follows:

from azure.identity import ClientSecretCredential
from azure.mgmt.compute import ComputeManagementClient

credential = ClientSecretCredential(
    tenant_id='xxxxx',
    client_id='xxxxx',
    client_secret='xxxxx'
)

Here is another related thread with a detailed solution: Azure Python SDK: 'ServicePrincipalCredentials' object has no attribute 'get_token'

Additional references:

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30