Hi all,
I have some trouble with the SDK/documentation. Maybe it is just my fault so please do not hate me.
I have been working on a project where I have two ongoing issue.
I found the PowerShell alternative for the 1. but nothing for 2.
Is there any exists Python SDK solution for both issue or I have to use the native RestAPI?
Hi @realrill !
Sorry for the late answer. What you want do is likely to be done with azure-mgmt-authorization. I don't have a specific sample, but this part of this might help you:
https://github.com/Azure-Samples/compute-python-msi-vm#role-assignement-to-the-msi-credentials
# Get "Contributor" built-in role as a RoleDefinition object
role_name = 'Contributor'
roles = list(authorization_client.role_definitions.list(
resource_group.id,
filter="roleName eq '{}'".format(role_name)
))
assert len(roles) == 1
contributor_role = roles[0]
role_assignment = authorization_client.role_assignments.create(
resource_group.id,
uuid.uuid4(), # Role assignment random name
{
'role_definition_id': contributor_role.id,
'principal_id': user_object_id
}
)
Hi @lmazuel,
Thank you for your response.
I just quickly overviewed the doc of azure-mgmt-authorization and looks like this is what I looked for the user assignment to subscription.
I guess I focused on the Active Directory and Resources documentation and did not realise I was on the wrong page.
Fortunately I made a workaround with native REST Api but I would prefer SDK.
~I will test and implement it while~ I can confirm it works, I am waiting for a solution for the 1. issue now.
Thank you for your help!
@yugangw-msft what would you do for:
Create a new guest user (Invite an external user into Azure AD)
This is not possible till we are able to integrate AAD Graph team's swagger into SDK's spec repository. There is an ownership discussion going on right now, and I hope we can resolve that and get this scenario covered soon.
Is there an update on this feature request?
I also need to create guest accounts with a python script based on some events from a webhook.
Just want to know that if there is a plan to support this feature in the SDK :-) ?
Most helpful comment
This is not possible till we are able to integrate AAD Graph team's swagger into SDK's spec repository. There is an ownership discussion going on right now, and I hope we can resolve that and get this scenario covered soon.