Provision and publish a bot in Azure - Bot Service (2024)

  • Article

APPLIES TO: SDK v4

This article describes how to use the Azure CLI to create resources for your bot, prepare your bot for deployment, and deploy your bot to Azure.

This article assumes that you have a bot ready to be deployed. For information on how to create a simple echo bot, see Create a bot with the Bot Framework SDK. You can also use one of the samples provided in the Bot Framework Samples repository.

Tip

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 new bot building, consider using Microsoft Copilot Studio and read about choosing the right copilot solution.

For more information, see The future of bot building.

Prerequisites

  • For Java bots, install Maven.

  • This process uses two Azure Resource Manager templates (ARM templates) to create resources for your bot.

    If you don't have the current templates, create a copy in your bot project of the deploymentTemplates folder: C#, JavaScript, Python, or Java.

To use the Azure CLI to provision and publish bots, you need:

  • An Azure account that has an active subscription. Create a free account.

  • An install of the Azure CLI.

    For your programming language, use the following version of the Azure CLI.Some steps won't work with later versions of the CLI.

    LanguageCLI version
    C# and JavaScript2.39.0 or later
    Python2.55.0 or later
    Java2.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.

DecisionNotes
How you'll manage the identities of your bot resources in AzureYou 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 resourcesUntil you're familiar with this process, we recommend using one resource group. For more information, see Manage Azure resources.
Whether your bot will be regional or globalFor information about regional bots, see Regionalization in Azure AI Bot Service.

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 ngrok.

App typeSupport
User-assigned managed identityAzure AI Bot Service and the C#, JavaScript, and Python SDKs
Single-tenantAzure AI Bot Service and the C#, JavaScript, and Python SDKs
Multi-tenantAzure AI Bot Service, all Bot Framework SDK languages, Composer, the Emulator, and ngrok

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.

  • User-assigned managed identity
  • Single-tenant
  • Multi-tenant
InformationWhere generated or foundWhere used
Tenant IDSign in and select subscriptionUse Azure CLI to create an App Service resource, Use Azure CLI to create or update an Azure Bot resource, Update project configuration settings
App typeCreate an identity resourceUse Azure CLI to create an App Service resource, Use Azure CLI to create or update an Azure Bot resource, Update project configuration settings
Client IDCreate an identity resourceUse Azure CLI to create an App Service resource, Use Azure CLI to create or update an Azure Bot resource, Update project configuration settings
Base app service URLUse Azure CLI to create an App Service resourceUse Azure CLI to create or update an Azure Bot resource
App Service nameUse Azure CLI to create an App Service resourcePublish your bot to Azure

Sign in and select subscription

  1. Open a command window.

  2. Sign in to Azure.

    az login
    • 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.
  3. To set the subscription to use, run:

    az account set --subscription "<subscription>"

    For <subscription>, use the ID or name of the subscription to use.

  4. 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.

Tip

If you need to work in a non-public cloud, see Azure cloud management with the Azure CLI.

Create resource groups

If you don't already have an appropriate resource group, use the az group create command to create the new resource groups you need.

az group create --name "<group>" --location "<region>"
OptionDescription
nameThe name of the resource group to create.
locationThe region in which to create the resource group.

For more information, see How to manage Azure resource groups with the Azure CLI.

Create an identity resource

  • User-assigned managed identity
  • Single-tenant
  • Multi-tenant
  1. To create a user-assigned managed identity, use the az identity create command.On success, the command generates JSON output.

    az identity create --resource-group "<group>" --name "<identity>"
    OptionDescription
    resource-groupThe name of the resource group in which to create the identity.
    nameThe name of the identity resource to create.

    For more information, see the az identity reference.

  2. Record values you'll need in later steps.

    1. The resource group name for the identity resource
    2. The name of the identity resource
    3. The clientId 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.

  1. Create an App Service resource for your bot. The App service can be within a new or existing App Service Plan.

    For detailed steps, see Use Azure CLI to create an App Service.

  2. Create an Azure Bot resource for your bot.

    For detailed steps, see Use Azure CLI to create or update an Azure Bot.

Important

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.

LanguageFile nameNotes
C#appsettings.jsonSupports all three application types for managing your bot's identity.
JavaScript.envSupports all three application types for managing your bot's identity.
Javaapplication.propertiesOnly supports multi-tenant bots.
Pythonconfig.pySupports 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.

  • User-assigned managed identity
  • Single-tenant
  • Multi-tenant

Available for C#, JavaScript, and Python bots.

PropertyValue
MicrosoftAppTypeUserAssignedMSI
MicrosoftAppIdThe client ID of the user-assigned managed identity.
MicrosoftAppPasswordNot applicable. Leave this blank for a user-assigned managed identity bot.
MicrosoftAppTenantIdThe tenant ID of the user-assigned managed identity.

Prepare your project files

Prepare your project files before you deploy your bot.

  • C#
  • JavaScript
  • Java
  • Python
  1. Switch to your project's root folder. For C#, the root is the folder that contains the .csproj file.

  2. Do a clean rebuild in release mode.

  3. 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.

    az bot prepare-deploy --lang Csharp --code-dir "." --proj-file-path "<my-cs-proj>"
    OptionDescription
    langThe language or runtime of the bot. Use Csharp.
    code-dirThe directory to place the generated deployment files in. Use your project's root folder. Default is the current directory.
    proj-file-pathThe path to the .csproj file for your bot, relative to the code-dir option.
  4. 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.

  • C# / JavaScript / Python
  • Java

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).

OptionDescription
resource-groupThe name of the Azure resource group that contains your bot.
nameName of the app service you used earlier.
srcThe 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.

Test in Web Chat

  1. In your browser, navigate to the Azure portal.
  2. Go to your bot resource.
  3. Open the Test in Web Chat pane.
  4. Interact with your deployed bot.

For more information about bot registration, see Register a bot with Bot Service.

Clean up resources

If you're not going to publish this application, delete the associated resources with the following steps:

  1. In the Azure portal, open the resource group for your bot.
    1. Select Delete resource group to delete the group and all the resources it contains.
    2. Enter the resource group name in the confirmation pane, then select Delete.
  2. If you created a single-tenant or multi-tenant app:
    1. Go to the Microsoft Entra ID blade.
    2. Locate the app registration you used for your bot, and delete it.

Additional resources

See these articles for more information about Azure applications and resources that are used to host a bot.

SubjectArticle
Azure CLIWhat is the Azure CLI?
Azure subscription managementHow to manage Azure subscriptions with the Azure CLI
Azure regionsRegions and availability zones
Resource groups and resource managementManage Azure resources
Managed identitiesWhat are managed identities for Azure resources?
Single-tenant and multi-tenant appsTenancy in Microsoft Entra ID
Web applicationsApp Service
Compute resources for web applicationsApp Service plans
Azure Resource Manager templates (ARM templates)What are ARM templates? and How to use Azure Resource Manager (ARM) deployment templates with Azure CLI
Azure billingBilling and cost management

Kudu files

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.

Next steps

Set up continuous deployment

Provision and publish a bot in Azure - Bot Service (2024)
Top Articles
SuperVPN Review 2024: What They Won’t Tell You
Fidelity Student Loan Refinance: A Comprehensive Guide For 2023
Use Copilot in Microsoft Teams meetings
Le Blanc Los Cabos - Los Cabos – Le Blanc Spa Resort Adults-Only All Inclusive
Obor Guide Osrs
Coindraw App
Doublelist Paducah Ky
Academic Integrity
Kristine Leahy Spouse
Fototour verlassener Fliegerhorst Schönwald [Lost Place Brandenburg]
Soap2Day Autoplay
Jasmine
Paketshops | PAKET.net
Pollen Count Los Altos
Zoebaby222
Jessica Renee Johnson Update 2023
Why Is Stemtox So Expensive
Sams Gas Price Fairview Heights Il
2021 Lexus IS for sale - Richardson, TX - craigslist
Syracuse Jr High Home Page
Slope Unblocked Minecraft Game
Cvs Learnet Modules
2016 Hyundai Sonata Price, Value, Depreciation & Reviews | Kelley Blue Book
What to do if your rotary tiller won't start – Oleomac
The Banshees Of Inisherin Showtimes Near Regal Thornton Place
Sony E 18-200mm F3.5-6.3 OSS LE Review
Driving Directions To Bed Bath & Beyond
Rams vs. Lions highlights: Detroit defeats Los Angeles 26-20 in overtime thriller
R Cwbt
Mychart Anmed Health Login
2024 INFINITI Q50 Specs, Trims, Dimensions & Prices
Uncovering The Mystery Behind Crazyjamjam Fanfix Leaked
The Listings Project New York
Kirk Franklin Mother Debra Jones Age
Churchill Downs Racing Entries
Evil Dead Rise Showtimes Near Regal Sawgrass & Imax
Courtney Roberson Rob Dyrdek
Armor Crushing Weapon Crossword Clue
Colin Donnell Lpsg
Southern Democrat vs. MAGA Republican: Why NC governor race is a defining contest for 2024
Strange World Showtimes Near Regal Edwards West Covina
Devotion Showtimes Near Mjr Universal Grand Cinema 16
Mandy Rose - WWE News, Rumors, & Updates
Publictributes
Emulating Web Browser in a Dedicated Intermediary Box
Tunica Inmate Roster Release
Po Box 101584 Nashville Tn
White County
Whitney Wisconsin 2022
Costner-Maloy Funeral Home Obituaries
Kobe Express Bayside Lakes Photos
Latest Posts
Article information

Author: Ms. Lucile Johns

Last Updated:

Views: 5896

Rating: 4 / 5 (41 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Ms. Lucile Johns

Birthday: 1999-11-16

Address: Suite 237 56046 Walsh Coves, West Enid, VT 46557

Phone: +59115435987187

Job: Education Supervisor

Hobby: Genealogy, Stone skipping, Skydiving, Nordic skating, Couponing, Coloring, Gardening

Introduction: My name is Ms. Lucile Johns, I am a successful, friendly, friendly, homely, adventurous, handsome, delightful person who loves writing and wants to share my knowledge and understanding with you.