Skip to content

Commit add6c50

Browse files
MehakBindraMehak Bindraheyitsaamir
authored
TS Changes for atk.basic in azure and atk.oauth (#354)
skip-test-verification 1. Oauth in Typescript - verified in local and dev 2. Basic in typescript Dev env (switched from managed identity back to client id and secret - single tenant) For managed identity we would have had to update each template to use azure identity 3. Remove conversion of port to number as ports are strings in dev env --------- Co-authored-by: Mehak Bindra <[email protected]> Co-authored-by: heyitsaamir <[email protected]>
1 parent 4e644eb commit add6c50

File tree

27 files changed

+197
-79
lines changed

27 files changed

+197
-79
lines changed

packages/cli/configs/atk/basic/python/.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"name": "Start",
5050
"type": "debugpy",
5151
"request": "launch",
52+
"python": "${workspaceFolder}/.venv/bin/python",
5253
"program": "${workspaceFolder}/src/main.py",
5354
"console": "integratedTerminal"
5455
},

packages/cli/configs/atk/basic/typescript/env/.env.dev

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ AZURE_RESOURCE_GROUP_NAME=
1010
RESOURCE_SUFFIX=
1111

1212
# Generated during provision, you can also add your own variables.
13-
BOT_ID=
1413
TEAMS_APP_ID=
14+
TEAMS_APP_TENANT_ID=
15+
BOT_ID=
16+
AAD_APP_OBJECT_ID=
17+
AAD_APP_TENANT_ID=
1518
BOT_AZURE_APP_SERVICE_RESOURCE_ID=
1619
BOT_DOMAIN=
17-
BOT_TENANT_ID=

packages/cli/configs/atk/basic/typescript/infra/azure.bicep

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
@description('Used to generate names for all resources in this file')
44
param resourceBaseName string
55

6+
@description('Required when create Azure Bot service')
7+
param botAadAppClientId string
8+
9+
@secure()
10+
@description('Required by Bot Framework package in your bot project')
11+
param botAadAppClientSecret string
12+
613
param webAppSKU string
14+
param tenantId string
715

816
@maxLength(42)
917
param botDisplayName string
1018

1119
param serverfarmsName string = resourceBaseName
1220
param webAppName string = resourceBaseName
13-
param identityName string = resourceBaseName
1421
param location string = resourceGroup().location
1522

16-
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
17-
location: location
18-
name: identityName
19-
}
20-
2123
// Compute resources for your Web App
2224
resource serverfarm 'Microsoft.Web/serverfarms@2021-02-01' = {
2325
kind: 'app'
@@ -41,7 +43,7 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = {
4143
appSettings: [
4244
{
4345
name: 'WEBSITE_RUN_FROM_PACKAGE'
44-
value: '1' // Run Azure App Service from a package file
46+
value: '1' // Run Azure APP Service from a package file
4547
}
4648
{
4749
name: 'WEBSITE_NODE_DEFAULT_VERSION'
@@ -53,43 +55,34 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = {
5355
}
5456
{
5557
name: 'CLIENT_ID'
56-
value: identity.properties.clientId
58+
value: botAadAppClientId
5759
}
5860
{
59-
name: 'TENANT_ID'
60-
value: identity.properties.tenantId
61+
name: 'CLIENT_SECRET'
62+
value: botAadAppClientSecret
6163
}
6264
{
63-
name: 'BOT_TYPE'
64-
value: 'UserAssignedMsi'
65+
name: 'TENANT_ID'
66+
value: tenantId
6567
}
6668
]
6769
ftpsState: 'FtpsOnly'
6870
}
6971
}
70-
identity: {
71-
type: 'UserAssigned'
72-
userAssignedIdentities: {
73-
'${identity.id}': {}
74-
}
75-
}
7672
}
7773

7874
// Register your web service as a bot with the Bot Framework
7975
module azureBotRegistration './botRegistration/azurebot.bicep' = {
8076
name: 'Azure-Bot-registration'
8177
params: {
8278
resourceBaseName: resourceBaseName
83-
identityClientId: identity.properties.clientId
84-
identityResourceId: identity.id
85-
identityTenantId: identity.properties.tenantId
79+
botAadAppClientId: botAadAppClientId
8680
botAppDomain: webApp.properties.defaultHostName
8781
botDisplayName: botDisplayName
82+
tenantId: tenantId
8883
}
8984
}
9085

9186
// The output will be persisted in .env.{envName}. Visit https://aka.ms/teamsfx-actions/arm-deploy for more details.
9287
output BOT_AZURE_APP_SERVICE_RESOURCE_ID string = webApp.id
9388
output BOT_DOMAIN string = webApp.properties.defaultHostName
94-
output BOT_ID string = identity.properties.clientId
95-
output BOT_TENANT_ID string = identity.properties.tenantId

packages/cli/configs/atk/basic/typescript/infra/azure.parameters.json.hbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
"webAppSKU": {
99
"value": "B1"
1010
},
11+
"botAadAppClientId": {
12+
"value": "$\{{BOT_ID}}"
13+
},
14+
"botAadAppClientSecret": {
15+
"value": "$\{{SECRET_BOT_PASSWORD}}"
16+
},
17+
"tenantId": {
18+
"value": "$\{{AAD_APP_TENANT_ID}}"
19+
},
1120
"botDisplayName": {
1221
"value": "{{ toPascalCase name }}Infra"
1322
}

packages/cli/configs/atk/basic/typescript/infra/botRegistration/azurebot.bicep

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ param botDisplayName string
88

99
param botServiceName string = resourceBaseName
1010
param botServiceSku string = 'F0'
11-
param identityResourceId string
12-
param identityClientId string
13-
param identityTenantId string
11+
param botAadAppClientId string
1412
param botAppDomain string
13+
param tenantId string
1514

1615
// Register your web service as a bot with the Bot Framework
1716
resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
@@ -21,10 +20,9 @@ resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
2120
properties: {
2221
displayName: botDisplayName
2322
endpoint: 'https://${botAppDomain}/api/messages'
24-
msaAppId: identityClientId
25-
msaAppMSIResourceId: identityResourceId
26-
msaAppTenantId:identityTenantId
27-
msaAppType:'UserAssignedMSI'
23+
msaAppId: botAadAppClientId
24+
msaAppType: 'SingleTenant'
25+
msaAppTenantId: tenantId
2826
}
2927
sku: {
3028
name: botServiceSku

packages/cli/configs/atk/basic/typescript/teamsapp.yml.hbs

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,52 @@ provision:
2020
writeToEnvironmentFile:
2121
teamsAppId: TEAMS_APP_ID
2222

23-
# Automates the creation an Azure AD app registration which is required for a bot.
24-
# The Bot ID (AAD app client ID) and Bot Password (AAD app client secret) are saved to an environment file.
25-
- uses: botAadApp/create
23+
# Creates a new Microsoft Entra app to authenticate users if
24+
# the environment variable that stores clientId is empty
25+
- uses: aadApp/create
2626
with:
2727
name: {{ toPascalCase name }}$\{{APP_NAME_SUFFIX}}
28+
# Note: when you run aadApp/update, the Microsoft Entra app name will be updated
29+
# based on the definition in manifest. If you don't want to change the
30+
# name, make sure the name in Microsoft Entra manifest is the same with the name
31+
# defined here.
32+
# If the value is false, the driver will not generate client secret for you
33+
generateClientSecret: true
34+
# organization's Microsoft Entra tenant (for example, single tenant).
35+
signInAudience: AzureADMultipleOrgs
36+
# Write the information of created resources into environment file for the
37+
# specified environment variable(s).
2838
writeToEnvironmentFile:
29-
botId: BOT_ID
30-
botPassword: SECRET_BOT_PASSWORD
39+
clientId: BOT_ID
40+
# Environment variable that starts with `SECRET_` will be stored to the
41+
# .env.{envName}.user environment file
42+
clientSecret: SECRET_BOT_PASSWORD
43+
objectId: AAD_APP_OBJECT_ID
44+
tenantId: AAD_APP_TENANT_ID
3145

32-
# Automates the creation of infrastructure defined in ARM templates to host the bot.
33-
# The created resource IDs are saved to an environment file.
34-
- uses: arm/deploy
46+
- uses: arm/deploy # Deploy given ARM templates parallelly.
3547
with:
48+
# AZURE_SUBSCRIPTION_ID is a built-in environment variable,
49+
# if its value is empty, TeamsFx will prompt you to select a subscription.
50+
# Referencing other environment variables with empty values
51+
# will skip the subscription selection prompt.
3652
subscriptionId: $\{{AZURE_SUBSCRIPTION_ID}}
53+
# AZURE_RESOURCE_GROUP_NAME is a built-in environment variable,
54+
# if its value is empty, TeamsFx will prompt you to select or create one
55+
# resource group.
56+
# Referencing other environment variables with empty values
57+
# will skip the resource group selection prompt.
3758
resourceGroupName: $\{{AZURE_RESOURCE_GROUP_NAME}}
3859
templates:
39-
- path: ./infra/azure.bicep
60+
- path: ./infra/azure.bicep # Relative path to this file
61+
# Relative path to this yaml file.
62+
# Placeholders will be replaced with corresponding environment
63+
# variable before ARM deployment.
4064
parameters: ./infra/azure.parameters.json
41-
deploymentName: Create-resources-for-tab
65+
# Required when deploying ARM template
66+
deploymentName: Create-resources-for-bot
67+
# M365 Agents Toolkit will download this bicep CLI version from github for you,
68+
# will use bicep CLI in PATH if you remove this config.
4269
bicepCliVersion: v0.9.1
4370

4471
# Optional: Automates schema and error checking of the Teams app manifest and outputs the results in the console.

packages/cli/configs/atk/oauth/python/.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"name": "Start",
5050
"type": "debugpy",
5151
"request": "launch",
52+
"python": "${workspaceFolder}/.venv/bin/python",
5253
"program": "${workspaceFolder}/src/main.py",
5354
"console": "integratedTerminal"
5455
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Built-in environment variables
2+
TEAMSFX_ENV=dev
3+
APP_NAME_SUFFIX=dev
4+
5+
# Updating AZURE_SUBSCRIPTION_ID or AZURE_RESOURCE_GROUP_NAME after provision may also require an update to RESOURCE_SUFFIX, because some services require a globally unique name across subscriptions/resource groups.
6+
AZURE_SUBSCRIPTION_ID=
7+
AZURE_RESOURCE_GROUP_NAME=
8+
RESOURCE_SUFFIX=
9+
10+
TEAMS_APP_ID=
11+
TEAMS_APP_TENANT_ID=
12+
BOT_ID=
13+
AAD_APP_OBJECT_ID=
14+
AAD_APP_TENANT_ID=
15+
BOT_AZURE_APP_SERVICE_RESOURCE_ID=
16+
BOT_DOMAIN=

packages/cli/configs/atk/oauth/typescript/infra/azure.bicep

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
@description('Used to generate names for all resources in this file')
44
param resourceBaseName string
55

6+
@description('Required when create Azure Bot service')
7+
param botAadAppClientId string
8+
9+
@secure()
10+
@description('Required by Bot Framework package in your bot project')
11+
param botAadAppClientSecret string
12+
613
param webAppSKU string
714

815
@maxLength(42)
916
param botDisplayName string
1017

1118
param serverfarmsName string = resourceBaseName
1219
param webAppName string = resourceBaseName
13-
param identityName string = resourceBaseName
1420
param location string = resourceGroup().location
1521
param oauthConnectionName string
16-
17-
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
18-
location: location
19-
name: identityName
20-
}
22+
param tenantId string
2123

2224
// Compute resources for your Web App
2325
resource serverfarm 'Microsoft.Web/serverfarms@2021-02-01' = {
@@ -53,31 +55,21 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = {
5355
value: '1'
5456
}
5557
{
56-
name: 'BOT_ID'
57-
value: identity.properties.clientId
58+
name: 'CLIENT_ID'
59+
value: botAadAppClientId
5860
}
5961
{
60-
name: 'BOT_TENANT_ID'
61-
value: identity.properties.tenantId
62-
}
63-
{
64-
name: 'BOT_TYPE'
65-
value: 'UserAssignedMsi'
62+
name: 'CLIENT_SECRET'
63+
value: botAadAppClientSecret
6664
}
6765
{
68-
name: 'OAUTH_CONNECTION_NAME'
69-
value: oauthConnectionName
66+
name: 'TENANT_ID'
67+
value: tenantId
7068
}
7169
]
7270
ftpsState: 'FtpsOnly'
7371
}
7472
}
75-
identity: {
76-
type: 'UserAssigned'
77-
userAssignedIdentities: {
78-
'${identity.id}': {}
79-
}
80-
}
8173
}
8274

8375
// Register your web service as a bot with the Bot Framework
@@ -86,9 +78,11 @@ module azureBotRegistration './botRegistration/azurebot.bicep' = {
8678
params: {
8779
resourceBaseName: resourceBaseName
8880
botAadAppClientId: botAadAppClientId
81+
botAddAppClientSecret: botAadAppClientSecret
8982
botAppDomain: webApp.properties.defaultHostName
9083
botDisplayName: botDisplayName
9184
oauthConnectionName: oauthConnectionName
85+
tenantId: tenantId
9286
}
9387
}
9488

packages/cli/configs/atk/oauth/typescript/infra/azure.local.bicep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ param botDisplayName string
1515

1616
param botAppDomain string
1717
param oauthConnectionName string
18+
param tenantId string
1819

1920
module azureBotRegistration './botRegistration/azurebot.bicep' = {
2021
name: 'Azure-Bot-registration'
@@ -25,5 +26,6 @@ module azureBotRegistration './botRegistration/azurebot.bicep' = {
2526
botDisplayName: botDisplayName
2627
botAddAppClientSecret: botAadAppClientSecret
2728
oauthConnectionName: oauthConnectionName
29+
tenantId: tenantId
2830
}
2931
}

0 commit comments

Comments
 (0)