This article creates an Azure Bot resource for your bot.
Existing bots that use a Web App Bot resource or a Bot Channels Registration resource will continue to work, but you can't create new bots that use these resource types.
Note
The Bot Framework JavaScript, C#, and Python SDKs will continue to be supported, however, the Java SDK is being retired with final long-term support ending in November 2023.
Existing bots built with the Java SDK will continue to function.
For your programming language, use the following version of the Azure CLI.
Some steps won't work with later versions of the CLI.
Language
CLI version
C# and JavaScript
2.39.0 or later
Python
2.55.0 or later
Java
2.29.2
Note
If your bot uses additional resources, such as a storage service or language services, these need to be deployed separately.
Plan your deployment
Before you begin, make these decisions.
Decision
Notes
How you'll manage the identities of your bot resources in Azure
You can use a user-assigned managed identity, a single-tenant app registration, or a mutli-tenant app registration. For more information, see Create an identity resource.
In which resource group or resource groups you'll create your bot resources
Until you're familiar with this process, we recommend using one resource group. For more information, see Manage Azure resources.
Your bot identity can be managed in Azure in a few different ways.
As a user-assigned managed identity, so that you don't need to manage the bot's credentials yourself.
As a single-tenant app.
As a multi-tenant app.
Support for the user-assigned managed identity and single-tenant app types was added to the Bot Framework SDK for C#, JavaScript, and Python.
These app types aren't supported in the other languages or in Bot Framework Composer, Bot Framework Emulator, or Dev Tunnels.
App type
Support
User-assigned managed identity
Azure AI Bot Service and the C#, JavaScript, and Python SDKs
Single-tenant
Azure AI Bot Service and the C#, JavaScript, and Python SDKs
Multi-tenant
Azure AI Bot Service, all Bot Framework SDK languages, Composer, the Emulator, and Dev Tunnels
Important
Python bots can't be deployed to a resource group that contains Windows services or bots.
However, multiple Python bots can be deployed to the same resource group.
Create other services, such as Azure AI services, in a different resource group.
Azure resources
Before you can deploy your bot, you create (or provision) the Azure resources it will need.
For some of the steps, you can use an existing resource or create a new one.
You may find it helpful to decide ahead of time on the names of the new resources you'll create and the names of the existing resources you'll use.
Your bot will use these types of resources.
The Azure subscription that you'll use to provision, publish, and manage the bot
One or more resource groups
A user-assigned managed identity or an Microsoft Entra ID app registration
An App Service Plan resource
An App Service resource
An Azure Bot resource
Information used across resources
As you create resources in Azure, Azure will generate or request IDs, passwords, and other information that you'll need in later steps.
The following table lists the information beyond resource names you'll need to record, in which step it's generated, and in which steps it's used.
Caution
Many of these IDs and passwords are sensitive information. For information about common security guidelines, see Bot Framework security guidelines.
A browser window will open. Complete the sign-in process.
On success, the command outputs a list of the subscriptions your account has access to.
To set the subscription to use, run:
Azure CLI
az account set --subscription"<subscription>"
For <subscription>, use the ID or name of the subscription to use.
If you'll create a user-assigned managed identity or a single-tenant bot, record the tenantId for the subscription.
You'll use the tenant ID in the following steps.
For Azure CLI 2.39.0 or later, use the following commands to create your app registration and set its password. On success, these commands generate JSON output.
Use the az ad app create command to create an Microsoft Entra ID app registration.
This command generates an app ID that you'll need in later steps.
Azure CLI
az ad app create --display-name"<app-registration-display-name>"--sign-in-audience"AzureADandPersonalMicrosoftAccount"
Option
Description
display-name
The display name for your app registration.
sign-in-audience
The supported Microsoft accounts for the app. Use AzureADandPersonalMicrosoftAccount for a multi-tenant app.
Use the az ad app credential reset command to generate a new password for your app registration.
Azure CLI
az ad app credential reset --id"<appId>"
Record values you'll need in later steps: the app ID and password from the command output.
For more information about az ad app, see the command reference. For more information about the sign-in-audience parameter, see sigInAudience values.
For Azure CLI 2.36.0 or earlier, use the following command to create your app registration and set its password. On success, this command generates JSON output.
Use the az ad app create command to create an Microsoft Entra ID app registration.
Azure CLI
az ad app create --display-name"<name>"--password"<password>"--available-to-other-tenants
Option
Description
display-name
The display name for the app registration.
password
The password, or client secret, for the application. It must be at least 16 characters long and contain at least one upper-case or lower-case alphabetical character, at least one numeric character, and at least one special character.
available-to-other-tenants
Include this flag to create a multi-tenant bot. It allows the application to be accessible from any Microsoft Entra ID tenant.
Record values you'll need in later steps.
The password you used
The app ID from the command output
Create resources with ARM templates
Create the App Service and the Azure Bot resources for your bot.
Both steps use an ARM template and the az deployment group create Azure CLI command to create the resource or resources.
Create an App Service resource for your bot. The App service can be within a new or existing App Service Plan.
You can do these steps in either order.
However, if you create your Azure Bot first, you'll need to update its messaging endpoint after you create your App Service resource.
Update project configuration settings
Bot identity information
Follow these steps to add identity information to your bot's configuration file.
The file differs depending on the programming language you use to create the bot.
Important
The Java version of the Bot Framework SDK only supports multi-tenant bots.
The C#, JavaScript, and Python versions support all three application types for managing the bot's identity.
Language
File name
Notes
C#
appsettings.json
Supports all three application types for managing your bot's identity.
JavaScript
.env
Supports all three application types for managing your bot's identity.
Java
application.properties
Only supports multi-tenant bots.
Python
config.py
Supports all three application types for managing your bot's identity.
The identity information you need to add depends on the bot's application type.
Provide the following values in your configuration file.
Switch to your project's root folder. For C#, the root is the folder that contains the .csproj file.
Do a clean rebuild in release mode.
If you haven't done so before, run az bot prepare-deploy to add required files to the root of your local source code directory.
This command generates a .deployment file in your bot project folder.
Azure CLI
az bot prepare-deploy --lang Csharp --code-dir"."--proj-file-path"<my-cs-proj>"
Option
Description
lang
The language or runtime of the bot. Use Csharp.
code-dir
The directory to place the generated deployment files in. Use your project's root folder. Default is the current directory.
proj-file-path
The path to the .csproj file for your bot, relative to the code-dir option.
Within your project's root folder, create a zip file that contains all files and subfolders.
Switch to your project's root folder.
For JavaScript, the root is the folder that contains the app.js or index.js file.
For TypeScript, the root is the folder that contains the src folder (where the bot.ts and index.ts files are).
Run npm install.
If you haven't done so before, run az bot prepare-deploy to add required files to the root of your local source code directory.
This command generates a web.config file in your project folder.
Azure App Services requires each Node.js bot to include a web.config file in its project root folder.
Azure CLI
az bot prepare-deploy --lang<language>--code-dir"."
Option
Description
lang
The language or runtime of the bot. Use Javascript or Typescript.
code-dir
The directory to place the generated deployment files in. Use your project's root folder. Default is the current directory.
Within your project's root folder, create a zip file that contains all files and subfolders.
Switch to your project's root folder.
In the project directory, run the following command from the command line:
Console
mvn clean package
Tip
For Python bots, dependency installation is performed on the server.
The ARM templates require your dependencies to be listed in a requirements.txt file.
If you're using a dependency and package manager:
Convert your dependencies list to a requirements.txt file
Add requirements.txt to the folder that contains app.py.
Within your project's root folder, create a zip file that contains all files and subfolders.
Publish your bot to Azure
At this point, you're ready to deploy code for your bot to your App Service resource.
Note
This step can take a few minutes to complete.
Also it can take a few more minutes between when the deployment finishes and when your bot is available to test.
Run the az webapp deploy command from the command line to perform deployment using the Kudu zip push deployment for your app service (web app).
Option
Description
resource-group
The name of the Azure resource group that contains your bot.
name
Name of the app service you used earlier.
src
The absolute or relative path to the zipped project file you created.
Tip
By default, this command deploys to the production slot. Use the optional --slot parameter to specify a different slot.
For more information, see the az webapp deploy command reference documentation.
In the project directory, run the following command from the command line.
The web app deployment command uses Kudu to deploy C#, JavaScript, and Python bots.
When using the non-configured zip deploy API to deploy your bot's code, the behavior is as follows:
Kudu assumes by default that deployments from .zip files are ready to run and don't require extra build steps during deployment, such as npm install or dotnet restore/dotnet publish.
It's important to include your built code with all necessary dependencies in the zip file being deployed; otherwise, your bot won't work as intended. For more information, see the Azure documentation on how to Deploy files to App Service.
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.