-
Notifications
You must be signed in to change notification settings - Fork 3.3k
BotService: Bugfixing, code refactoring, reorganization and UX revamping #7924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1602107
f0faca3
b15d366
4674507
e8d4ca1
93c5acd
a11bbdb
7a6f4ec
60b72ef
9d2903a
be9b622
b9e750a
e259d73
abf7dfa
7dc31d9
7d52e28
98c5c3d
0f50f25
fb609c2
ce45466
372c65f
b855ee0
eb93d61
c7d364d
4b0ab4b
eb5976a
9fb84c3
3e6a85a
5975391
0a5566f
c08ebe1
1bc9e12
e87984f
c227f30
bb9b0be
5fbbd42
86e3e7f
7cc7393
1a04b40
e8ed0aa
075ca94
652cba2
deb9ca2
62b460c
a552fbc
cdb70a3
dca6763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| include *.rst | ||
| include azure\cli\command_modules\botservice\functionapp.template.json | ||
| include azure\cli\command_modules\botservice\webapp.template.json | ||
| include azure/cli/command_modules/botservice/functionapp.template.json | ||
| include azure/cli/command_modules/botservice/webapp.template.json | ||
| include azure/cli/command_modules/botservice/webappv4.template.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ | |
|
|
||
| name_arg_type = CLIArgumentType(metavar='NAME', configured_default='botname', id_part='Name') | ||
|
|
||
| supported_languages = ['Csharp', 'Node'] | ||
|
||
|
|
||
|
|
||
| # pylint: disable=line-too-long,too-many-statements | ||
| def load_arguments(self, _): | ||
|
|
@@ -30,13 +32,16 @@ def load_arguments(self, _): | |
| c.argument('password', options_list=['-p', '--password'], help='The Microsoft account (MSA) password for the bot.') | ||
| c.argument('storageAccountName', options_list=['-s', '--storage'], help='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', help='The language to be used to create the bot.', options_list=['--lang'], arg_type=get_enum_type(['Csharp', 'Node']), arg_group='Web/Function bot Specific') | ||
| c.argument('language', help='The language to be used to create the bot.', options_list=['--lang'], arg_type=get_enum_type(supported_languages), arg_group='Web/Function bot Specific') | ||
carlosscastro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| c.argument('appInsightsLocation', help='The location for the app insights to be used with the bot.', options_list=['--insights-location'], arg_group='Web/Function bot Specific', | ||
| arg_type=get_enum_type(['South Central US', 'East US', 'West US 2', 'North Europe', 'West Europe', 'Southeast Asia'])) | ||
| 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') | ||
|
|
||
| with self.argument_context('bot publish') as c: | ||
| c.argument('code_dir', options_list=['--code-dir'], help='The directory to upload bot code from.') | ||
| c.argument('proj_name', help='Name of the start up project file name.') | ||
| c.argument('version', options_list=['-v', '--version'], | ||
| help='The Microsoft Bot Builder SDK version by the bot.') | ||
|
|
||
| with self.argument_context('bot download') as c: | ||
| c.argument('file_save_path', options_list=['--save-path'], help='The directory to download bot code to.') | ||
|
|
@@ -48,6 +53,9 @@ def load_arguments(self, _): | |
| c.argument('proj_name', help='Name of the start up project file name. Required only for C#.') | ||
| c.argument('sln_name', help='Name of the start up solution file name. Required only for C#.') | ||
| c.argument('code_dir', options_list=['--code-dir'], help='The directory to download deployment scripts to.') | ||
| c.argument('version', options_list=['-v', '--version'], help='The Microsoft Bot Builder SDK version to be used ' | ||
| 'in the bot template that will be created.', | ||
| arg_type=get_enum_type(['v3', 'v4']), arg_group='Web/Function bot Specific') | ||
carlosscastro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| with self.argument_context('bot facebook create') as c: | ||
| c.argument('is_disabled', options_list=['--add-disabled'], arg_type=get_three_state_flag(), help='Add the channel in a disabled state') | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import adal | ||
| from knack.log import get_logger | ||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| class AdalAuthenticator: # pylint:disable=too-few-public-methods | ||
|
|
||
| bot_first_party_app_id = 'f3723d34-6ff5-4ceb-a148-d99dcd2511fc' | ||
| aad_client_id = '1950a258-227b-4e31-a9cf-717495945fc2' | ||
| login_url = 'https://login.windows.net/common' | ||
|
|
||
| @staticmethod | ||
| def acquire_token(): | ||
|
|
||
| # Create ADAL Authentication Context to acquire tokens | ||
| context = adal.AuthenticationContext( | ||
| authority=AdalAuthenticator.login_url, | ||
| validate_authority=True, | ||
| api_version=None | ||
| ) | ||
|
|
||
| # Acquire a device code | ||
| code = context.acquire_user_code( | ||
| resource=AdalAuthenticator.bot_first_party_app_id, | ||
| client_id=AdalAuthenticator.aad_client_id, | ||
| ) | ||
|
|
||
| # Request the user to perform device login | ||
| logger.warning(code['message']) | ||
|
|
||
| # Use the device code to retrieve a token | ||
| token = context.acquire_token_with_device_code( | ||
| resource=AdalAuthenticator.bot_first_party_app_id, | ||
| user_code_info=code, | ||
| client_id=AdalAuthenticator.aad_client_id | ||
| ) | ||
|
|
||
| # Return the entire token object including the access token plus expiration date and other info | ||
| return token |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from knack.log import get_logger | ||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| class AzureRegionMapper: # pylint:disable=too-few-public-methods | ||
|
|
||
| @staticmethod | ||
| def get_app_insights_location(key): | ||
| region_map = { | ||
| 'australiaeast': 'southeastasia', | ||
| 'australiacentral': 'southeastasia', | ||
| 'australiacentral2': 'southeastasia', | ||
| 'australiasoutheast': 'southeastasia', | ||
| 'eastasia': 'southeastasia', | ||
| 'southeastasia': 'westus', | ||
| 'eastus': 'eastus', | ||
| 'eastus2': 'eastus', | ||
| 'southcentralus': 'southcentralus', | ||
| 'westcentralus': 'westus2', | ||
| 'westus': 'westus2', | ||
| 'westus2': 'westus2', | ||
| 'brazilsouth': 'southcentralus', | ||
| 'centralus': 'southcentralus', | ||
| 'northcentralus': 'southcentralus', | ||
| 'japanwest': 'southeastasia', | ||
| 'japaneast': 'southeastasia', | ||
| 'southindia': 'southeastasia', | ||
| 'centralindia': 'southeastasia', | ||
| 'westindia': 'southeastasia', | ||
| 'canadacentral': 'southcentralus', | ||
| 'canadaeast': 'eastus', | ||
| 'koreacentral': 'southeastasia', | ||
| 'koreasouth': 'southeastasia', | ||
| 'northeurope': 'northeurope', | ||
| 'westeurope': 'westeurope', | ||
| 'uksouth': 'westeurope', | ||
| 'ukwest': 'westeurope', | ||
| 'francecentral': 'westeurope', | ||
| 'francesouth': 'westeurope' | ||
| } | ||
| region = region_map.get(key) | ||
|
|
||
| if not region: | ||
| logger.warning('Warning: provided region ("%s") for Application Insights does not exist. Defaulting to ' | ||
| '"southcentralus"', key) | ||
| region = 'southcentralus' | ||
|
|
||
| return region |
Uh oh!
There was an error while loading. Please reload this page.