azureazure-virtual-machineazure-identity

How can i assign a VM in Azure to view all subscriptions using Managed Identity?


I have a VM in Azure i have assigned an Identity and i can login using

 az login --identity

When i do that , it only displays the Subscription that the VM is in . I have a number of subscriptions and I want that VM to be able to view all subscriptions and be able to access all resources in all subscriptions .

I have tried to configure Role assignment but couldnt see anything that would allow the VM to access all subscriptions

How can i configure the VM identity to access all subscriptions and all resources ?


Solution

  • How can i assign a VM in Azure to view all subscriptions using Managed Identity?

    To assign a role to the VM identity on different subscriptions, follow these steps

    1. Enable the VM Identity by navigating to Virtual Machines > Identity.

    enter image description here

    1. Assign the role to another subscription in same tenant, by navigating to another Subscription > Access control (IAM) > Add role assignment > Select the role > User, group, or service principal > Enter your VM Name at search place.

    Note: If you select Managed identity, The managed identity will be access within the same subscription, it won't display in another subscription

    .

    enter image description here

    1. Once assign the roles to the VM identity, when I try to log in with the identity, I am able to see all subscription details which are assigned, as shown below.

    Output:

    enter image description here