The purpose of this web part is to show how you can consume LOB (Line of Business) solutions and external (on-premises, cloud based, etc) data within SharePoint Framework.
The web part leverages a back-end REST API, built using a ASP.NET Core 3.1 WebAPI project that you can find here. This API is representative of LOB data exposed via a web service and consumed using Http calls. Visual Studio 2019 version 16.4 or higher required for Visual Studio based deployment to Azure.
The LOB service is protected via the Microsoft Identity Platform. An application registration is required to implement this protection. Peform the following steps to register an application in a tenant.
If you are not an administrator of a Microsoft 365 tenant, you can get a tenant at no charge as part of the Microsoft 365 Developer Program.
- Log in to the Azure Active Directory admin center at https://aad.portal.azure.com/.
- In the left-hand navigation bar, select Azure Active Directory, then App Registrations.
- Select New Registration from the toolbar.
- Enter a name for the application. In this example, the name is SharePointPnP-LobScenario.
This value, known as the Application Name, is required later in the SharePoint Service Principal configuration.
- For Supported account types, select Accounts in this organizational directory only (Single tenant).
- Select Register.
- In the application overview blade, select Expose an API.
- Select Add a scope.
- The portal will display a panel requesting an Application ID URI. Leave the suggested default (
api://{app-id}
).This value, known as the Application URI, is required as a web part property.
- Select Save and continue.
- For Scope name, enter
access_as_user
.This value, known as the Application Scope, is required later in the SharePoint Service Principal configuration.
- Complete the Consent fields as appropriate.
- Select Add scope to complete the configuration.
- Select Overview in the application menu. Make note of the following values for configuring the service code:
- Application (client) ID
- Directory (tenant) ID
The LOB service code must be configured with the application registration values.
- Open the
appsettings.json
file. - Set the TenantId property to the Directory (tenant) ID value.
- Set the ClientId property to the Application (client) ID value.
Once updated, deploy or start the solution. The service must use the https scheme. Make note of the address (url).
This value, known as the Service Url, is required as a web part property.
The SharePoint Service Principal must have a permission grant before getting an access token for the service. The following PowerShell commands will configure the service principal (the Resource and Scope parameters must match the values from the application registration):
Connect-SPOService -Url "https://[your-tenant]-admin.sharepoint.com/"
Approve-SPOTenantServicePrincipalPermissionGrant -Resource "[Application Name]" -Scope "[Application Scope]"
- Place the page you want to add this web part to in edit mode.
- Search for and insert the LobIntegration web part.
- Configure the webpart to update its properties.
The LobIntegration
webpart must be configured with the following properties:
Label | Property | Type | Required | Description |
---|---|---|---|---|
Service Url | serviceUrl | string | yes | The hosting address of the LOB service. (The address must use the https scheme.) |
Application URI | webapiUri | string | yes | The value from the application registration in the Azure Active Directory admin center. |
- SharePoint Online only due to dependency on API permission management
WebAPI configured as secured asset in the same Azure AD instance as where web part is hosted.
Solution | Author(s) |
---|---|
react-lob-integration | Paul Schaeflein (Technical Architect, AddIn365) / Microsoft MVP (Office Development) / @paulschaeflein |
react-lob-integration | Chandani Prajapati / @Chandani_SPD |
Version | Date | Comments |
---|---|---|
2.0 | December 25, 2019 | Initial release |
3.0 | February 2023 | Initial release for SharePoint Starter Kit v3 (Upgraded to SPFx 1.16.1) |
THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
- Clone this repository
- Move to solution folder
- in the command line run:
npm install
gulp serve
Include any additional steps as needed.
Description of the web part with possible additional details than in short summary. This Web Part illustrates the following concepts on top of the SharePoint Framework:
- Calling securely custom Web APIs in SharePoint Online from SharePoint Framework solutions