I have a function app in azure that needs to read AAD group information. This function app has system assigned managed identity enabled and the MSI has Directory.ReadAll permission on Microsoft Graph.
I use this code to get list of AAD Groups:
from azure.graphrbac import GraphRbacManagementClient
from msrestazure.azure_active_directory import MSIAuthentication
import logging
MSI_credential = MSIAuthentication(resource="https://graph.windows.net")
graphrbac_client = GraphRbacManagementClient(credentials=MSI_credential, tenant_id='*****')
groups = graphrbac_client.groups.list()
for g in groups:
logging.info(g.display_name)
This gives me the following error :
Retrying (Retry(total=3, connect=4, read=3, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')
I have tried using this wrapper class as well, https://github.com/jongio/azidext/blob/master/python/azure_identity_credential_adapter.py but it gives the exact same error. What am I missing here? Could this be related to whitelisting "https://graph.windows.net" in the firewall?