Skip to main content

App Authentication

Your application needs to authenticate to send messages to Teams as your bot. Authentication allows your app service to certify that it is allowed to send messages as your Azure Bot.

Azure Setup Required

Before configuring your application, you must first set up authentication in Azure. See the App Authentication Setup guide for instructions on creating the necessary Azure resources.

Authentication Methods​

There are 3 main ways of authenticating:

  1. Client Secret - Simple password-based authentication using a client secret
  2. User Assigned Managed Identity - Passwordless authentication using Azure managed identities
  3. Federated Identity Credentials - Advanced identity federation using managed identities

Configuration Reference​

The Teams SDK automatically detects which authentication method to use based on the environment variables you set:

CLIENT_IDCLIENT_SECRETMANAGED_IDENTITY_CLIENT_IDAuthentication Method
not_setNo-Auth (local development only)
setsetClient Secret
setnot_setUser Assigned Managed Identity
setnot_setset (same as CLIENT_ID)User Assigned Managed Identity
setnot_setset (different from CLIENT_ID)Federated Identity Credentials (UMI)
setnot_set"system"Federated Identity Credentials (System Identity)
SDK 2.1

SDK 2.1 uses MSAL with standard ASP.NET Core configuration. Developers can authenticate their bot with any supported Microsoft Entra authentication solution by configuring the app according to the Microsoft.Identity.Web credential format.

Client Secret​

The simplest authentication method using a password-like secret.

Setup​

First, complete the Client Secret Setup in Azure Portal or Azure CLI.

Configuration​

Configure the following settings in appsettings.json:

appsettings.json
{
"AzureAd": {
"ClientId": "your-client-id-here",
"TenantId": "your-tenant-id",
"ClientCredentials": [
{
"SourceType": "ClientSecret",
"ClientSecret": "your-client-secret-here"
}
]
}
}

User Assigned Managed Identity​

Passwordless authentication using Azure managed identities - no secrets to rotate or manage.

Setup​

First, complete the User Assigned Managed Identity Setup in Azure Portal or Azure CLI.

Configuration​

Your application should automatically use User Assigned Managed Identity authentication when you provide the ClientId without a ClientSecret.

Configure the following settings in appsettings.json:

appsettings.json
{
"AzureAd": {
"ClientId": "your-client-id-here",
"TenantId": "your-tenant-id"
}
}

Federated Identity Credentials​

Advanced identity federation allowing you to assign managed identities directly to your App Registration.

Setup​

First, complete the Federated Identity Credentials Setup in Azure Portal or Azure CLI.

Configuration​

Depending on the type of managed identity you select, configure the corresponding settings in appsettings.json.

appsettings.json
{
"AzureAd": {
"ClientId": "your-app-client-id-here",
"TenantId": "your-tenant-id",
"ClientCredentials": [
{
"SourceType": "SignedAssertionFromManagedIdentity",
"ManagedIdentityClientId": "your-managed-identity-client-id-here"
}
]
}
}

For system-assigned identity, omit ManagedIdentityClientId:

appsettings.json
{
"AzureAd": {
"ClientId": "your-app-client-id-here",
"TenantId": "your-tenant-id",
"ClientCredentials": [
{
"SourceType": "SignedAssertionFromManagedIdentity"
}
}
}
}

Troubleshooting​

If you encounter authentication errors, see the Authentication Troubleshooting guide for common issues and solutions.