Skip to main content

BYOA-Backup Teams Chat by manually deploying the Enterprise App

Updated over a week ago

Overview

To back up Microsoft Teams Chat, customers must create and configure a custom App Registration in Microsoft Entra ID.

Druva provides a PowerShell script-driven automation that deploys the App, the required self-signed certificate, and also assigns the required GRAPH Permissions, using Azure Web Shell. Refer to this document for setting up the App using Azure Web Shell.

Azure Web Shell requires a separate subscription from Microsoft. If you do not have Azure Web Shell, then this document will help you to deploy the App Manually.

This app is used for app-only authentication with Microsoft Graph and requires:

  • Microsoft Graph Application permissions

  • A client secret

  • A self-signed certificate uploaded to the app


    📝NOTE: If you would like to use a third-party CA Certificate, then you may skip the steps to create self signed certificate. But ensure that the CA Cert has a Private Key in Base64 format, to upload to Druva Portal during configuration.



Step 1: Create an App Using App Registration in Microsoft Entra ID

This step covers:

  • Creating a custom app

  • Generating a client secret

  • Assigning required Microsoft Graph permissions


1.1 Create a New App Registration

  1. Sign in to the Azure Portal
    https://portal.azure.com

  2. Navigate to Microsoft Entra ID > App registrations

  3. Click + New registration

  4. Fill in the following:

    • Name:
      Example: Teams-Chat-Backup-App

    • Supported account types:
      Select Accounts in this organizational directory only

    • Redirect URI:
      Leave this blank

  5. Click Register

  6. After creation, note the following value (required later. Also available under App Properties):

    • Application (client) ID

      📝NOTE: ObjectID is not needed.


1.2 Generate a Client Secret

  1. Inside the newly created app, go to: Certificates & secrets

  2. Under Client secrets, click + New client secret

  3. Enter:

    • Description: TeamsBackup

    • Expires: Choose an appropriate duration (e.g., 12 or 24 months)

  4. Click Add

  5. Immediately copy and store the secret value

    • This value is shown only once

    • Losing it will require creating a new secret


1.3 Assign Microsoft Graph Permissions

The app must have the following Application permissions:

  • User.Read.All

  • Chat.Read.All

Steps to Assign Permissions

  1. Go to API permissions

  2. Click + Add a permission

  3. Select Microsoft Graph

  4. Choose Application permissions

  5. Add the following:

    • User.Read.All

    • Chat.Read.All

  6. Click Add permissions

Grant Admin Consent

  1. Click Grant admin consent

  2. Confirm the action


❗IMPORTANT

  • Only Application permissions are supported

  • Delegated permissions will not work

  • Admin consent is mandatory



Step 2: Create a Self-Signed Certificate (Windows)

This step explains how to:

  • Install OpenSSL

  • Create a self-signed certificate

  • Export the private key

  • Convert it to Base64 single-line format


2.1 Download and Install OpenSSL (Windows)

  1. Download OpenSSL for Windows from:
    https://slproweb.com/products/Win32OpenSSL.html

  2. Download Win64 OpenSSL – Light or Full

  3. Install OpenSSL and ensure:

    • Option “Add OpenSSL to the system PATH” is selected

  4. Verify installation:

    • Open Command Prompt and run: openssl version


2.2 Create a Self-Signed Certificate and Private Key

  1. Launch Windows PowerShell as Admin and execute the below command:

    $cert = New-SelfSignedCertificate `
    -Subject "CN=DruvaTeamsBackup" `
    -CertStoreLocation "Cert:\CurrentUser\My" `
    -KeyExportPolicy Exportable `
    -KeySpec Signature `
    -KeyLength 2048 `
    -HashAlgorithm SHA256
  2. Create Working Folders (Windows PowerShell);

    New-Item -ItemType Directory -Path C:\DruvaCerts -Force
  3. Export the certificate as PFX (local use only) (Windows PowerShell)

    $pfxPass = ConvertTo-SecureString -String "TempPassword123!" -AsPlainText -Force

    Export-PfxCertificate `
    -Cert $cert `
    -FilePath "C:\DruvaCerts\DruvaTeamsBackup.pfx" `
    -Password $pfxPass
  4. Export the public certificate (for Entra ID) (Windows PowerShell)

    Export-Certificate `
    -Cert $cert `
    -FilePath "C:\DruvaCerts\DruvaTeamsBackup.cer"
  5. Extract the private key using OpenSSL (CMD)

    openssl pkcs12 -in C:\DruvaCerts\DruvaTeamsBackup.pfx ^
    -password pass:TempPassword123! ^
    -nodes -nocerts ^
    -out C:\DruvaCerts\DruvaTeamsBackup-raw.pem
  6. Convert the private key to PKCS#8 (unencrypted) (CMD)

    openssl pkcs8 -in C:\DruvaCerts\DruvaTeamsBackup-raw.pem ^
    -topk8 -nocrypt ^
    -out C:\DruvaCerts\DruvaTeamsBackup-privatekey.pem


    Output will look like:

    -----BEGIN PRIVATE KEY-----
    ...
    -----END PRIVATE KEY-----
  7. Normalize the private key for the Druva UI (Windows PowerShell)

    (Get-Content C:\DruvaCerts\DruvaTeamsBackup-privatekey.pem -Raw) -replace "`r?`n", "\n"


    Output will look like:

    -----BEGIN PRIVATE KEY-----\nBASE64DATA...\n-----END PRIVATE KEY-----\n

Step 3: Upload the Certificate to the App in Entra ID

This step links the certificate to the app created in Step 1.


Upload the Certificate

  1. Go to Azure Portal

  2. Navigate to Microsoft Entra ID > App registrations

  3. Select the previously created app

  4. Go to Certificates & secrets

  5. Under Certificates, click Upload certificate

  6. Select the file: certificate.crt

  7. Click Add

Step 4: Configure Druva inSync to backup M365 Chat using this Enterprise App

  1. Login to Druva Admin Console

  2. Click on Menu at top left > Microsoft 365

  3. Click on “Teams Chat” > click “Install Azure App”

  4. In the pop up form, fill in the details as below:

    • Application Name: The name of the app from EntraID.

    • ClientID: The Application (client) ID of the app.

    • Client Secret: Client secret generated in EntraID for the App

    • Secret Expiry: Client’s secret expiration date set in EntraID

    • Thumbprint: Cert Thumbprint from the App in EntraID

    • Private Key: Normalized Private Key in Single Line format as below:

    .-----BEGIN PRIVATE KEY-----\nBASE64DATA...\n-----END PRIVATE KEY-----\n
  5. Save

  6. If the App shows “Disconnected”, validate the steps once again.

Step 5: Configure the Druva inSync profile to start backing up Teams Chat Data.

Did this answer your question?