-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BotService: Bugfixing, code refactoring, reorganization and UX revamp…
…ing (#7924)
- Loading branch information
1 parent
adcb813
commit 0729c9f
Showing
31 changed files
with
223,577 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 0 additions & 127 deletions
127
src/command_modules/azure-cli-botservice/azure/cli/command_modules/botservice/_webutils.py
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
...d_modules/azure-cli-botservice/azure/cli/command_modules/botservice/adal_authenticator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
54 changes: 54 additions & 0 deletions
54
..._modules/azure-cli-botservice/azure/cli/command_modules/botservice/azure_region_mapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.