Configure a bot in Microsoft Azure operated by 21Vianet
This guide helps Microsoft Azure customers deploy Bot Framework and Azure AI Bot Service bots on the Microsoft Azure platform operated by 21Vianet.
Prerequisites
- An account in the Azure operated by 21Vianet.
- The C# or JavaScript bot project you want to configure.
- Bot Framework SDK version 4.14 or later.
Use the cloud adapter
Make sure that your bot uses the cloud adapter, or an adapter that derives from the cloud adapter. The cloud adapter lets you specify settings specific to the Azure Cloud.
The ConfigurationBotFrameworkAuthentication
class reads authentication settings from your bot configuration file. Upon creation, the cloud adapter utilizes these authentication settings.
Make sure that the ConfigureServices
method in your Startup.cs file contains this line.
services.AddSingleton<BotFrameworkAuthentication, ConfigurationBotFrameworkAuthentication>();
Configure UserAssignedMSI/SingleTenant Bot
To ensure the bot functions correctly in the Microsoft Azure Cloud, extra authentication settings are necessary. Replace the "App-Tenant-ID" with the bot's tenant ID.
Add the following settings to your appsettings.json file.
"OAuthUrl": "https://token.botframework.azure.cn/",
"ToChannelFromBotLoginUrl": "https://login.partner.microsoftonline.cn/<App-Tenant-ID>",
"ToChannelFromBotOAuthScope": "https://api.botframework.azure.cn",
"ToBotFromChannelTokenIssuer": "https://api.botframework.azure.cn",
"ToBotFromChannelOpenIdMetadataUrl": "https://login.botframework.azure.cn/v1/.well-known/openidconfiguration",
"ToBotFromEmulatorOpenIdMetadataUrl": "https://login.partner.microsoftonline.cn/a55a4d5b-9241-49b1-b4ff-befa8db00269/v2.0/.well-known/openid-configuration",
"ValidateAuthority": true
Configure MultiTenant Bot
For the multitenant bot, use the following settings.
Add the following settings to your appsettings.json file.
"OAuthUrl": "https://token.botframework.azure.cn/",
"ToChannelFromBotLoginUrl": "https://login.partner.microsoftonline.cn/microsoftservices.partner.onmschina.cn",
"ToChannelFromBotOAuthScope": "https://api.botframework.azure.cn",
"ToBotFromChannelTokenIssuer": "https://api.botframework.azure.cn",
"ToBotFromChannelOpenIdMetadataUrl": "https://login.botframework.azure.cn/v1/.well-known/openidconfiguration",
"ToBotFromEmulatorOpenIdMetadataUrl": "https://login.partner.microsoftonline.cn/a55a4d5b-9241-49b1-b4ff-befa8db00269/v2.0/.well-known/openid-configuration",
"ValidateAuthority": true
Add user authentication to your bot
Your bot can use various identity providers to access resources on behalf of a user, such as Microsoft Entra ID and many other OAuth providers.
The Microsoft Azure Cloud uses a redirect URL that is different from the ones used for other environments.
To configuring your bot for authentication, use https://token.botframework.azure.cn/.auth/web/redirect
as the OAuth redirect URL and follow the steps in how to add authentication to your bot.
Configure a bot to run on one or more channels
To configure a bot to connect to a channel, complete the following steps:
- Sign in to the Azure portal.
- Select the bot that you want to configure.
- In the left pane, select Channels under Settings.
- In the right pane, select the icon of the channel you want to add to your bot. You may need to scroll down to see the list of all Available Channels. The connection steps vary for each channel. For more information on supported channels, see the related articles.
Channel | Description |
---|---|
Direct Line | Integrate a bot into a mobile app, web page, or other applications. |
Microsoft Teams | Configure a bot to communicate with users through Microsoft Teams. |
Web Chat | Automatically configured for you when you create a bot with the Bot Framework Service. |
Next steps
With these steps, your bot should be configured to work successfully. Other useful references regarding Bot Service.