microsoft / Partner-Center-PowerShell

PowerShell module for managing Partner Center resources.
https://docs.microsoft.com/powershell/partnercenter/
MIT License
130 stars 59 forks source link

Using PartnerAccessToken with Azure PowerShell #343

Open Agazoth opened 3 years ago

Agazoth commented 3 years ago

When running Partner Center PowerShell 1.5 I was able to run Connect-AzAccount with a Partner Center Token and query Customer Resources and AzAD objects by following the description here

The documentation on the page is a bit confusing. In this code block:

$credential = Get-Credential
$refreshToken = '<RefreshToken>'

$azureToken = New-PartnerAccessToken -ApplicationId 'xxxx-xxxx-xxxx-xxxx' -Credential $credential -RefreshToken $refreshToken -Scopes 'https://management.azure.com//user_impersonation' -ServicePrincipal -Tenant 'yyyy-yyyy-yyyy-yyyy'
$graphToken = New-PartnerAccessToken -ApplicationId 'xxxx-xxxx-xxxx-xxxx' -Credential $credential -RefreshToken $refreshToken -Scopes 'https://graph.windows.net/.default' -ServicePrincipal -Tenant 'yyyy-yyyy-yyyy-yyyy'

# Az Module
Connect-AzAccount -AccessToken $token.AccessToken -AccountId 'azureuser@contoso.com' -GraphAccessToken $graphToken.AccessToken -TenantId 'xxxx-xxxx-xxxx-xxxx'

"yyyy-yyyy-yyyy-yyyy" refers to the CSP tenant containing my AdminAgent user account and the Application Account I use for generationg the Token and Refresh token.

"xxxx-xxxx-xxxx-xxxx" refers to the the Customer Tenant

However, the Note block below states that:

When connecting to an environment where you have admin on behalf of privileges, you will need to specify the tenant identifier for the target environment through the Tenant parameter. With respect to the Cloud Solution Provider program this means you will specify the tenant identifier of the customer's Azure Active Directory tenant using the Tenant parameter.

I think Tenant should be exchanged with TenantId to avoid confusion.

Furthermore, "xxxx-xxxx-xxxx-xxxx" and "yyyy-yyyy-yyyy-yyyy" are used for different things throughout the code examples on the page, which makes the confusion even greater.

I would like to update the code examples, but the page does not seem to be editable on GitHub.