Register a bot with Azure

APPLIES TO: SDK v4

This article shows how to register a bot with the Azure Bot Service when you develop and host it in Azure.

If the bot is hosted elsewhere, you can also make it available in Azure and connect it to the supported channels. You supply the web address where your bot is hosted.

Important

You only need to register a bot if it is not hosted in Azure. Bots created using Azure CLI are already registered with the Azure Bot Service.

This article does not describe how to create or deploy the bot to register. For more information see:

Create the resource

Create the Azure Bot resource, which will allow you to register your bot with the Azure Bot Service.

Warning

Web App Bot and Bot Channels Registration are deprecated but existing resources will continue to work. You should use Azure Bot, instead.

  1. Go to the Azure portal.

  2. In the right pane, select Create a resource.

  3. In the search box enter bot, then press Enter.

  4. Select the Azure Bot card.

    Select Azure bot resource

  5. Select Create.

    Create Azure bot resource

  6. Enter the required values. The following figure shows Create new Microsoft App ID selected.

    Create Azure bot resource values

    You can also select Use existing app registration and enter your existing app ID and password.

    Create Azure bot resource existing values

  7. Select Review + create.

  8. If the validation passes, select Create.

  9. Select Go to resource group. You should see the bot and the related Azure Key Vault resources listed in the resource group you selected.

    Tip

    The app secret (password) is stored in the the key vault and there is one key vault per resource group. Using key vault is recommended instead of copying and storing sensitive data.

  10. Select Get the SDK from Github to build your bot with the Bot Framework SDK.

    Create bot in SDK

Azure Key Vault

When Azure creates the Azure Bot resource, it also generates an app ID and a password and stores the password in Azure Key Vault.

Key Vault is a service that provides centralized secrets management, with full control over access policies and audit history. For more information, see Use Key Vault references for App Service and Azure Functions. You're charged a small fee for using the service. For more information, see Key Vault pricing.

App ID and password

You need the Azure bot resource app ID and password to configure your bot for deployment. You'll assign their values to the related variables: MicrosoftAppId and MicrosoftAppPassword contained in your bot project configuration file. The file differs depending on the programming language you use to create the bot.

The appsettings.json file contains these settings:

{
  "MicrosoftAppId": "<your app ID>",
  "MicrosoftAppPassword": "<your password>"
}

Get Azure Bot resource app ID

  1. Go to the Azure portal.
  2. Select the Azure Bot resource to obtain its app ID.
  3. In the left pane, in the Settings section, select Configuration.
  4. Copy and save the value contained in the Microsoft App ID box.

Get Azure bot resource password from Azure Key Vault

When Azure creates the Azure Bot resource, it stores the app password in Azure Key Vault. For information on how to access the key vault to obtain your password, see:

Manual app registration

A manual registration is necessary when:

  • You are unable to make the registrations in your organization and need another party to create the App ID for the bot you're building.
  • You need to manually create your own app ID and password.

Important

When creating the app, in the section Supports account types, choose one of the following multi-tenant types options:

Type Description
Accounts in any organizational directory (Any Azure AD - Multitenant) This option provides less exposure by restricting access and in case OAuth is not supported.
Accounts in any organizational directory (Any Azure AD - Multitenant) and personal Microsoft accounts (for example, Xbox, Outlook.com) This option is well-suited to support OAuth and bot authentication.

For more information, see Register an application with the Microsoft identity platform.

Update the bot

Set the following key values in the appsettings.json file:

  • MicrosoftAppId = <appId>
  • MicrosoftAppPassword = <appSecret>

Next steps