Minor updates to the documentation and module manifest files (#66)

* Minor updates to the documentation and module manifest files

* Update README.md
This commit is contained in:
Isaiah Williams 2019-02-03 13:11:19 -06:00 коммит произвёл Joel Stidley
Родитель d1c77817a2
Коммит 43fca7f1cc
4 изменённых файлов: 22 добавлений и 120 удалений

Просмотреть файл

@ -11,7 +11,11 @@ This repository contains a set of PowerShell commands for administrators and dev
Run the following command in an elevated PowerShell session to install the Partner Center module:
```powershell
# Install the Partner Center PowerShell module
Install-Module -Name PartnerCenter
# Install the Partner Center PowerShell module for PowerShell Core
Install-Module -Name PartnerCenter.NetCore
```
If you have an earlier version of the Partner Center PowerShell modules installed from the PowerShell Gallery and would like to update to the latest version, run the following commands from an elevated PowerShell session.
@ -21,6 +25,9 @@ If you have an earlier version of the Partner Center PowerShell modules installe
```powershell
# Install the latest version of the Partner Center PowerShell module
Update-Module -Name PartnerCenter
# Install the latest version of the Partner Center PowerShell module for PowerShell Core
Update-Module -Name PartnerCenter.NetCore
```
## Usage
@ -31,7 +38,7 @@ To connect to Partner Center, use the [`Connect-PartnerCenter`](docs/help/Connec
#### Service Principal
The following example demonstrates how to connect using a service principal. Using this approach will leverage the app only authentication flow. It is important to note that not all Partner Center operations support this type of authentication. If you have not already created an Azure AD application then please follow the steps documented in the [Web App](#Web-App) section below.
The following example demonstrates how to connect using a service principal. It is important to note that not all Partner Center operations support this type of authentication. If you have not already created an Azure AD application, then follow the steps documented in the [Web App](#Web-App) section below.
```powershell
# Service principal login
@ -39,20 +46,16 @@ $appId = '<Web-AAD-AppId-for-PartnerCenter>'
$appSecret = '<Web-AAD-AppSecret>' | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $appId $appSecret
Connect-PartnerCenter -Credential $credential -ServicePrincipal -TenantId '<TenantId>
Connect-PartnerCenter -Credential $credential -ServicePrincipal -TenantId '<TenantId>'
```
#### User Credentials
The following examples demonstrate how to connect using user credentials. Using this approach will leverage the app + user authentication flow. If you have not already configured an Azure AD application for use with this command then please see the steps documented in the [Native App](#Native-App) section below.
The following examples demonstrate how to connect using user credentials. Using this approach will leverage app + user authentication. If you have not already configured an Azure AD application for use with this command then, see the steps documented in the [Native App](#Native-App) section below.
```powershell
# Interactive login - a dialog box will appear for you to provide your Partner Center credentials
Connect-PartnerCenter -ApplicationId '<Native-AAD-AppId-for-PartnerCenter>'
# Non-interactive login
$PSCredential = Get-Credential
Connect-PartnerCenter -ApplicationId '<Native-AAD-AppId-for-PartnerCenter>' -Credential $PSCredential
```
#### Access Token
@ -62,11 +65,11 @@ The following example demonstrates how to connect using an access token. It is i
```powershell
$appId = '<AAD-AppId-for-PartnerCenter>'
$appSecret = '<AAD-AppSecret>' | ConvertTo-SecureString -AsPlainText -Force
$PSCredential = New-Object System.Management.Automation.PSCredential $appId $appSecret
$PSCredential = New-Object System.Management.Automation.PSCredential $appId, $appSecret
$token = New-PartnerAccessToken -Credential $PSCredential -ServicePrincipal -TenantId '<TenantId>'
Connect-PartnerCenter -AccessToken $token.AccessToken -AccessTokenExpiresOn $token.ExpiresOn -ApplicationId '<AAD-AppId-for-PartnerCenter>' -TenantId '<TenantId>'
Connect-PartnerCenter -AccessToken $token.AccessToken -ApplicationId '<AAD-AppId-for-PartnerCenter>' -TenantId '<TenantId>'
```
#### Sovereign Cloud
@ -112,7 +115,7 @@ Get-Help -Name Get-PartnerCustomer -Full
1. Sign in to the [Partner Center](https://partner.microsoft.com/cloud-solution-provider/csp-partner) using credentials that have *Admin Agent* and *Global Admin* privileges
2. Click on _Dashboard_ at the top of the page, then click on the cog icon in the upper right, and then click the _Partner settings_.
3. Add a new native application if one does not exist already.
4. Sign in to the [Azure management portal](https://portal.azure.com) using the same credentials from step 1.
4. Sign in to the [classic portal](https://portal.azure.com) using the same credentials from step 1.
5. Click on the _Azure Active Directory_ icon in the toolbar.
6. Click _App registrations_ -> Select _All apps_ from the drop down -> Click on the application created in step 3.
7. Click _Settings_ and then click _Redirect URIs_
@ -122,4 +125,4 @@ Get-Help -Name Get-PartnerCustomer -Full
1. Sign in to the [Partner Center](https://partner.microsoft.com/cloud-solution-provider/csp-partner) using credentials that have *Admin Agent* and *Global Admin* privileges
2. Click on _Dashboard_ at the top of the page, then click on the cog icon in the upper right, and then click the _Partner settings_.
3. Add a new web application if one does not exist already.
3. Add a new web application if one does not exist already.

Просмотреть файл

@ -1,101 +0,0 @@
// -----------------------------------------------------------------------
// <copyright file="SecureAppCredentials.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
namespace Microsoft.Store.PartnerCenter.Extensions
{
using System.Threading.Tasks;
using RequestContext;
/// <summary>
/// Partner service credentials based on the secure application model.
/// </summary>
internal class SecureAppCredentials : BasePartnerCredentials
{
/// <summary>
/// The default AAD authority endpoint.
/// </summary>
private const string DefaultAadAuthority = "https://login.microsoftonline.com";
/// <summary>
/// The default Azure AD Graph endpoint.
/// </summary>
private const string DefaultGraphEndpoint = "https://graph.windows.net";
/// <summary>
/// The Azure Active Directory application secret.
/// </summary>
private readonly string applicationSecret;
/// <summary>
/// The application domain in Azure Active Directory.
/// </summary>
private readonly string aadApplicationDomain;
/// <summary>
/// The Active Directory authentication endpoint.
/// </summary>
private readonly string activeDirectoryAuthority;
/// <summary>
/// The Azure AD Graph API endpoint.
/// </summary>
private readonly string graphApiEndpoint;
/// <summary>
/// Initializes static members of the <see cref="SecureAppCredentials" /> class.
/// </summary>
static SecureAppCredentials()
{
PartnerService.Instance.RefreshCredentials += new PartnerService.RefreshCredentialsHandler(OnCredentialsRefreshNeededAsync);
}
/// <summary>
/// Initializes a new instance of the <see cref="SecureAppCredentials" /> class.
/// </summary>
/// <param name="aadApplicationId">The application Id in Azure Active Directory.</param>
/// <param name="aadApplicationSecret">The application secret in Azure Active Directory.</param>
/// <param name="aadApplicationDomain">The application domain in Azure Active Directory.</param>
/// <param name="refreshToken">The refresh token </param>
/// <param name="aadAuthorityEndpoint">The Active Directory authority endpoint.</param>
/// <param name="graphApiEndpoint">The AAD graph API endpoint.</param>
public SecureAppCredentials(string aadApplicationId, string aadApplicationSecret, string aadApplicationDomain, string refreshToken, string aadAuthorityEndpoint, string graphApiEndpoint)
: base(aadApplicationId)
{
aadApplicationId.AssertNotEmpty(nameof(aadApplicationId));
aadApplicationSecret.AssertNotEmpty(nameof(aadApplicationSecret));
aadApplicationDomain.AssertNotEmpty(nameof(aadApplicationDomain));
if (string.IsNullOrEmpty(aadAuthorityEndpoint))
{
aadAuthorityEndpoint = DefaultAadAuthority;
}
if (string.IsNullOrEmpty(graphApiEndpoint))
{
graphApiEndpoint = DefaultGraphEndpoint;
}
applicationSecret = aadApplicationSecret;
this.aadApplicationDomain = aadApplicationDomain;
activeDirectoryAuthority = aadAuthorityEndpoint;
this.graphApiEndpoint = graphApiEndpoint;
}
/// <summary>
/// Called when a partner credentials instance needs to be refreshed.
/// </summary>
/// <param name="credentials">The outdated partner credentials.</param>
/// <param name="context">The partner context.</param>
/// <returns>A task that is complete when the credential refresh is complete.</returns>
private static async Task OnCredentialsRefreshNeededAsync(IPartnerCredentials credentials, IRequestContext context)
{
if (credentials is ApplicationPartnerCredentials partnerCredentials)
{
await partnerCredentials.AuthenticateAsync(context).ConfigureAwait(false);
}
}
}
}

Просмотреть файл

@ -1,9 +1,9 @@
#
# Module manifest for module 'PartnerCenter'
# Module manifest for module 'PartnerCenter.NetCore'
#
# Generated by: Microsoft Corporation
#
# Generated on: 02/01/2019
# Generated on: 02/04/2019
#
@{
@ -63,7 +63,7 @@
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = 'Microsoft.Store.PartnerCenter.PowerShell.types.ps1xml'
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = 'Microsoft.Store.PartnerCenter.PowerShell.format.ps1xml'
@ -196,10 +196,10 @@
# IconUri = ''
# ReleaseNotes of this module
ReleaseNotes = ''
ReleaseNotes = 'Initial release'
# Prerelease string of this module
Prerelease = 'preview'
# Prerelease = 'preview'
# Flag to indicate whether the module requires explicit user acceptance for install/update
# RequireLicenseAcceptance = $false

Просмотреть файл

@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 02/01/2019
# Generated on: 02/04/2019
#
@{
@ -63,7 +63,7 @@
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = 'Microsoft.Store.PartnerCenter.PowerShell.types.ps1xml'
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = 'Microsoft.Store.PartnerCenter.PowerShell.format.ps1xml'
@ -196,7 +196,7 @@
# IconUri = ''
# ReleaseNotes of this module
ReleaseNotes = ''
ReleaseNotes = 'Added the ability to get offer categories. Retired the Get-PartnerCustomerRelationship command. Removed the ability to pass user credentials when connecting due to security changes with the Partner Center API.'
# Prerelease string of this module
# Prerelease = 'preview'