Get-AzureAccountPrincipals
Right now there's no way of listing the users that an account has and their roles. It would be handy to have that cmdlet available.
https://msdn.microsoft.com/en-us/library/azure/dn469420.aspx
Get-AzureRoleAssignment does that.
@mvanotti does that solve your issue?
Thanks for pointing that out :)
Sadly, Get-AzureRoleAssignment doesn't show up anything on my subscription, whereas doing a manual request gives me all the information I need:
PS C:\Windows\system32> Get-MyAzureUser
Role Email
---- -----
ServiceAdministrator;AccountAdministrator [email protected]
CoAdministrator [email protected]
PS C:\Windows\system32> Switch-AzureMode -Name AzureResourceManager
WARNING: The Switch-AzureMode cmdlet is deprecated and will be removed in a future release.
PS C:\Windows\system32> Get-AzureRoleAssignment
PS C:\Windows\system32>
In a subscription with assigned roles I get multiple usernames and role assignments similar to the following returned:
PS C:\Windows\System32\WindowsPowerShell\v1.0> Get-AzureRoleAssignment
UserPrincipalName : [email protected] Mail : [email protected] RoleAssignmentId : /subscriptions/SUBSCRIPTION-GUID/resourceGroups/CentraliaRG/providers/Microsoft .Authorization/roleAssignments/4daa4c4a-8526-4771-8452-fb71a76ec6a8 DisplayName : William Wallace RoleDefinitionName : Virtual Machine Contributor Actions : {Microsoft.ClassicStorage/storageAccounts/read, Microsoft.ClassicStorage/storageAccounts/listKeys/action, Microsoft.ClassicStorage/storageAccounts/disks/read, Microsoft.ClassicStorage/storageAccounts/images/read...} NotActions : {} Scope : /subscriptions/SUBSCRIPTION-GUID/resourceGroups/CentraliaRG ObjectId : 99035360-03b0-4c18-a25b-0847c4eb1d46
RoleAssignmentId : /subscriptions/SUBSCRIPTION-GUID/resourceGroups/CentraliaRG/providers/Microsoft .Authorization/roleAssignments/3de9b2ab-5c02-4f2f-a336-a5aa0023a1e2 DisplayName : RoleDefinitionName : Virtual Machine Contributor Actions : {Microsoft.ClassicStorage/storageAccounts/read, Microsoft.ClassicStorage/storageAccounts/listKeys/action, Microsoft.ClassicStorage/storageAccounts/disks/read, Microsoft.ClassicStorage/storageAccounts/images/read...} NotActions : {} Scope : /subscriptions/SUBSCRIPTION-GUID/resourceGroups/CentraliaRG ObjectId : ce389818-2f26-4ede-9cbb-497220b6fd8c
Do you have any idea why the output is different? I am not getting any output when I call that command.
Are you using a subscription for which roles have been defined? I get no output when I run the command in a subscription with no roles assigned to users or groups.
I think these are different things. I have an admin and a co-admin in my account, I want to be able to list them, that's what this issue is about.
Get-AzureRoleAssignment shows me all the assigned roles (except the default one: I'm the owner), but no signs of the co-admin of the subscription.
Yes, they are different things. There are two ways to administer Azure services:
- Azure Service Management used by the production portal (manage.windowsazure.com) and the ASM (currently default mode of Azure PowerShell)
- Azure Resource Manager used by the preview portal (portal.azure.com) and the ARM mode of Azure PowerShell. This is the focus of all current and future management of Azure services.
ASM is managed by admins and co-admins. It does not use roles and does not support RBAC. it supports certificate auth and AAD auth. ARM is managed through users, groups and roles - and supports RBAC.
The Get-AzureRoleAssignment cmdlet is an ARM cmdlet retrieving all the users permitted access to Azure resources using ARM - and the roles which provide them that access. It provides no information about ASM and its administrators.
However, since all new Azure features are only available using ARM and most existing features have been lit up in ARM the guidance is to stop using ASM/co-admins and start using ARM/users/roles to manage Azure resources.
Thanks for your answer @nmackenzie!
I have a few follow up questions: I'm getting a warning when I run Swith-AzureMode, it says it is deprecated, what's the correct way to use the ARM? Is the ASM going away? That means that all of the current ASM functions will be deprecated and there will be a replacement version in the ARM? For example is there a replacement for Get-AzureVM?
Thanks :)
ASM is being replaced by ARM - and ARM will become the default for PowerShell. The team has put a put a post on GitHub asking for comments about their proposal for this:
https://github.com/Azure/azure-powershell/wiki/Deprecation-of-Switch-AzureMode-in-Azure-PowerShell
@mvanotti I'm going to close this issue. If you feel that the question requires more attention, please reopen the issue.