Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
3210cad
[Doc Feature][Update Bot/ME Project to use Certificate or MSI][3928131]
v-bvishnu Sep 12, 2024
d02d116
Update
v-bvishnu Sep 12, 2024
edde967
Update update-bot-me-project-to-use-certificate-or-msi-for-authentica…
v-bvishnu Sep 12, 2024
083d8d9
Update TOC.yml
v-bvishnu Sep 12, 2024
144bb78
Images added.
v-bvishnu Sep 12, 2024
914152c
Updated.
v-bvishnu Sep 12, 2024
1e5fc6d
Update.
v-bvishnu Sep 12, 2024
191fa95
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-bvishnu Sep 12, 2024
fd9542f
Update whats-new.md
v-bvishnu Sep 12, 2024
1c7b34a
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-bvishnu Sep 12, 2024
750eaec
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-deabira Sep 14, 2024
4b7ef3c
Update msteams-platform/toolkit/update-bot-me-app-to-use-certificate-…
v-preethah Sep 14, 2024
08ff12e
.
v-deabira Sep 14, 2024
1c4bb02
Merge branch 'update-bot/ME-project-to-use-certificate-or-MSI' of htt…
v-deabira Sep 14, 2024
5fd5d90
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-shalinir Sep 16, 2024
4f07e6c
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-shalinir Sep 16, 2024
b4421b9
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-shalinir Sep 16, 2024
f01c668
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-shalinir Sep 16, 2024
0c7302a
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-shalinir Sep 16, 2024
ee2fe4f
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-shalinir Sep 17, 2024
8615273
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-deabira Sep 17, 2024
ac24728
Merge branch 'update-bot/ME-project-to-use-certificate-or-MSI' of htt…
v-shalinir Sep 17, 2024
5101d2f
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-shalinir Sep 17, 2024
806c047
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-bvishnu Oct 21, 2024
c43f3a5
Updated
v-bvishnu Oct 21, 2024
f47464e
Update whats-new.md
v-bvishnu Oct 22, 2024
017ab2b
Updated.
v-bvishnu Oct 22, 2024
ca03a08
Updated.
v-bvishnu Oct 22, 2024
8f7e966
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-bvishnu Oct 24, 2024
9630e7b
Update certificates-secrets.png
v-bvishnu Oct 24, 2024
65b59f3
Update upload-certificate.png
v-bvishnu Oct 24, 2024
7bdfeaf
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-bvishnu Oct 25, 2024
ebaf318
Updated.
v-bvishnu Oct 25, 2024
ccda37e
Update whats-new.md
v-bvishnu Oct 25, 2024
0bd8a58
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-bvishnu Oct 27, 2024
9a0f48a
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-bvishnu Oct 27, 2024
d0edb4d
Update update-bot-me-app-to-use-certificate-or-msi-for-authentication.md
v-bvishnu Oct 27, 2024
729adbc
Updated.
v-bvishnu Oct 28, 2024
e329c53
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-bvishnu Oct 28, 2024
cc9e2c4
Merge branch 'main' into update-bot/ME-project-to-use-certificate-or-MSI
v-bvishnu Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Doc Feature][Update Bot/ME Project to use Certificate or MSI][3928131]
  • Loading branch information
v-bvishnu committed Sep 12, 2024
commit 3210cada332f4702189e428edad55b23bf79ba52
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
title: Update bot/ME project to use Certificate or MSI for Authentication
author: surbhigupta
description: Learn about Update bot/ME project to use Certificate or MSI for Authentication.
ms.topic: conceptual
ms.author: surbhigupta
ms.localizationpriority: high
---

# Update bot/ME project to use Certificate or MSI for Authentication

## Introduction

This guide provides step-by-step instructions to update your existing bot project from using a Bot ID and secret for authentication to using a certificate or Managed Service Identity (MSI). This change helps address compliance concerns related to using Entra ID with a secret.

## Prerequisites

Before proceeding, ensure that you have a Teams bot app deployed to Azure with the following resources:

- An Azure Bot Service.
- An Entra ID with a secret used for bot authentication.
- A resource that hosts your bot app (e.g., Azure App Service, Azure Functions).

## Updating to Certificate-Based Authentication

### Step 1: Prepare and Upload the Certificate

1. Obtain a certificate and private key.
2. Upload the certificate to your Entra ID.

### Step 2: Update Your Code and Deploy

#### For TypeScript/JavaScript Projects

```javascript
const credentialsFactory = new ConfigurationServiceClientCredentialFactory({
MicrosoftAppId: config.botId,
CertificatePrivateKey: '{your private key}',
CertificateThumbprint: '{your cert thumbprint}',
MicrosoftAppType: "MultiTenant",
});

const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication(
{},
credentialsFactory
);

const adapter = new CloudAdapter(botFrameworkAuthentication);
```

#### For C# Projects

```csharp
builder.Services.AddSingleton<ServiceClientCredentialsFactory>((e) =>
new CertificateServiceClientCredentialsFactory("{your certificate}", "{your Entra ID}")
);
```

### Step 3: Test Your Bot App

Ensure your bot functions correctly with the updated authentication method.

### Step 4: Clean Up Secrets

Once verified, delete the secrets in your Entra ID to maintain security compliance.

## Updating to MSI-Based Authentication

### Step 1: Create a New Azure Bot Service with MSI

Since the Azure Bot Service’s ID and type cannot be modified after creation, follow these steps:

1. Create a new Azure Bot Service, selecting **User-Assigned Managed Identity** as the type and **Create new Microsoft App ID** as the creation type. This will automatically create the Azure Bot Service and the associated managed identity.

*Alternatively*: You can manually create a managed identity first, then create the Azure Bot Service using the "Use existing app registration" option.

2. Update the new Azure Bot Service’s messaging endpoint and channels to match those of the old service.

### Step 2: Assign the Managed Identity to Your Hosting Resource

1. Navigate to your app’s hosting resource.
2. Select **Settings > Identity > User assigned**.
3. Add the managed identity created in the previous step.

### Step 3: Update Your Code and Deploy

#### For TypeScript/JavaScript Projects

```javascript
const credentialsFactory = new ConfigurationServiceClientCredentialFactory({
MicrosoftAppType: 'UserAssignedMsi',
MicrosoftAppId: '{your MSI’s client ID}',
MicrosoftAppTenantId: '{your MSI’s tenant ID}',
});

const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication(
{},
credentialsFactory
);

const adapter = new CloudAdapter(botFrameworkAuthentication);
```

#### For C# Projects

```csharp
builder.Configuration["MicrosoftAppType"] = "UserAssignedMsi";
builder.Configuration["MicrosoftAppId"] = "{your MSI’s client ID}";
builder.Configuration["MicrosoftAppPassword"] = "{your MSI’s tenant ID}";
builder.Services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFrameworkAuthentication>();
```

### Step 4: Update the `BOT_ID` Value in the `.env` File

Update the `BOT_ID` value in your `.env` file to reflect your newly created managed identity’s client ID.

### Step 5: Test Your Bot App

Verify that your bot operates as expected with the updated authentication.

### Step 6: Clean Up Unneeded Resources

If everything is functioning correctly, you can delete the old Azure Bot Service and the old Entra ID to clean up unnecessary resources.