Skip to content

Commit

Permalink
Merge pull request #826 from OfficeDev/v-pritka/teamsfx-migration2
Browse files Browse the repository at this point in the history
Teams fx migration samples
  • Loading branch information
Prithvi-MSFT authored Jul 4, 2023
2 parents 381f967 + 13d7692 commit dba3592
Show file tree
Hide file tree
Showing 110 changed files with 13,971 additions and 4,218 deletions.
23 changes: 21 additions & 2 deletions samples/app-hello-world/nodejs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,24 @@ manifest/
build/

# VS Code config files
.vscode/**
.vs/**
.vs/**

#############

# TeamsFx files
env/.env.*.user
env/.env.local
.localConfigs
appPackage/build
/build

# dependencies
node_modules/

# misc
.env
.deployment
.DS_Store

# build
lib/
5 changes: 5 additions & 0 deletions samples/app-hello-world/nodejs/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"TeamsDevApp.ms-teams-vscode-extension"
]
}
73 changes: 73 additions & 0 deletions samples/app-hello-world/nodejs/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch App (Edge)",
"type": "msedge",
"request": "launch",
"url": "https://teams.microsoft.com/l/app/${{local:TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
"cascadeTerminateToConfigurations": [
"Attach to Local Service"
],
"presentation": {
"group": "all",
"hidden": true
},
"internalConsoleOptions": "neverOpen"
},
{
"name": "Launch App (Chrome)",
"type": "chrome",
"request": "launch",
"url": "https://teams.microsoft.com/l/app/${{local:TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
"cascadeTerminateToConfigurations": [
"Attach to Local Service"
],
"presentation": {
"group": "all",
"hidden": true
},
"internalConsoleOptions": "neverOpen"
},
{
"name": "Attach to Local Service",
"type": "node",
"request": "attach",
"port": 9239,
"restart": true,
"presentation": {
"group": "all",
"hidden": true
},
"internalConsoleOptions": "neverOpen"
}
],
"compounds": [
{
"name": "Debug (Edge)",
"configurations": [
"Launch App (Edge)",
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App Locally",
"presentation": {
"group": "all",
"order": 1
},
"stopAll": true
},
{
"name": "Debug (Chrome)",
"configurations": [
"Launch App (Chrome)",
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App Locally",
"presentation": {
"group": "all",
"order": 2
},
"stopAll": true
}
]
}
11 changes: 11 additions & 0 deletions samples/app-hello-world/nodejs/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"debug.onTaskErrors": "abort",
"json.schemas": [
{
"fileMatch": [
"/aad.*.json"
],
"schema": {}
}
]
}
105 changes: 105 additions & 0 deletions samples/app-hello-world/nodejs/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// This file is automatically generated by Teams Toolkit.
// The teamsfx tasks defined in this file require Teams Toolkit version >= 5.0.0.
// See https://aka.ms/teamsfx-tasks for details on how to customize each task.
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Teams App Locally",
"dependsOn": [
"Validate prerequisites",
"Start local tunnel",
"Provision",
"Deploy",
"Start application"
],
"dependsOrder": "sequence"
},
{
// Check all required prerequisites.
// See https://aka.ms/teamsfx-tasks/check-prerequisites to know the details and how to customize the args.
"label": "Validate prerequisites",
"type": "teamsfx",
"command": "debug-check-prerequisites",
"args": {
"prerequisites": [
"nodejs", // Validate if Node.js is installed.
"m365Account", // Sign-in prompt for Microsoft 365 account, then validate if the account enables the sideloading permission.
"portOccupancy" // Validate available ports to ensure those debug ones are not occupied.
],
"portOccupancy": [
3978, // app service port
9239 // app inspector port for Node.js debugger
]
}
},
{
// Start the local tunnel service to forward public URL to local port and inspect traffic.
// See https://aka.ms/teamsfx-tasks/local-tunnel for the detailed args definitions.
"label": "Start local tunnel",
"type": "teamsfx",
"command": "debug-start-local-tunnel",
"args": {
"type": "dev-tunnel",
"ports": [
{
"portNumber": 3978,
"protocol": "http",
"access": "public",
"writeToEnvironmentFile": {
"endpoint": "BOT_ENDPOINT", // output tunnel endpoint as BOT_ENDPOINT
"domain": "BOT_DOMAIN" // output tunnel domain as BOT_DOMAIN
}
}
],
"env": "local"
},
"isBackground": true,
"problemMatcher": "$teamsfx-local-tunnel-watch"
},
{
// Create the debug resources.
// See https://aka.ms/teamsfx-tasks/provision to know the details and how to customize the args.
"label": "Provision",
"type": "teamsfx",
"command": "provision",
"args": {
"env": "local"
}
},
{
// Build project.
// See See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args.
"label": "Deploy",
"type": "teamsfx",
"command": "deploy",
"args": {
"env": "local"
}
},
{
"label": "Start application",
"type": "shell",
"command": "npm run dev:teamsfx",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": {
"pattern": [
{
"regexp": "^.*$",
"file": 0,
"location": 1,
"message": 2
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "[nodemon] starting",
"endsPattern": "restify listening to|Bot/ME service listening at|[nodemon] app crashed"
}
}
}
]
}
17 changes: 16 additions & 1 deletion samples/app-hello-world/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,22 @@ Please find below demo manifest which is deployed on Microsoft Azure and you can

- [M365 developer account](https://docs.microsoft.com/microsoftteams/platform/concepts/build-and-test/prepare-your-o365-tenant) or access to a Teams account with the appropriate permissions to install an app.

## Setup
- [Teams Toolkit for VS Code](https://marketplace.visualstudio.com/items?itemName=TeamsDevApp.ms-teams-vscode-extension) or [TeamsFx CLI](https://learn.microsoft.com/microsoftteams/platform/toolkit/teamsfx-cli?pivots=version-one)

## Run the app (Using Teams Toolkit for Visual Studio Code)

The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio Code.

1. Ensure you have downloaded and installed [Visual Studio Code](https://code.visualstudio.com/docs/setup/setup-overview)
1. Install the [Teams Toolkit extension](https://marketplace.visualstudio.com/items?itemName=TeamsDevApp.ms-teams-vscode-extension)
1. Select **File > Open Folder** in VS Code and choose this samples directory from the repo
1. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps
1. Select **Debug > Start Debugging** or **F5** to run the app in a Teams web client.
1. In the browser that launches, select the **Add** button to install the app to Teams.

> If you do not have permission to upload custom apps (sideloading), Teams Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.
## Run the app (Manually Uploading to Teams)

> Note these instructions are for running the sample on your local machine, the tunnelling solution is required because
> the Teams service needs to call into the bot.
Expand Down
14 changes: 7 additions & 7 deletions samples/app-hello-world/nodejs/appPackage/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.12/MicrosoftTeams.schema.json",
"manifestVersion": "1.12",
"version": "1.0.0",
"id": "<<Your Microsoft App Id>>",
"id": "${{TEAMS_APP_ID}}",
"packageName": "com.contoso.helloworld",
"developer": {
"name": "Contoso",
Expand All @@ -27,15 +27,15 @@
{
"entityId": "com.contoso.helloworld.hellotab",
"name": "Hello Tab",
"contentUrl": "https://{{domain-name}}/hello",
"contentUrl": "https://${{BOT_DOMAIN}}/hello",
"scopes": [
"personal"
]
}
],
"configurableTabs": [
{
"configurationUrl": "https://{{domain-name}}/configure",
"configurationUrl": "https://${{BOT_DOMAIN}}/configure",
"canUpdateConfiguration": true,
"scopes": [
"team"
Expand All @@ -44,7 +44,7 @@
],
"bots": [
{
"botId": "<<Your Microsoft App Id>>",
"botId": "${{AAD_APP_CLIENT_ID}}",
"needsChannelSelector": false,
"isNotificationOnly": false,
"scopes": [
Expand All @@ -55,7 +55,7 @@
],
"composeExtensions": [
{
"botId": "<<Your Microsoft App Id>>",
"botId": "${{AAD_APP_CLIENT_ID}}",
"commands": [
{
"id": "getRandomText",
Expand All @@ -75,6 +75,6 @@
],
"permissions": [],
"validDomains": [
"{{domain-name}}"
"${{BOT_DOMAIN}}"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"appId": "MICROSOFT_APP_ID",
"appPassword": "MICROSOFT_APP_PASSWORD"
}
}
}
12 changes: 6 additions & 6 deletions samples/app-hello-world/nodejs/config/default.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"bot": {
"appId": "00000000-0000-0000-0000-000000000000",
"appPassword": "yourBotAppPassword"
},
"storage": "memory"
}
"bot": {
"appId": "",
"appPassword": ""
},
"storage": "memory"
}
17 changes: 17 additions & 0 deletions samples/app-hello-world/nodejs/env/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your local development environment.

# Built-in environment variables
TEAMSFX_ENV=local

# Generated during provision, you can also add your own variables. If you're adding a secret value, add SECRET_ prefix to the name so Teams Toolkit can handle them properly
BOT_ENDPOINT=
BOT_DOMAIN=
AAD_APP_CLIENT_ID=
AAD_APP_OBJECT_ID=
AAD_APP_TENANT_ID=
AAD_APP_OAUTH_AUTHORITY=
AAD_APP_OAUTH_AUTHORITY_HOST=
TEAMS_APP_ID=
AAD_APP_ACCESS_AS_USER_PERMISSION_ID=
MICROSOFT_APP_TYPE=
MICROSOFT_APP_TENANT_ID=
44 changes: 44 additions & 0 deletions samples/app-hello-world/nodejs/infra/azure.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@maxLength(20)
@minLength(4)
@description('Used to generate names for all resources in this file')
param resourceBaseName string

@description('Required when create Azure Bot service')
param botAadAppClientId string

param botAppDomain string

@maxLength(42)
param botDisplayName string

param botServiceName string = resourceBaseName
param botServiceSku string = 'F0'
param microsoftAppType string
param microsoftAppTenantId string

// Register your web service as a bot with the Bot Framework
resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
kind: 'azurebot'
location: 'global'
name: botServiceName
properties: {
displayName: botDisplayName
endpoint: 'https://${botAppDomain}/api/messages'
msaAppId: botAadAppClientId
msaAppType: microsoftAppType
msaAppTenantId: microsoftAppType == 'SingleTenant' ? microsoftAppTenantId : ''
}
sku: {
name: botServiceSku
}
}

// Connect the bot service to Microsoft Teams
resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2021-03-01' = {
parent: botService
location: 'global'
name: 'MsTeamsChannel'
properties: {
channelName: 'MsTeamsChannel'
}
}
Loading

0 comments on commit dba3592

Please sign in to comment.