'AdalAuthentication' object has no attribute 'get_token'

Amit Suneja (Khoj) 1 Reputation point
2022-09-01T13:09:27.73+00:00

I am trying to write a runbook that can list all the snapshots created in my azure cloud, using the azure automation account.

Here is my Code:

!/usr/bin/env python3

import azure.mgmt.resource
import azure.mgmt.compute
import automationassets
from azure_automation_utility import get_automation_runas_credential

runas_connection = automationassets.get_automation_connection("AzureRunAsConnection")
azure_credential = get_automation_runas_credential()
compute_client = azure.mgmt.compute.ComputeManagementClient(azure_credential,str(runas_connection["SubscriptionId"]))
snapshots = compute_client.snapshots.list()
print(snapshots)
for item in snapshots:
print(item.name)

But I am getting below mentioned error:

Traceback (most recent call last): File "C:\Temp\s42kmnmn.q1k\51173539-dc9c-4f5a-8d18-fff106f50b80", line 52, in for item in snapshots: File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\paging.py", line 128, in next return next(self._page_iterator) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\paging.py", line 76, in next self._response = self._get_next(self.continuation_token) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\mgmt\compute\v2022_03_02\operations_snapshots_operations.py", line 966, in get_next pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\pipeline_base.py", line 211, in run return first_node.send(pipeline_request) # type: ignore File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\pipeline_base.py", line 71, in send response = self.next.send(request) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\pipeline_base.py", line 71, in send response = self.next.send(request) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\pipeline_base.py", line 71, in send response = self.next.send(request) [Previous line repeated 2 more times] File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\mgmt\core\policies_base.py", line 47, in send response = self.next.send(request) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\pipeline\policies_redirect.py", line 158, in send response = self.next.send(request) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\pipeline\policies_retry.py", line 446, in send response = self.next.send(request) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\pipeline\policies_authentication.py", line 117, in send self.on_request(request) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\azure\core\pipeline\policies_authentication.py", line 94, in on_request self._token = self._credential.get_token(*self._scopes)AttributeError: 'AdalAuthentication' object has no attribute 'get_token'

I am using python 3.8.0
azure_automation_utility = 0.0.1
azure-common = 1.1.28
azure-core = 1.25.0
azure-identity = 1.10.0
azure-mgmt-compute = 27.2.0
azure-mgmt-core = 1.3.1
typing-extensions = 4.3.0

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,822 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,336 Reputation points
    2022-09-09T08:07:27.643+00:00

    Hi Amit,

    Thank you for posting your query. My name is Clarence, I'll be more than happy to assist you with your concern.

    To resolve your query kindly do the steps below.

    Kindly try the solutions provided below.

    1.- Use the kernel "Python 3.6 - AzureML"

    2.- pip install azureml-core --upgrade

    This will upgrade

    azureml-core to 1.32.0

    But will downgrade:

    azure-mgmt-resource to 13.0.0 (was 18.0.0)

    azure-mgmt-storage down to 11.2.0 (was 18.0.0)

    urllib3 to 1.26.5 (was 1.26.6)

    This upgrade / downgrade allows the same package versions as in the python 3.6 anaconda install.

    Go to this link for your reference https://learn.microsoft.com/en-us/answers/questions/87272/failure-while-loading-azureml-run-type-providers.html

    -----------------------------------------------------------------------------------------------------------------------------

    If the answer is helpful kindly click "Accept as Answer" and upvote it. Thanks.

    0 comments No comments