Kopīgot, izmantojot


Use Azure CLI to create an App Service resource

APPLIES TO: SDK v4

This article describes how to create an App Service resource with the Azure CLI and an Azure Resource Manager template (ARM template) as part of the process to provision and publish a bot. The app service is sometimes referred to as a web app.

Important

Python bots can't be deployed to a resource group that contains Windows services or bots. Multiple Python bots can be deployed to the same resource group; however, you need to create other services (such as Azure AI services) in another resource group.

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

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.

    Language CLI version
    C# and JavaScript 2.39.0 or later
    Python 2.55.0 or later
    Java 2.29.2
  • This process uses an Azure Resource Manager template (ARM template) to create an App Service resource 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.

Tip

This is part of the larger process to provision and publish a bot. See how to Provision and publish a bot for a complete list of prerequisites.

Edit parameters file

Edit the parameters file for the ARM template to contain the values you want to use.

Important

You must use the same appType value for your App Service and Azure Bot resources.

If your project doesn't yet contain the most recent ARM template and parameters files, you can copy them from the Bot Framework SDK repo for your language: C#, JavaScript, Python, or Java.

This table describes the deployment parameters in the parameters file, for use with the parameters command option. By default, the name of the parameters file is parameters-for-template-BotApp-with-rg.json.

Parameter Type Description
appServiceName String Required. The globally unique name of the app service.
existingAppServicePlanName String Optional. The name of an existing app service plan with which to create the app service for the bot.
existingAppServicePlanLocation String Optional. The location of the existing app service plan.
newAppServicePlanName String Optional. The name of the new app service plan.
newAppServicePlanLocation String Optional. The location of the new app service plan.
newAppServicePlanSku Object Optional. The SKU for the new app service plan. Default is the S1 (Standard) service plan.
appType String Required. How the identities of your bot resources are managed. Allowed values: "MultiTenant", "SingleTenant", and "UserAssignedMSI". Default is "MultiTenant".
appId String Required. The client ID or app ID from the identity resource you created earlier. This is used as the Microsoft app ID of the app service.
appSecret String Optional. For single-tenant and multi-tenant app types, the password for the identity resource.
UMSIName String Optional. For user-assigned managed identity app types, the name of the identity resource.
UMSIResourceGroupName String Optional. For user-assigned managed identity app types, the resource group for the identity resource.
tenantId String Optional. For user-assigned managed identity and single-tenant app types, The Microsoft Entra ID tenant ID for the identity resource.

Not all parameters apply to all app types.

  • Provide values for UMSIName, UMSIResourceGroupName, and tenantId.
  • Leave appSecret blank.

Some parameters are specific to using an existing or new app service plan.

  • Provide values for existingAppServicePlanName and existingAppServicePlanLocation.
  • Leave newAppServicePlanName, newAppServicePlanLocation, and newAppServicePlanSku blank.

Create the app service

Create the app service for your bot.

az deployment group create --resource-group <resource-group> --template-file <template-file-path> --parameters "@<parameters-file-path>"
Option Description
resource-group Name of the Azure resource group in which to create the app service.
template-file The path to the ARM template for the app service. The path can be relative or absolute.
parameters The path to the parameters file to use with the ARM template. The path can be relative or absolute.

For projects created with the latest generators, the ARM template and parameter files are located in the DeploymentTemplates\DeployUseExistResourceGroup folder within the project. The default file names are template-BotApp-with-rg.json and parameters-for-template-BotApp-with-rg.json.

Tip

  • The base URL for your app service is based on the app service name: https:<app-service-name>.azurewebsites.net.
  • The messaging endpoint for your bot will be the base URL plus /api/messages, such as https:<app-service-name>.azurewebsites.net/api/messages.

Additional information

For more information about ARM templates, see What are ARM templates? and How to use Azure Resource Manager (ARM) deployment templates with Azure CLI.

Next steps

If you created the App Service as part of a bot deployment, see Create resources with ARM templates to continue the process.