Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'ClientSecretCredential' object has no attribute 'signed_session' #21007

Closed
db533 opened this issue Oct 1, 2021 · 2 comments
Closed
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@db533
Copy link

db533 commented Oct 1, 2021

  • Package Name: azure-identity
  • Package Version: 1.6.1
  • Package Name: azure-mgmt-resource
  • Package Version: 2.2.0
  • Operating System: Windows 10 Home 19042.1237
  • Python Version: 3.9.5

Describe the bug
After creating a resource management client, when trying to use it to return a list of resource groups (or similar code to create a new resource group), the code fails with an attribute error "'ClientSecretCredential' object has no attribute 'signed_session'."

To Reproduce
Steps to reproduce the behavior:

  1. Define environment variables for a service principal with Contributor role to the Azure Basic subscription.
  2. Run the code below.
  3. Results in the error message: "AttributeError: 'ClientSecretCredential' object has no attribute 'signed_session'"
import os
from azure.mgmt.resource import ResourceManagementClient
from azure.identity import ClientSecretCredential

def main():
    SUBSCRIPTION_ID = os.environ.get("AZURE_SUBSCRIPTION_ID", None)
    tenant_id = os.environ["AZURE_TENANT_ID"]
    client_id = os.environ["AZURE_CLIENT_ID"]
    client_secret = os.environ["AZURE_CLIENT_SECRET"]
    credential = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)

    print("Create resource client...")
    resource_client = ResourceManagementClient(credential, SUBSCRIPTION_ID)
    print("Printing existing resource grouops:")
    for item in resource_client.resource_groups.list():
        print_item(item)

if __name__ == "__main__":
    main()

This code results in the following output:

Create resource client...
Printing existing resource grouops:
Traceback (most recent call last):
  File "C:\Users\db533\PycharmProjects\GunaBot2\azure-mgmt\azure_test3.py", line 20, in <module>
    main()
  File "C:\Users\db533\PycharmProjects\GunaBot2\azure-mgmt\azure_test3.py", line 16, in main
    for item in resource_client.resource_groups.list():
  File "C:\Users\db533\PycharmProjects\GunaBot2\venv\lib\site-packages\msrest\paging.py", line 143, in __next__
    self.advance_page()
  File "C:\Users\db533\PycharmProjects\GunaBot2\venv\lib\site-packages\msrest\paging.py", line 129, in advance_page
    self._response = self._get_next(self.next_link)
  File "C:\Users\db533\PycharmProjects\GunaBot2\venv\lib\site-packages\azure\mgmt\resource\resources\v2018_05_01\operations\resource_groups_operations.py", line 512, in internal_paging
    response = self._client.send(request, stream=False, **operation_config)
  File "C:\Users\db533\PycharmProjects\GunaBot2\venv\lib\site-packages\msrest\service_client.py", line 336, in send
    pipeline_response = self.config.pipeline.run(request, **kwargs)
  File "C:\Users\db533\PycharmProjects\GunaBot2\venv\lib\site-packages\msrest\pipeline\__init__.py", line 197, in run
    return first_node.send(pipeline_request, **kwargs)  # type: ignore
  File "C:\Users\db533\PycharmProjects\GunaBot2\venv\lib\site-packages\msrest\pipeline\__init__.py", line 150, in send
    response = self.next.send(request, **kwargs)
  File "C:\Users\db533\PycharmProjects\GunaBot2\venv\lib\site-packages\msrest\pipeline\requests.py", line 65, in send
    self._creds.signed_session(session)
AttributeError: 'ClientSecretCredential' object has no attribute 'signed_session'

Expected behavior
Expect the code to return the list of existing resource groups.

Screenshots
N/A

Additional context
Similar code has worked previously when I ran it in an Ubuntu (20.04) virtual machine, but I do not have access to this VM anymore. I'm now trying to run this code in a venv virtual environment in a PyCharm Community project, running PyCharm on a Windows 10 laptop (same laptop in which the Ubuntu VM was run). The same service principal was used when it worked on Ubuntu VM.

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 1, 2021
@xiangyan99 xiangyan99 added needs-author-feedback Workflow: More information is needed from author to address the issue. and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Oct 1, 2021
@xiangyan99
Copy link
Member

Thanks for your feedback.

azure-mgmt-resource 2.2.0 is track 1 library and it is not fully compatible with azure-identity.

You can upgrade azure-mgmt-resource to latest version or https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/identity/azure-identity/migration_guide.md for migrations.

Please let us know if any questions.

@xiangyan99 xiangyan99 added Azure.Identity Client This issue points to a problem in the data-plane of the library. labels Oct 1, 2021
@xiangyan99 xiangyan99 self-assigned this Oct 1, 2021
@db533
Copy link
Author

db533 commented Oct 3, 2021

Thanks for the quick response. Switching to azure-common credentials, as detailed in the link, did indeed fix the issue.

@db533 db533 closed this as completed Oct 3, 2021
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-python that referenced this issue Oct 5, 2022
[Hub Generated] Review request for Microsoft.MachineLearningServices to add version preview/2022-10-01-preview (Azure#20818)

* Adds base for updating Microsoft.MachineLearningServices from version preview/2022-06-01-preview to version 2022-10-01-preview

* Updates readme

* Updates API version in new specs and examples

* Registries public preview 2022-10-01-preview (Azure#20200)

* Registries public preview 2022-10-01-preview

* Fix validation errors

* Fix LintDiff and Avocado errors

* Fixing prettier errors

* Fixing more LintDiff errors

* Another LintDiff error

* Another Lint error

Co-authored-by: Fahd Kamal <fahdk@microsoft.com>

* Added schedule api (Azure#20273)

* added schedule api

* add updateSchedules to examples parent folder

* fix typo

* change position of allOf

* remove subnet from example compute create

* after prettier run

* Description change for recurrence freq

* point to mfe for common objects

* add hash operator

* removed triggertype as well

* change year

* get rid of breaking changes since we didn't change the api

Co-authored-by: Naman Agarwal <naagarw@microsoft.com>

* Added Compute Instance OS Patching Properties (Azure#20284)

* Added CI Os Patching related properties

* Updated descriptions as per Dennis's suggestions

Co-authored-by: Srivatsa Sinha <srsinha@microsoft.com>

* Maulik/sync preview (Azure#20554)

* Added changes to sync with main

* Fixed Prettier Check

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* Remove update schedules REST call for compute instance (Azure#20699)

* change post call to put

* change put to patch

* remove updateschedules rest call

Co-authored-by: Naman Agarwal <naagarw@microsoft.com>

* Update connection type and auth type (Azure#20493)

* Update connection type and auth type

* update connection category

* update x-ms-secret tag

* Add autologger_settings for CI (Azure#20302)

* Add autologger_settings for CI

Add settings to opt-in/out of default mlflow autologger on CIs.

* update machinelearningservices.json

* Add for command job

* fix comma

* Add autologger for command job

* fix CI failures

* Remove mfe.json from PR

* Remove whitespace

* Update custom-words.txt

* Delete incorrect custom-words.txt

* Fixing auto-rest issues in registries (Azure#20772)

* Fixing auto-rest issues in registries

* Removing location from the required list

Co-authored-by: Fahd Kamal <fahdk@microsoft.com>

* Maulik/mfe preview changes (Azure#20372)

* Added mfe.json preview changes

* Added resources to Registries and Workspaces folder

* removed unwanted resources

* removed unwanted resources

* Ran prettier check

* removed unwanted resources

* removed unwanted resources

* Added ManagedOnlineDeployment resource

* Added files to OnlineDeplyment

* Added Model Validation changes

* Added mfe.json changes to handle duplicate operation id changes

* Updated mfe to fix underscore error

* Update title of mfe.json

* Renamed name path parameter

* Updated examples

* Fixed Semantic validations and examples

* Fixed Semantic validations and examples

* Fixed Semantic validations and examples

* Removed name changes from workspaces

* Changes related to Model Validation

* Changes related to Model validation

* Added consumes amd produces in registries.json

* Removed changes from registries

* Updated parameter mlFlowAutologger to mlflowAutologger in mfe.json

* Changed property name to mlflowAutologger

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* Updated custom words to resolve merge conflict (Azure#20833)

* Updated custom words to resolve merge conflict

* Updated custom words to resolve merge conflict

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* Resolved merge conflict (Azure#20845)

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* Fixed LintDiff checks (Azure#20847)

* Fixed LintDiff checks

* Fixed LintDiff checks

* Fixed LintDiff checks

* Fixed LintDiff checks

* Updated examples

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* Resolved merge conflict of cutsom-words.txt (Azure#20956)

* Resolved merge conflict

* Resolved merge conflict

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* [Hub Generated] Review request for Microsoft.MachineLearningServices to add version stable/2022-10-01 (Azure#20800) (Azure#20982)

* Adds base for updating Microsoft.MachineLearningServices from version stable/2022-05-01 to version 2022-10-01

* Updates readme

* Updates API version in new specs and examples

* Added readOnly property (Azure#20506)

* Added readOnly property

* Added changes to sync with main

* Fixed Prettier check

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* Add schedule related schemas for Compute Instance (Azure#20697)

* support for update schedules on Compute Instance

* change put to patch

* remove update schedules rest call

Co-authored-by: Naman Agarwal <naagarw@microsoft.com>

* Added mfe.json changes (Azure#20514)

* Added mfe.json changes

* Added checks related changes

* Updated mfe.json to handle online endpoint and deployment changes

* Updated mfe.json with AutoRebuild changes

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* Removed duplicate definitions and updated with mfe references (Azure#20840)

* Removed duplicate definitions and updated with mfe references

* Replaced Cron to CronTrigger, Recurrence to RecurrenceTrigger from mfe

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>
Co-authored-by: Naman Agarwal <namanag16@gmail.com>
Co-authored-by: Naman Agarwal <naagarw@microsoft.com>

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>
Co-authored-by: Naman Agarwal <namanag16@gmail.com>
Co-authored-by: Naman Agarwal <naagarw@microsoft.com>

* Revert "[Hub Generated] Review request for Microsoft.MachineLearningS… (Azure#20983)

* Revert "[Hub Generated] Review request for Microsoft.MachineLearningServices to add version stable/2022-10-01 (Azure#20800) (Azure#20982)"

This reverts commit 649ef8334aca13558e534babdcf53cef6831f22a.

* Updated readme.md to resolve merge conflict

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* Maulik/fix preview (Azure#20994)

* Merged readme from main

* Added preview tag changes

Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>

* shuffle readme tags (Azure#21005)

* conflict resolution (Azure#21007)

Co-authored-by: fahdkmsft <51756016+fahdkmsft@users.noreply.github.com>
Co-authored-by: Fahd Kamal <fahdk@microsoft.com>
Co-authored-by: Naman Agarwal <namanag16@gmail.com>
Co-authored-by: Naman Agarwal <naagarw@microsoft.com>
Co-authored-by: srivatsasinha <102133347+srivatsasinha@users.noreply.github.com>
Co-authored-by: Srivatsa Sinha <srsinha@microsoft.com>
Co-authored-by: maulikjoshi <maulikjoshi@microsoft.com>
Co-authored-by: ZhidaLiu <zhili@microsoft.com>
Co-authored-by: prakharg-msft <75808410+prakharg-msft@users.noreply.github.com>
Co-authored-by: Teddy Todorov <thtodoro@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

2 participants