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

azure_rm_adapplication_info - failed to get application info 'dict' object has no attribute 'get_all' #1338

Closed
Elrau opened this issue Nov 17, 2023 · 15 comments · Fixed by #1345
Labels
bug Something isn't working has_pr PR fixes have been made high_priority High priority

Comments

@Elrau
Copy link

Elrau commented Nov 17, 2023

SUMMARY

Hello,
Tried to upgrade from version 1.16 to new 2.0. Code works fine before that.

ISSUE TYPE

When I try to get AD Application info by its identifier URL, I got a message failed to get application info 'dict' object has no attribute 'get_all'

COLLECTION VERSION
collections:
  - name: azure.azcollection
    version: "2.0.0"
STEPS TO REPRODUCE
    - name: Verify if aad application exist
      azure.azcollection.azure_rm_adapplication_info:
        identifier_uri: "https://{{ my_awesome_var }}.mydomain.com"
      environment :
        AZURE_CLIENT_ID: "{{ aad_client_id }}" ## For authentication
        AZURE_SECRET: "{{ aad_client_secret }}" ## For authentication
        AZURE_SUBSCRIPTION_ID: "{{ aad_subscription_id }}" ## For authentication
        AZURE_TENANT: "{{ aad_tenant_id }}"
      run_once: yes
      delegate_to: localhost
      register: aad_application_info
EXPECTED RESULTS

Task performs correctly and get AAD App info if exist or a specific string if not

ACTUAL RESULTS

Task fail with message : failed to get application info 'dict' object has no attribute 'get_all'

@xuzhang3 xuzhang3 added the bug Something isn't working label Nov 17, 2023
@xuzhang3
Copy link
Collaborator

SDK bug : microsoftgraph/msgraph-sdk-python#466

@xuzhang3
Copy link
Collaborator

@Elrau you can use the object_id to get the application as there is a bug in the SDK

@Elrau
Copy link
Author

Elrau commented Nov 17, 2023

Thanks for your return and the information about the bug.

Unfortunately in my usecase I can't use the object_id because the identifier_uri is the only information we have access to.
We'll wait for the fix of the SDK then

@Fred-sun Fred-sun added the hold The problem holds for a particular reason label Nov 20, 2023
@A360-Paul
Copy link

A360-Paul commented Nov 22, 2023

This looks related to issue 451

My comment should apply. Basically your setting a dict where its expecting the "HeaderColleciton" class.
Documentation is not up to date on this.

Use the request_configuration.headers.try_add('HEADERKEY','HEADERVALUE') instead.

If you share code, I can fix for you. I resolved it by reviewing the SDK source.

@xuzhang3
Copy link
Collaborator

@A360-Paul Looks like the headers has been deleted from request configuration. So I remove the headers in the request configuration and the this bug fixed. headers={'ConsistencyLevel': "eventual"}, should be deleted.

async def get_applications(self, sub_filters):
        if sub_filters:
            request_configuration = ApplicationsRequestBuilder.ApplicationsRequestBuilderGetRequestConfiguration(
                query_parameters=ApplicationsRequestBuilder.ApplicationsRequestBuilderGetQueryParameters(
                    filter=(' and '.join(sub_filters)),
                ),
                headers={'ConsistencyLevel': "eventual"},
            )
            return await self._client.applications.get(request_configuration=request_configuration)
        else:
            return await self._client.applications.get()

@Fred-sun Fred-sun added has_pr PR fixes have been made high_priority High priority and removed hold The problem holds for a particular reason labels Nov 23, 2023
@xPancakery
Copy link

I'm getting this same issue on the azure_rm_adgroup_info module. I'd imagine it'd be the exact same fix, could you look into it @xuzhang3 ?

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Dec 1, 2023

@xPancaker Seems the same issue, can you share your configuration file?

@juniinacio
Copy link

I'm also getting the same issue with azure_rm_adgroup module.

Playbook

- name: "AAD"
  hosts: localhost
  connection: local
  tags:
    - "AAD"
  tasks:
    - name: Create Group
      azure.azcollection.azure_rm_adgroup:
        display_name: "MY_GROUP_NAME"
        mail_nickname: "MY_GROUP_NICK_NAME"
        object_id: "MY_GROUP_OBJECT_ID"
        auth_source: credential_file
        profile: default
        state: 'present'

Credentials file

[default]
subscription_id=MY_SUB_ID
client_id=MY_CLIENT_ID
secret=MY_CLIENT_SECRET
tenant=MY_TENANT_ID

@xPancakery
Copy link

@xPancaker Seems the same issue, can you share your configuration file?

My config file isn't much, just points to some custom plugins and hides skipped_hosts.

[defaults]
display_skipped_hosts = no
filter_plugins = ./filter_plugins

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Dec 4, 2023

@xPancakery @juniinacio #1355 will fix this issue.

@juniinacio
Copy link

@xPancakery @juniinacio #1355 will fix this issue.

I will give it a try as soon as possible, and let you know.

@xPancakery
Copy link

@xuzhang3 that fixed the issue for a day by adding a pre-task to pull the dev branch, but now it's again not working with the same error?

    - name: Install specific azcollection
      shell:
        cmd: "ansible-galaxy collection install git+https://github.com/ansible-collections/azure.git,dev"

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Dec 7, 2023

@xPancakery can you share your script and the error logs?

@xPancakery
Copy link

Portion of the script with the relevant call:

- name: Gather USER MEMBERSHIP information from Azure Active Directory and compile relevant lists
  block:

    - name: Get user memberships for all Azure AD Groups
      azure.azcollection.azure_rm_adgroup_info:
        tenant: "{{ tenant }}"
        client_id: "{{ client_id }}"
        secret: "{{ secret }}"
        subscription_id: "{{ subscription_id }}"
        all: true
        return_group_members: True
      register: ad_group_membership_initial

Error in AWX:

{
  "msg": "failed to get ad group info 'dict' object has no attribute 'get_all'",
  "invocation": {
    "module_args": {
      "tenant": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "client_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "subscription_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "all": true,
      "return_group_members": true,
      "auth_source": "auto",
      "cloud_environment": "AzureCloud",
      "api_profile": "latest",
      "return_owners": false,
      "return_member_groups": false,
      "profile": null,
      "ad_user": null,
      "password": null,
      "cert_validation_mode": null,
      "adfs_authority_url": null,
      "log_mode": null,
      "log_path": null,
      "x509_certificate_path": null,
      "thumbprint": null,
      "object_id": null,
      "attribute_name": null,
      "attribute_value": null,
      "odata_filter": null,
      "check_membership": null
    }
  },
  "deprecations": [
    {
      "msg": "tenant ID has been deprecated and will be removed in the future. See the Azure documentation for more information: https://learn.microsoft.com/en-us/graph/migrate-azure-ad-graph-request-differences#example-request-comparison",
      "version": "2.0.0",
      "collection_name": "azure.azcollection"
    }
  ],
  "_ansible_no_log": null,
  "changed": false
}

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Dec 8, 2023

@xPancakery This issue should be fix by #1355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has_pr PR fixes have been made high_priority High priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants