Partner-Center-PowerShell icon indicating copy to clipboard operation
Partner-Center-PowerShell copied to clipboard

Using PartnerAccessToken with Azure PowerShell

Open Agazoth opened this issue 5 years ago • 0 comments

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 '[email protected]' -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.

Agazoth avatar Dec 09 '20 16:12 Agazoth