Deploy a Facebook Business pages connector to archive data in Microsoft 365

This article describes the process to deploy a connector that uses the Microsoft 365 Import service to import data from Facebook Business pages to Microsoft 365. For a high-level overview of this process and a list of prerequisites required to deploy a Facebook connector, see Set up a connector to archive Facebook data.

Step 1: Create an app in Microsoft Entra ID

Complete the following steps to create and register an application in Microsoft Entra ID.

  1. Go to https://portal.azure.com and sign in with the credentials of a global admin account.

    Screenshot of the Azure portal home page for creating a Microsoft Entra ID app registration.

  2. In the left navigation, select Microsoft Entra ID.

    Screenshot of the Azure portal left navigation pane with Microsoft Entra ID selected.

  3. In the left navigation, select App registrations (Preview), then select New registration.

    Screenshot of the App registrations page with the New registration option highlighted.

  4. Register the application. Under Redirect URI, select Web in the application type dropdown list, then enter https://portal.azure.com in the URI box.

    Screenshot of the Register an application page with the name, redirect URI, and Register button.

  5. Copy the Application (client) ID and Directory (tenant) ID and save them to a text file or other safe location. You use these IDs in later steps.

    Screenshot of the application overview page showing the Application ID and Directory ID values to copy.

  6. Go to Certificates & secrets for the new app.

    Screenshot of the Certificates and secrets page for the new application in the Azure portal.

  7. Select New client secret.

    Screenshot of the Client secrets section with the New client secret button highlighted.

  8. Create a new secret. In the description box, type the secret and then select an expiration period.

    Screenshot of the Add a client secret dialog with the description and expiration period fields.

  9. Copy the value of the secret and save it to a text file or other storage location. This is the Microsoft Entra application secret that you use in later steps.

    Screenshot of the client secret value displayed after creation for copying to a safe location.

Step 2: Deploy the connector web service from GitHub to your Azure account

Complete the following steps to deploy the connector web service from GitHub to your Azure account.

  1. Go to the Microsoft 365 sample connector repository and select Deploy to Azure.

    Screenshot of the GitHub repository page with the Deploy to Azure button highlighted.

  2. After you select Deploy to Azure, you're redirected to an Azure portal with a custom template page. Fill in the Basics and Settings details, then select Purchase.

    • Subscription: Select your Azure subscription that you want to deploy the Facebook Business pages connector web service to.

    • Resource group: Select or create a new resource group. A resource group is a container that holds related resources for an Azure solution.

    • Location: Select a location.

    • Web App Name: Provide a unique name for the connector web app. The name must be between 3 and 18 characters in length. This name is used to create the Azure app service URL; for example, if you provide the Web app name of fbconnector then the Azure app service URL is fbconnector.azurewebsites.net.

    • tenantId: The tenant ID of your Microsoft 365 organization that you copied after creating the Facebook connector app in Microsoft Entra ID in Step 1.

    • APISecretKey: You can type any value as the secret. This value is used to access the connector web app in Step 5.

      Screenshot of the Azure custom deployment template page with the Basics and Settings fields filled in.

  3. After the deployment is successful, the page looks similar to the following screenshot:

    Screenshot of the Azure portal showing the successful deployment of the connector web service.

Step 3: Register the Facebook app

Complete the following steps to register and configure a Facebook app for the connector.

  1. Go to https://developers.facebook.com, sign in with the credentials for the account for your organization's Facebook Business pages, and then select Add New App.

    Screenshot of the Facebook for Developers page with the Add New App option highlighted.

  2. Create a new app ID.

    Screenshot of the Facebook Create a New App ID dialog with the required fields displayed.

  3. In the left navigation, select Add Products and then select Set Up in the Facebook Login tile.

    Screenshot of the Facebook app dashboard with Add Products selected and the Facebook Login tile visible.

  4. On the Integrate Facebook Login page, select Web.

    Screenshot of the Integrate Facebook Login page with the Web platform option selected.

  5. Add the Azure app service URL, such as https://fbconnector.azurewebsites.net.

    Screenshot of the Facebook Login setup page with the Azure app service URL entered in the Site URL field.

  6. Complete the QuickStart section of the Facebook Login setup.

    Screenshot of the completed QuickStart section of the Facebook Login setup wizard.

  7. In the left navigation under Facebook Login, select Settings, and add the OAuth redirect URI in the Valid OAuth Redirect URIs box. Use the format <connectorserviceuri>/Views/FacebookOAuth, where the value for connectorserviceuri is the Azure app service URL for your organization; for example, https://fbconnector.azurewebsites.net.

    Screenshot of the Facebook Login Settings page with the OAuth redirect URI in the Valid OAuth Redirect URIs field.

  8. In the left navigation, select Add Products and then select Webhooks. In the Page pull-down menu, select Page.

    Screenshot of the Facebook app dashboard with Add Products selected and the Webhooks product tile.

  9. Add Webhooks Callback URL and add a verify token. For the callback URL, use the format <connectorserviceuri>/api/FbPageWebhook, where the value for connectorserviceuri is the Azure app service URL for your organization; for example https://fbconnector.azurewebsites.net.

    The verify token should similar to a strong password. Copy the verify token to a text file or other storage location.

    Screenshot of the Webhooks setup page with the Callback URL and verify token fields configured.

  10. Test and subscribe to the endpoint for feed.

    Screenshot of the Webhooks page showing the feed endpoint with test and subscribe options.

  11. Add a privacy URL, app icon, and business use. Also, copy the app ID and app secret to a text file or other storage location.

    Screenshot of the Facebook app settings page with the privacy URL, app icon, and business use fields.

  12. Make the app public.

    Screenshot of the Facebook app review settings page with the toggle to make the app public.

  13. Add user to the admin or tester role.

    Screenshot of the Facebook app Roles page with the option to add a user to the admin or tester role.

  14. Add the Page Public Content Access permission.

    Screenshot of the Facebook app permissions page with the Page Public Content Access permission added.

  15. Add Manage Pages permission.

    Screenshot of the Facebook app permissions page with the Manage Pages permission added.

  16. Get the application reviewed by Facebook.

    Screenshot of the Facebook App Review page showing the application submission for review by Facebook.

Step 4: Configure the connector web app

Complete the following steps to configure the connector web app with the required credentials and settings.

  1. Go to https://<AzureAppResourceName>.azurewebsites.net (where AzureAppResourceName is the name of your Azure app resource that you named in Step 4). For example, if the name is fbconnector, go to https://fbconnector.azurewebsites.net. The home page of the app looks like the following screenshot:

    Screenshot of the Facebook connector web app home page at the Azure app service URL.

  2. Select Configure to display a sign in page.

    Screenshot of the connector web app with the Configure button to display the sign-in page.

  3. In the Tenant ID box, type or paste your tenant ID (that you obtained in Step 1). In the password box, type or paste the APISecretKey (that you obtained in Step 2), then select Set Configuration Settings to display the configuration details page.

    Screenshot of the sign-in page with the Tenant ID and password fields for accessing configuration settings.

  4. Enter the following configuration settings:

    • Facebook application ID: The app ID for the Facebook application that you obtained in Step 3.

    • Facebook application secret: The app secret for the Facebook application that you obtained in Step 3.

    • Facebook webhooks verify token: The verify token that you created in Step 3.

    • Microsoft Entra application ID: The application ID for the Microsoft Entra app that you created in Step 1.

    • Microsoft Entra application secret: The value for the APISecretKey secret that you created in Step 1.

  5. Select Save to save the connector settings.

Step 5: Set up a Facebook connector

Complete the following steps to set up a Facebook connector in the Microsoft Purview portal.

  1. Sign in to the Microsoft Purview portal.

  2. Select Settings > Data connectors.

  3. Select My connectors, then select Add connector.

  4. From the list, select Facebook Business pages.

  5. On the Terms of service page, select Accept.

  6. On the Add credentials for your connector app page, enter the following information and then select Validate connection.

    • In the Name box, type a name for the connector, such as Facebook news page.
    • In the Connection URL box, type or paste the Azure app service URL, such as https://fbconnector.azurewebsites.net.
    • In the Password box, type or paste the value of the APISecretKey that you added in Step 2.
    • In the Azure App ID box, type or paste the value of the Application (client) ID, also called Microsoft Entra Application ID, that you created in Step 1.
  7. After the connection is successfully validated, select Next.

  8. On the Authorize Microsoft 365 to import data page, type or paste the APISecretKey again and then select Login web app.

  9. On the Configure Facebook connector app page, select Login with Facebook and sign in by using the credentials for the account for your organization's Facebook Business pages. Make sure the Facebook account that you sign in to is assigned the admin role for your organization's Facebook Business pages.

  10. A list of the business pages managed by the Facebook account that you sign in to is displayed. Select the page to archive and then select Next.

  11. Select Continue to exit the setup of the connector service app.

  12. On the Set filters page, you can apply a filter to initially import items that are a certain age. Select an age, and then select Next.

  13. On the Choose storage location page, type the email address of Microsoft 365 mailbox that the Facebook items will be imported to, and then select Next.

  14. Select Next to review the connector settings and then select Finish to complete the connector setup.