Get the shared tenant ids of an app

Yang Jing (景阳) 1 Reputation point
2022-07-07T10:57:33.703+00:00

I made an app registration App1 in Tenant1, and shared gallery VM images across Azure tenants from Tenant2 following this doc: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/share-images-across-tenants?tryIt=true&source=docs

Now assume I have App1 and Tenant1, and I don't know the shared tenant ids (e.g.Tenant2), is there any way to get them by powershell or azure sdk?

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
18,715 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JamesTran-MSFT 36,056 Reputation points Microsoft Employee
    2022-07-07T22:51:27.417+00:00

    @Yang Jing (景阳)
    Thank you for your post!

    For your specific question - If you only have the Azure AD App and don't know the shared tenant's ID, is there a way for you to get the Tenant ID?

    There are a few ways to get a Tenant's ID as described in our - How to find your Azure Active Directory tenant ID documentation. However, if you only have the Azure AD App (i.e. Name, Object ID, or Application ID), you can use some Azure AD PowerShell commands to find the tenant ID.

    Note: You'll have to login to the App's tenant prior to running these commands. If you aren't a member of the tenant, you won't be able to get the Tenant ID using these commands.

    #Connect to Azure AD  
    Connect-AzureAD  
      
    #Get an application by display name  
    Get-AzureADApplication -Filter "DisplayName eq 'TestName'"  
      
    #Get an application by App ID  
    Get-AzureADApplication -Filter "AppId eq '...02b43a4d37b8'"  
      
    #Get an application by Object ID  
    Get-AzureADApplication -ObjectId "...02b43a4d37b8"  
      
    #Get details for a tenant  
    $ObjectId = "...02b43a4d37b8"  
    (Get-AzureADTenantDetail).ObjectId  
    

    218637-image.png

    Links:
    Get-AzureADApplication
    Get-AzureADTenantDetail

    I hope this helps!

    If you have any other questions, please let me know.
    Thank you for your time and patience throughout this issue.

    ----------

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.