Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Release History

* az webapp webjob continuous group commands were failing for slots

**BotService**

* BREAKING CHANGE:
create:
- Removed support for creating v3 SDK bots
- Remove `az bot publish` example when creating a Web App bot

**CognitiveServices**

* add "cognitiveservices account network-rule" commands.
Expand Down
5 changes: 2 additions & 3 deletions src/azure-cli/azure/cli/command_modules/botservice/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
"""
helps['bot create'] = """
type: command
short-summary: Create a new bot.
long-summary: Create a new bot. Support for creating v3 SDK bots will be deprecated on August 1st, 2019. For more
information please visit this blog post, blog.botframework.com/2019/06/07/v3-bot-broadcast-message/
short-summary: Create a new v4 SDK bot.
long-summary: Create a new v4 SDK bot.
"""
helps['bot show'] = """
type: command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,15 @@ def load_arguments(self, _):

with self.argument_context('bot create') as c:
c.argument('sku_name', options_list=['--sku'], arg_type=get_enum_type(SUPPORTED_SKUS), help='The Sku of the bot.', arg_group='Registration Bot Specific')
c.argument('kind', options_list=['--kind', '-k'], arg_type=get_enum_type(['registration', 'function', 'webapp']), help='The kind of the bot.')
c.argument('kind', options_list=['--kind', '-k'], arg_type=get_enum_type(['registration', 'webapp']), help='The kind of the bot.')
c.argument('display_name', help='The display name of the bot. If not specified, defaults to the name of the bot.', arg_group='Registration Bot Specific')
c.argument('description', options_list=['--description', '-d'], help='The description of the bot.', arg_group='Registration Bot Specific')
c.argument('endpoint', options_list=['-e', '--endpoint'], help='The messaging endpoint of the bot.', arg_group='Registration Bot Specific')
c.argument('msa_app_id', options_list=['--appid'], help='The Microsoft account ID (MSA ID) to be used with the bot.')
c.argument('password', options_list=['-p', '--password'], help='The Microsoft account (MSA) password for the bot. Used to authorize messages being sent to the bot.')
c.argument('storageAccountName', options_list=['-s', '--storage'], help='WARNING: Not used in V4 bot creation. Storage account name to be used with the bot. If not provided, a new account will be created.', arg_group='Web/Function Bot Specific')
c.argument('tags', arg_type=tags_type)
c.argument('language', options_list=['--lang'], arg_type=get_enum_type(SUPPORTED_LANGUAGES), help='The language to be used to create the bot.', arg_group='Web/Function Bot Specific')
c.argument('appInsightsLocation', help='WARNING: Not used in V4 bot creation. The location for the app insights to be used with the bot. Default: South Central US.', options_list=['--insights-location'], arg_group='Web/Function Bot Specific',
arg_type=get_enum_type(SUPPORTED_APP_INSIGHTS_REGIONS))
c.argument('version', options_list=['-v', '--version'], help='The Microsoft Bot Builder SDK version to be used to create the bot', arg_type=get_enum_type(['v3', 'v4']), arg_group='Web/Function Bot Specific')
c.argument('language', options_list=['--lang'], arg_type=get_enum_type(SUPPORTED_LANGUAGES), help='The language to be used to create the bot.', arg_group='Web Bot Specific')
c.argument('version', options_list=['-v', '--version'], help='The Microsoft Bot Builder SDK version to be used to create the bot', arg_type=get_enum_type(['v4']), arg_group='Web Bot Specific')
c.argument('deploy_echo', options_list=['--echo'], arg_type=get_three_state_flag(), help='Deploy an Echo Bot template to the newly created v4 Web App Bot.', arg_group='V4 Bot Templates')

with self.argument_context('bot publish') as c:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@


class BotTemplateDeployer:
# Function App
function_template_name = 'functionapp.template.json'
v3_webapp_template_name = 'webapp.template.json'

v4_webapp_template_name = 'webappv4.template.json'

Expand Down Expand Up @@ -56,11 +53,10 @@ def deploy_arm_template(cli_ctx, resource_group_name, # pylint: disable=too-man

@staticmethod
def create_app(cmd, logger, client, resource_group_name, resource_name, description, kind, appid, password, # pylint:disable=too-many-statements
storageAccountName, location, sku_name, appInsightsLocation, language, version, bot_template_type):
location, sku_name, language, version, bot_template_type):
kind = 'sdk' if kind == 'webapp' else kind
(zip_url, template_name) = BotTemplateDeployer.__retrieve_bot_template_link(version,
language,
kind,
bot_template_type)

logger.debug('Detected SDK version %s, kind %s and programming language %s. Using the following template: %s.',
Expand All @@ -72,7 +68,7 @@ def create_app(cmd, logger, client, resource_group_name, resource_name, descript
# The valid name would be "testname.azurewebsites.net"
while site_name[-1] == '-':
site_name = site_name[:-1]
logger.debug('Web or Function app name to be used is %s.', site_name)
logger.debug('Web app name to be used is %s.', site_name)

# ARM Template parameters
paramsdict = {
Expand All @@ -93,24 +89,6 @@ def create_app(cmd, logger, client, resource_group_name, resource_name, descript
if description:
paramsdict['description'] = description

if version == 'v3':
# Storage prep
paramsdict['createNewStorage'] = False
paramsdict['storageAccountResourceId'] = ''
if not storageAccountName:
storageAccountName = re.sub(r'[^a-z0-9]', '', resource_name[:24].lower())
paramsdict['createNewStorage'] = True

logger.debug('Storage name not provided. If storage is to be created, name to be used is %s.',
storageAccountName)
paramsdict['storageAccountName'] = storageAccountName

# Application insights prep
appInsightsLocation = appInsightsLocation.lower().replace(' ', '')
paramsdict['useAppInsights'] = True
paramsdict['appInsightsLocation'] = appInsightsLocation
logger.debug('Application insights location resolved to %s.', appInsightsLocation)

params = {k: {'value': v} for k, v in paramsdict.items()}

# Get and deploy ARM template
Expand Down Expand Up @@ -162,7 +140,7 @@ def _try_parse_json_object(value):
return parameters

@staticmethod
def __retrieve_bot_template_link(version, language, kind, bot_template_type):
def __retrieve_bot_template_link(version, language, bot_template_type):
if version == 'v4' and not bot_template_type:
return '', BotTemplateDeployer.v4_webapp_template_name

Expand All @@ -172,27 +150,11 @@ def __retrieve_bot_template_link(version, language, kind, bot_template_type):
'https://github.com/Microsoft/botbuilder-tools/issues'
))
cdn_link = response.text.strip('"')
if version == 'v3':
if kind == 'function':
template_name = BotTemplateDeployer.function_template_name
if language == CSHARP:
cdn_link = cdn_link + 'csharp-abs-functions_emptybot.zip'
elif language == JAVASCRIPT:
cdn_link = cdn_link + 'node.js-abs-functions_emptybot_funcpack.zip'
else:
template_name = BotTemplateDeployer.v3_webapp_template_name
if language == CSHARP:
cdn_link = cdn_link + 'csharp-abs-webapp_simpleechobot_precompiled.zip'
elif language == JAVASCRIPT:
cdn_link = cdn_link + 'node.js-abs-webapp_hello-chatconnector.zip'
else:
if kind == 'function':
raise CLIError('Function bot creation is not supported for v4 bot sdk.')

template_name = BotTemplateDeployer.v4_webapp_template_name
if language == CSHARP and bot_template_type == 'echo':
cdn_link = cdn_link + 'csharp-abs-webapp-v4_echobot_precompiled.zip'
elif language == JAVASCRIPT and bot_template_type == 'echo':
cdn_link = cdn_link + 'node.js-abs-webapp-v4_echobot.zip'

template_name = BotTemplateDeployer.v4_webapp_template_name
if language == CSHARP and bot_template_type == 'echo':
cdn_link = cdn_link + 'csharp-abs-webapp-v4_echobot_precompiled.zip'
elif language == JAVASCRIPT and bot_template_type == 'echo':
cdn_link = cdn_link + 'node.js-abs-webapp-v4_echobot.zip'

return cdn_link, template_name

This file was deleted.

55 changes: 10 additions & 45 deletions src/azure-cli/azure/cli/command_modules/botservice/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from azure.cli.command_modules.botservice.constants import CSHARP, JAVASCRIPT, TYPESCRIPT
from azure.cli.command_modules.botservice.kudu_client import KuduClient
from azure.cli.command_modules.botservice.web_app_operations import WebAppOperations
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.mgmt.botservice.models import (
Bot,
BotProperties,
Expand All @@ -29,13 +28,10 @@
logger = get_logger(__name__)


def __bot_template_validator(version, deploy_echo): # pylint: disable=inconsistent-return-statements
if version == 'v3' and deploy_echo:
raise CLIError("'az bot create --version v3' only creates one type of bot. To create a v3 bot, do not use "
"the '--echo' flag when using this command. See 'az bot create --help'.")

def __bot_template_validator(deploy_echo): # pylint: disable=inconsistent-return-statements
if deploy_echo:
return 'echo'
return None


def __prepare_configuration_file(cmd, resource_group_name, kudu_client, folder_path):
Expand Down Expand Up @@ -79,21 +75,13 @@ def __prepare_configuration_file(cmd, resource_group_name, kudu_client, folder_p


def create(cmd, client, resource_group_name, resource_name, kind, msa_app_id, password, language=None, # pylint: disable=too-many-locals, too-many-statements
description=None, display_name=None, endpoint=None, tags=None, storageAccountName=None,
location='Central US', sku_name='F0', appInsightsLocation=None, version='v4', deploy_echo=None):
description=None, display_name=None, endpoint=None, tags=None, location='Central US',
sku_name='F0', version='v4', deploy_echo=None):
# Kind parameter validation
kind = kind.lower()
registration_kind = 'registration'
bot_kind = 'bot'
webapp_kind = 'webapp'
function_kind = 'function'

if version == 'v3':
logger.warning('WARNING: `az bot create` for v3 bots is being discontinued on August 1st, 2019. We encourage '
'developers to move to creating and deploying v4 bots.\n\nFor more information on creating '
'and deploying v4 bots, please visit https://aka.ms/create-and-deploy-v4-bot\n\nFor more '
'information on v3 bot creation deprecation, please visit this blog post: '
'https://blog.botframework.com/2019/06/07/v3-bot-broadcast-message/')

if resource_name.find(".") > -1:
logger.warning('"." found in --name parameter ("%s"). "." is an invalid character for Azure Bot resource names '
Expand Down Expand Up @@ -153,43 +141,20 @@ def create(cmd, client, resource_group_name, resource_name, kind, msa_app_id, pa
parameters=parameters
)

# Web app and function bots require deploying custom ARM templates, we do that in a separate method
# Web app bots require deploying custom ARM templates, we do that in a separate method
logger.info('Detected kind %s, validating parameters for the specified kind.', kind)

if not language:
raise CLIError("You must pass in a language when creating a {0} or {1} bot. See 'az bot create --help'."
.format(webapp_kind, function_kind))
raise CLIError("You must pass in a language when creating a {0} bot. See 'az bot create --help'."
.format(webapp_kind))
language = language.lower()

bot_template_type = __bot_template_validator(version, deploy_echo)

if version == 'v4':
if storageAccountName:
logger.warning('WARNING: `az bot create` for v4 bots no longer creates or uses a Storage Account. If '
'you wish to create a Storage Account via Azure CLI, please use `az storage account` or '
'an ARM template.')
if appInsightsLocation:
logger.warning(
'WARNING: `az bot create` for v4 bots no longer creates or uses Application Insights. If '
'you wish to create Application Insights via Azure CLI, please use an ARM template.')
storageAccountName = None
appInsightsLocation = None
if version == 'v3' and not appInsightsLocation:
appInsightsLocation = 'South Central US'
bot_template_type = __bot_template_validator(deploy_echo)

creation_results = BotTemplateDeployer.create_app(
cmd, logger, client, resource_group_name, resource_name, description, kind, msa_app_id, password,
storageAccountName, location, sku_name, appInsightsLocation, language, version, bot_template_type)

subscription_id = get_subscription_id(cmd.cli_ctx)
publish_cmd = "az bot publish --resource-group %s -n %s --subscription %s -v %s" % (
resource_group_name, resource_name, subscription_id, version)
if language == CSHARP:
proj_file = '%s.csproj' % resource_name
publish_cmd += " --proj-file-path %s" % proj_file
creation_results['publishCommand'] = publish_cmd
logger.info('To publish your local changes to Azure, use the following command from your code directory:\n %s',
publish_cmd)
location, sku_name, language, version, bot_template_type)

return creation_results


Expand Down
Loading