Create an Amazon Bedrock Knowledge Base with SharePoint Online

Introduction

Amazon Bedrock Knowledge Bases allow you to answer user queries by retrieving relevant information from various data sources, including SharePoint Online. This helps generate accurate responses, with the option to include citations for added reference. In this article, you’ll learn how to create and configure an Amazon Bedrock Knowledge Base using SharePoint Online as a data source and test it to generate responses based on SharePoint data.

Data source

SharePoint is a website-based collaboration system that is used as a secure place to store, organize, share, and access information from any device. SharePoint empowers teamwork with dynamic and productive team sites for every project team, department, and division. I have created a SharePoint site and added Wikipedia documents to the document library, as shown below.

Sharepoint

Pre-requisites

  1. AWS account and the required permissions to access Amazon Bedrock.
  2. Administrator access to SharePoint Online site.
  3. Administrator access to register an app in Microsoft Entra ID.
  4. Access to Amazon Bedrock foundation model to validate the knowledge base.

Register an app in Microsoft Entra ID

OAuth 2.0 and SharePoint App-Only are the supported authentication methods currently available for connecting Amazon Bedrock Knowledge Base to SharePoint Online. In this article, we will use OAuth 2.0 authentication to connect to the SharePoint Online data source. The following values are required and should be stored in AWS Secrets Manager.

  • username: SharePoint admin username
  • password: SharePoint admin password
  • clientId: OAuth app client ID
  • clientSecret: OAuth app client secret

Perform the following steps to register an application using Microsoft Entra ID.

  1. Navigate to Microsoft Azure Portal.
  2. Search for and click App registrations.
    App registrations
  3. Click New Registration.
    New Registration
  4. Enter a name for your application, select who can use this application, and click Register.
    Application
  5. An application will be created. You will see a page like the following screenshot. Note the application (client) ID and the directory (tenant) ID.
    SPO
  6. Select Certificates & secrets in the navigation pane. Select Client Secrets and then click New client Secrets.
    Client secrets
  7. Enter the description, select expiry, and choose Add. Note the secret value.
  8. Select API permissions in the navigation pane and click Add a permission. Select SharePoint from the list of applications. Select Delegated permissions and then select AllSites.Read permission. Click Add Permissions.
    API permissions
  9. Click Grant admin consent and select yes for confirmation.
    Grant admin

Create a Knowledge Base in Amazon Bedrock

Perform the following steps to create and configure the knowledge base in Amazon Bedrock using the AWS console.

  1. Navigate to Amazon Bedrock service in AWS Console.
  2. Select Knowledge Bases in the navigation pane. Select Create and click Knowledge Base with vector store.
    Knowledge Bases
  3. Enter the knowledge base name, and description and select Create and use a new service role.
    service role
  4. Select SharePoint as the data source.
  5. Optional: Add tags and configure log delivery. Click Next.
    Next
  6. Enter the data source name and description.
    Data source
  7. Enter the SharePoint site URL and domain name.
    Site URL
  8. Under the Authentication section, select OAuth 2.0 authentication, and click AWS Secrets Manager to create a new secret.
    Authentication section
  9. Choose another type of secret option and enter the key-value pairs as shown below. Click Next.
    key value pairs
  10. Enter the secret name and click Next. Review all the settings and click Store. Note the secret ARN.
    Store
  11. Go back to the knowledge base creation page. Enter the tenant ID and secret ARN. Click Next.
    Method
  12. Under the embeddings model section, select the embedding model as shown below.
    Embeddings model
  13. Leave the default selected values for the vector database and click Next.
     Vector database
  14. Review the configuration and click Create Knowledge Base.
     Configuration
  15. Once the knowledge base is created, select the newly created data source and click Sync.
    Sync
  16. It could take a few minutes to hours to sync, depending on the size of your data. Once the sync is completed successfully, test the knowledge base.

Validate the knowledge base

Perform the following steps to validate the newly created knowledge base using AWS Console.

  1. Navigate to Amazon Bedrock service in AWS Console.
  2. Select Knowledge Bases in the navigation pane.
  3. Select the newly created knowledge base. On the right-hand side, you will see the "Test Knowledge Base" section. Click on Select Model.
    Test Knowledge
  4. Choose any model based on your requirements. Click Apply.
    Categories
  5. Enter the prompt and you can see the response generated from the knowledge base as shown below.
    Prompt

References

Summary

This article describes how to create and configure an Amazon Bedrock Knowledge Base using SharePoint Online as a data source.


Similar Articles