diff --git a/templates/vsc/js/basic-custom-engine-agent/.vscode/tasks.json b/templates/vsc/js/basic-custom-engine-agent/.vscode/tasks.json index 97ca3321576..3137f1a9c73 100644 --- a/templates/vsc/js/basic-custom-engine-agent/.vscode/tasks.json +++ b/templates/vsc/js/basic-custom-engine-agent/.vscode/tasks.json @@ -12,6 +12,7 @@ "Provision (Sandbox)", "Deploy (Sandbox)", "Start application", + "Sideload App to channel" ], "dependsOrder": "sequence" }, @@ -299,6 +300,15 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } } ] } \ No newline at end of file diff --git a/templates/vsc/js/basic-custom-engine-agent/env/.env.sandbox b/templates/vsc/js/basic-custom-engine-agent/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/js/basic-custom-engine-agent/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/js/basic-custom-engine-agent/m365agents.sandbox.yml.tpl b/templates/vsc/js/basic-custom-engine-agent/m365agents.sandbox.yml.tpl index f915939fd6f..3cfa8a04fed 100644 --- a/templates/vsc/js/basic-custom-engine-agent/m365agents.sandbox.yml.tpl +++ b/templates/vsc/js/basic-custom-engine-agent/m365agents.sandbox.yml.tpl @@ -90,15 +90,6 @@ provision: appId: M365_APP_ID deploy: -{{#SandBoxedTeam}} - # Sideload app in sandboxed team. - - uses: devChannel/installApp - with: - teamId: ${{TEAM_ID}} - channelId: ${{CHANNEL_ID}} - appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip -{{/SandBoxedTeam}} - # Run npm command - uses: cli/runNpmCommand name: install dependencies @@ -110,9 +101,8 @@ deploy: with: target: ./.localConfigs envs: - BOT_ID: ${{BOT_ID}} - BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} - BOT_TYPE: 'MultiTenant' + clientId: ${{BOT_ID}} + clientSecret: ${{SECRET_BOT_PASSWORD}} {{#useOpenAI}} OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} {{/useOpenAI}} diff --git a/templates/vsc/js/custom-copilot-assistant-assistants-api/.vscode/launch.json.tpl b/templates/vsc/js/custom-copilot-assistant-assistants-api/.vscode/launch.json.tpl index d0675e713c6..d1d9c6253c5 100644 --- a/templates/vsc/js/custom-copilot-assistant-assistants-api/.vscode/launch.json.tpl +++ b/templates/vsc/js/custom-copilot-assistant-assistants-api/.vscode/launch.json.tpl @@ -89,10 +89,10 @@ {{/enableTestToolByDefault}} "order": 6 }, - "internalConsoleOptions": "neverOpen", - {{#CEAEnabled}} - }, - { + "internalConsoleOptions": "neverOpen" + } +{{#CEAEnabled}} + ,{ "name": "Launch Remote in Copilot (Edge)", "type": "msedge", "request": "launch", @@ -157,8 +157,25 @@ "--remote-debugging-port=9223", "--no-first-run" ] - {{/CEAEnabled}} } +{{#SandBoxedTeam}} + ,{ + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + } +{{/SandBoxedTeam}} +{{/CEAEnabled}} ], "compounds": [ { @@ -179,6 +196,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ @@ -230,9 +262,9 @@ "order": 1 }, "stopAll": true - {{#CEAEnabled}} - }, - { + } +{{#CEAEnabled}} + ,{ "name": "Debug in Copilot (Edge)", "configurations": [ "Launch in Copilot (Edge)", @@ -244,8 +276,8 @@ "order": 1 }, "stopAll": true - }, - { + }, + { "name": "Debug in Copilot (Chrome)", "configurations": [ "Launch in Copilot (Chrome)", @@ -257,7 +289,7 @@ "order": 2 }, "stopAll": true - {{/CEAEnabled}} } +{{/CEAEnabled}} ] } diff --git a/templates/vsc/js/custom-copilot-assistant-assistants-api/.vscode/tasks.json b/templates/vsc/js/custom-copilot-assistant-assistants-api/.vscode/tasks.json index 0ced6235bda..fa9007d7bcb 100644 --- a/templates/vsc/js/custom-copilot-assistant-assistants-api/.vscode/tasks.json +++ b/templates/vsc/js/custom-copilot-assistant-assistants-api/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -103,6 +115,77 @@ "reveal": "silent" } }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "sandbox", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "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 (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + // Build the project. + // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } + }, { "label": "Start Agent Locally", "dependsOn": [ diff --git a/templates/vsc/js/custom-copilot-assistant-assistants-api/env/.env.sandbox b/templates/vsc/js/custom-copilot-assistant-assistants-api/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/js/custom-copilot-assistant-assistants-api/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/js/custom-copilot-assistant-assistants-api/env/.env.sandbox.user.tpl b/templates/vsc/js/custom-copilot-assistant-assistants-api/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..85717badf18 --- /dev/null +++ b/templates/vsc/js/custom-copilot-assistant-assistants-api/env/.env.sandbox.user.tpl @@ -0,0 +1,29 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +OPENAI_ASSISTANT_ID= # See README.md for how to fill in this value. +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +AZURE_OPENAI_ASSISTANT_ID= # See README.md for how to fill in this value. +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-assistant-assistants-api/m365agents.sandbox.yml.tpl b/templates/vsc/js/custom-copilot-assistant-assistants-api/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..45a4e870c65 --- /dev/null +++ b/templates/vsc/js/custom-copilot-assistant-assistants-api/m365agents.sandbox.yml.tpl @@ -0,0 +1,119 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + OPENAI_ASSISTANT_ID: ${{OPENAI_ASSISTANT_ID}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_ASSISTANT_ID: ${{AZURE_OPENAI_ASSISTANT_ID}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-assistant-new/.vscode/launch.json.tpl b/templates/vsc/js/custom-copilot-assistant-new/.vscode/launch.json.tpl index 0e1196d9280..6a6cb1ef586 100644 --- a/templates/vsc/js/custom-copilot-assistant-new/.vscode/launch.json.tpl +++ b/templates/vsc/js/custom-copilot-assistant-new/.vscode/launch.json.tpl @@ -89,10 +89,10 @@ {{/enableTestToolByDefault}} "order": 6 }, - "internalConsoleOptions": "neverOpen", - {{#CEAEnabled}} - }, - { + "internalConsoleOptions": "neverOpen" + } +{{#CEAEnabled}} + ,{ "name": "Launch Remote in Copilot (Edge)", "type": "msedge", "request": "launch", @@ -157,8 +157,25 @@ "--remote-debugging-port=9223", "--no-first-run" ] - {{/CEAEnabled}} } +{{#SandBoxedTeam}} + ,{ + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + } +{{/SandBoxedTeam}} +{{/CEAEnabled}} ], "compounds": [ { @@ -179,6 +196,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ @@ -230,9 +262,9 @@ "order": 1 }, "stopAll": true - {{#CEAEnabled}} - }, - { + } +{{#CEAEnabled}} + ,{ "name": "Debug in Copilot (Edge)", "configurations": [ "Launch in Copilot (Edge)", @@ -244,8 +276,8 @@ "order": 1 }, "stopAll": true - }, - { + }, + { "name": "Debug in Copilot (Chrome)", "configurations": [ "Launch in Copilot (Chrome)", @@ -257,7 +289,7 @@ "order": 2 }, "stopAll": true - {{/CEAEnabled}} } +{{/CEAEnabled}} ] } diff --git a/templates/vsc/js/custom-copilot-assistant-new/.vscode/tasks.json b/templates/vsc/js/custom-copilot-assistant-new/.vscode/tasks.json index 0ced6235bda..fa9007d7bcb 100644 --- a/templates/vsc/js/custom-copilot-assistant-new/.vscode/tasks.json +++ b/templates/vsc/js/custom-copilot-assistant-new/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -103,6 +115,77 @@ "reveal": "silent" } }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "sandbox", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "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 (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + // Build the project. + // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } + }, { "label": "Start Agent Locally", "dependsOn": [ diff --git a/templates/vsc/js/custom-copilot-assistant-new/env/.env.sandbox b/templates/vsc/js/custom-copilot-assistant-new/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/js/custom-copilot-assistant-new/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/js/custom-copilot-assistant-new/env/.env.sandbox.user.tpl b/templates/vsc/js/custom-copilot-assistant-new/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..7dbda95bc90 --- /dev/null +++ b/templates/vsc/js/custom-copilot-assistant-new/env/.env.sandbox.user.tpl @@ -0,0 +1,33 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-assistant-new/m365agents.sandbox.yml.tpl b/templates/vsc/js/custom-copilot-assistant-new/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..0c6b48d1562 --- /dev/null +++ b/templates/vsc/js/custom-copilot-assistant-new/m365agents.sandbox.yml.tpl @@ -0,0 +1,118 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-basic/.vscode/launch.json.tpl b/templates/vsc/js/custom-copilot-basic/.vscode/launch.json.tpl index 89bcf36c8b1..1998023afe6 100644 --- a/templates/vsc/js/custom-copilot-basic/.vscode/launch.json.tpl +++ b/templates/vsc/js/custom-copilot-basic/.vscode/launch.json.tpl @@ -89,10 +89,10 @@ {{/enableTestToolByDefault}} "order": 6 }, - "internalConsoleOptions": "neverOpen", - {{#CEAEnabled}} - }, - { + "internalConsoleOptions": "neverOpen" + } +{{#CEAEnabled}} + ,{ "name": "Launch Remote in Copilot (Edge)", "type": "msedge", "request": "launch", @@ -107,8 +107,8 @@ "--remote-debugging-port=9222", "--no-first-run" ] - }, - { + }, + { "name": "Launch Remote in Copilot (Chrome)", "type": "chrome", "request": "launch", @@ -155,8 +155,25 @@ "--remote-debugging-port=9223", "--no-first-run" ] - {{/CEAEnabled}} } +{{#SandBoxedTeam}} + ,{ + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + } +{{/SandBoxedTeam}} +{{/CEAEnabled}} ], "compounds": [ { @@ -177,6 +194,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ @@ -228,9 +260,9 @@ "order": 1 }, "stopAll": true - {{#CEAEnabled}} - }, - { + } +{{#CEAEnabled}} + ,{ "name": "Debug in Copilot (Edge)", "configurations": [ "Launch in Copilot (Edge)", @@ -242,8 +274,8 @@ "order": 1 }, "stopAll": true - }, - { + }, + { "name": "Debug in Copilot (Chrome)", "configurations": [ "Launch in Copilot (Chrome)", @@ -255,7 +287,7 @@ "order": 2 }, "stopAll": true - {{/CEAEnabled}} } +{{/CEAEnabled}} ] } diff --git a/templates/vsc/js/custom-copilot-basic/.vscode/tasks.json b/templates/vsc/js/custom-copilot-basic/.vscode/tasks.json index 0ced6235bda..fa9007d7bcb 100644 --- a/templates/vsc/js/custom-copilot-basic/.vscode/tasks.json +++ b/templates/vsc/js/custom-copilot-basic/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -103,6 +115,77 @@ "reveal": "silent" } }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "sandbox", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "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 (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + // Build the project. + // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } + }, { "label": "Start Agent Locally", "dependsOn": [ diff --git a/templates/vsc/js/custom-copilot-basic/env/.env.sandbox b/templates/vsc/js/custom-copilot-basic/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/js/custom-copilot-basic/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/js/custom-copilot-basic/env/.env.sandbox.user.tpl b/templates/vsc/js/custom-copilot-basic/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..7dbda95bc90 --- /dev/null +++ b/templates/vsc/js/custom-copilot-basic/env/.env.sandbox.user.tpl @@ -0,0 +1,33 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-basic/m365agents.sandbox.yml.tpl b/templates/vsc/js/custom-copilot-basic/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..0c6b48d1562 --- /dev/null +++ b/templates/vsc/js/custom-copilot-basic/m365agents.sandbox.yml.tpl @@ -0,0 +1,118 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-azure-ai-search/.vscode/launch.json.tpl b/templates/vsc/js/custom-copilot-rag-azure-ai-search/.vscode/launch.json.tpl index 5bb858a7495..89435c9ef12 100644 --- a/templates/vsc/js/custom-copilot-rag-azure-ai-search/.vscode/launch.json.tpl +++ b/templates/vsc/js/custom-copilot-rag-azure-ai-search/.vscode/launch.json.tpl @@ -89,10 +89,10 @@ {{/enableTestToolByDefault}} "order": 6 }, - "internalConsoleOptions": "neverOpen", - {{#CEAEnabled}} - }, - { + "internalConsoleOptions": "neverOpen" + } +{{#CEAEnabled}} + ,{ "name": "Launch Remote in Copilot (Edge)", "type": "msedge", "request": "launch", @@ -156,8 +156,25 @@ "--remote-debugging-port=9223", "--no-first-run" ] - {{/CEAEnabled}} } +{{#SandBoxedTeam}} + ,{ + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + } +{{/SandBoxedTeam}} +{{/CEAEnabled}} ], "compounds": [ { @@ -178,6 +195,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ @@ -229,9 +261,9 @@ "order": 1 }, "stopAll": true - {{#CEAEnabled}} - }, - { + } +{{#CEAEnabled}} + ,{ "name": "Debug in Copilot (Edge)", "configurations": [ "Launch in Copilot (Edge)", @@ -243,8 +275,8 @@ "order": 1 }, "stopAll": true - }, - { + }, + { "name": "Debug in Copilot (Chrome)", "configurations": [ "Launch in Copilot (Chrome)", @@ -256,7 +288,7 @@ "order": 2 }, "stopAll": true - {{/CEAEnabled}} } +{{/CEAEnabled}} ] } diff --git a/templates/vsc/js/custom-copilot-rag-azure-ai-search/.vscode/tasks.json b/templates/vsc/js/custom-copilot-rag-azure-ai-search/.vscode/tasks.json index 0ced6235bda..fa9007d7bcb 100644 --- a/templates/vsc/js/custom-copilot-rag-azure-ai-search/.vscode/tasks.json +++ b/templates/vsc/js/custom-copilot-rag-azure-ai-search/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -103,6 +115,77 @@ "reveal": "silent" } }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "sandbox", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "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 (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + // Build the project. + // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } + }, { "label": "Start Agent Locally", "dependsOn": [ diff --git a/templates/vsc/js/custom-copilot-rag-azure-ai-search/env/.env.sandbox b/templates/vsc/js/custom-copilot-rag-azure-ai-search/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-azure-ai-search/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/js/custom-copilot-rag-azure-ai-search/env/.env.sandbox.user.tpl b/templates/vsc/js/custom-copilot-rag-azure-ai-search/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..67095b67c7c --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-azure-ai-search/env/.env.sandbox.user.tpl @@ -0,0 +1,51 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{#azureOpenAIEmbeddingDeploymentName}} +AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME='{{{azureOpenAIEmbeddingDeploymentName}}}' +{{/azureOpenAIEmbeddingDeploymentName}} +{{^azureOpenAIEmbeddingDeploymentName}} +AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME= +{{/azureOpenAIEmbeddingDeploymentName}} +{{/useAzureOpenAI}} +{{#secretAzureSearchKey}} +SECRET_AZURE_SEARCH_KEY='{{{secretAzureSearchKey}}}' +{{/secretAzureSearchKey}} +{{^secretAzureSearchKey}} +SECRET_AZURE_SEARCH_KEY= +{{/secretAzureSearchKey}} +{{#azureSearchEndpoint}} +AZURE_SEARCH_ENDPOINT='{{{azureSearchEndpoint}}}' +{{/azureSearchEndpoint}} +{{^azureSearchEndpoint}} +AZURE_SEARCH_ENDPOINT= +{{/azureSearchEndpoint}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-azure-ai-search/m365agents.sandbox.yml.tpl b/templates/vsc/js/custom-copilot-rag-azure-ai-search/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..2b833e649e5 --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-azure-ai-search/m365agents.sandbox.yml.tpl @@ -0,0 +1,121 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME: ${{AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} + AZURE_SEARCH_KEY: ${{SECRET_AZURE_SEARCH_KEY}} + AZURE_SEARCH_ENDPOINT: ${{AZURE_SEARCH_ENDPOINT}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-custom-api/.vscode/launch.json.tpl b/templates/vsc/js/custom-copilot-rag-custom-api/.vscode/launch.json.tpl index 89bcf36c8b1..f5136bf8d39 100644 --- a/templates/vsc/js/custom-copilot-rag-custom-api/.vscode/launch.json.tpl +++ b/templates/vsc/js/custom-copilot-rag-custom-api/.vscode/launch.json.tpl @@ -89,10 +89,10 @@ {{/enableTestToolByDefault}} "order": 6 }, - "internalConsoleOptions": "neverOpen", - {{#CEAEnabled}} - }, - { + "internalConsoleOptions": "neverOpen" + } +{{#CEAEnabled}} + ,{ "name": "Launch Remote in Copilot (Edge)", "type": "msedge", "request": "launch", @@ -155,8 +155,25 @@ "--remote-debugging-port=9223", "--no-first-run" ] - {{/CEAEnabled}} } +{{#SandBoxedTeam}} + ,{ + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + } +{{/SandBoxedTeam}} +{{/CEAEnabled}} ], "compounds": [ { @@ -177,6 +194,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ @@ -228,9 +260,9 @@ "order": 1 }, "stopAll": true - {{#CEAEnabled}} - }, - { + } +{{#CEAEnabled}} + ,{ "name": "Debug in Copilot (Edge)", "configurations": [ "Launch in Copilot (Edge)", @@ -242,8 +274,8 @@ "order": 1 }, "stopAll": true - }, - { + }, + { "name": "Debug in Copilot (Chrome)", "configurations": [ "Launch in Copilot (Chrome)", @@ -255,7 +287,7 @@ "order": 2 }, "stopAll": true - {{/CEAEnabled}} } +{{/CEAEnabled}} ] } diff --git a/templates/vsc/js/custom-copilot-rag-custom-api/.vscode/tasks.json b/templates/vsc/js/custom-copilot-rag-custom-api/.vscode/tasks.json index 0ced6235bda..09b7763fa99 100644 --- a/templates/vsc/js/custom-copilot-rag-custom-api/.vscode/tasks.json +++ b/templates/vsc/js/custom-copilot-rag-custom-api/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -227,6 +239,75 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", // Validate available ports to ensure those debug ones are not occupied. + "sandbox", + "nodejs" // Validate if Node.js is installed. + ], + "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 (Sandbox)", + "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": "sandbox" + }, + "isBackground": true, + "problemMatcher": "$teamsfx-local-tunnel-watch" + }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + // Build project. + // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } } ] } \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-custom-api/env/.env.sandbox b/templates/vsc/js/custom-copilot-rag-custom-api/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-custom-api/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/js/custom-copilot-rag-custom-api/env/.env.sandbox.user.tpl b/templates/vsc/js/custom-copilot-rag-custom-api/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..c67b5dfaaeb --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-custom-api/env/.env.sandbox.user.tpl @@ -0,0 +1,33 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_MODEL_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_MODEL_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT=' ' +{{/azureOpenAIEndpoint}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-custom-api/m365agents.sandbox.yml.tpl b/templates/vsc/js/custom-copilot-rag-custom-api/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..6d20ef59923 --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-custom-api/m365agents.sandbox.yml.tpl @@ -0,0 +1,118 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT: ${{AZURE_OPENAI_MODEL_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-customize/.vscode/launch.json.tpl b/templates/vsc/js/custom-copilot-rag-customize/.vscode/launch.json.tpl index 68660d1b4cf..1db36c78e0d 100644 --- a/templates/vsc/js/custom-copilot-rag-customize/.vscode/launch.json.tpl +++ b/templates/vsc/js/custom-copilot-rag-customize/.vscode/launch.json.tpl @@ -89,10 +89,10 @@ {{/enableTestToolByDefault}} "order": 6 }, - "internalConsoleOptions": "neverOpen", - {{#CEAEnabled}} - }, - { + "internalConsoleOptions": "neverOpen" + } +{{#CEAEnabled}} + ,{ "name": "Launch Remote in Copilot (Edge)", "type": "msedge", "request": "launch", @@ -156,8 +156,25 @@ "--remote-debugging-port=9223", "--no-first-run" ] - {{/CEAEnabled}} } +{{#SandBoxedTeam}} + ,{ + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + } +{{/SandBoxedTeam}} +{{/CEAEnabled}} ], "compounds": [ { @@ -178,6 +195,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ @@ -229,9 +261,9 @@ "order": 1 }, "stopAll": true - {{#CEAEnabled}} - }, - { + } +{{#CEAEnabled}} + ,{ "name": "Debug in Copilot (Edge)", "configurations": [ "Launch in Copilot (Edge)", @@ -243,8 +275,8 @@ "order": 1 }, "stopAll": true - }, - { + }, + { "name": "Debug in Copilot (Chrome)", "configurations": [ "Launch in Copilot (Chrome)", @@ -256,7 +288,7 @@ "order": 2 }, "stopAll": true - {{/CEAEnabled}} } +{{/CEAEnabled}} ] } diff --git a/templates/vsc/js/custom-copilot-rag-customize/.vscode/tasks.json b/templates/vsc/js/custom-copilot-rag-customize/.vscode/tasks.json index 0ced6235bda..a0c4b179711 100644 --- a/templates/vsc/js/custom-copilot-rag-customize/.vscode/tasks.json +++ b/templates/vsc/js/custom-copilot-rag-customize/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -132,6 +144,24 @@ ] } }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", // Validate available ports to ensure those debug ones are not occupied. + "sandbox", + "nodejs" // Validate if Node.js is installed. + ], + "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. @@ -156,6 +186,30 @@ "isBackground": true, "problemMatcher": "$teamsfx-local-tunnel-watch" }, + { + // 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 (Sandbox)", + "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": "sandbox" + }, + "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. @@ -166,6 +220,14 @@ "env": "local" } }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox", + } + }, { // Build project. // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. @@ -176,6 +238,16 @@ "env": "local" } }, + { + // Build project. + // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, { "label": "Start application", "type": "shell", diff --git a/templates/vsc/js/custom-copilot-rag-customize/env/.env.sandbox b/templates/vsc/js/custom-copilot-rag-customize/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-customize/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/js/custom-copilot-rag-customize/env/.env.sandbox.user.tpl b/templates/vsc/js/custom-copilot-rag-customize/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..7dbda95bc90 --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-customize/env/.env.sandbox.user.tpl @@ -0,0 +1,33 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-customize/m365agents.sandbox.yml.tpl b/templates/vsc/js/custom-copilot-rag-customize/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..0c6b48d1562 --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-customize/m365agents.sandbox.yml.tpl @@ -0,0 +1,118 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-microsoft365/.vscode/launch.json.tpl b/templates/vsc/js/custom-copilot-rag-microsoft365/.vscode/launch.json.tpl index 4581d395378..5a6a5d42c61 100644 --- a/templates/vsc/js/custom-copilot-rag-microsoft365/.vscode/launch.json.tpl +++ b/templates/vsc/js/custom-copilot-rag-microsoft365/.vscode/launch.json.tpl @@ -65,6 +65,23 @@ }, "internalConsoleOptions": "neverOpen" }, +{{#SandBoxedTeam}} + { + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + }, +{{/SandBoxedTeam}} { "name": "Launch Remote in Teams (Desktop)", "type": "node", @@ -74,7 +91,7 @@ "group": "1-Teams", "order": 6 }, - "internalConsoleOptions": "neverOpen", + "internalConsoleOptions": "neverOpen" } ], "compounds": [ @@ -91,6 +108,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ diff --git a/templates/vsc/js/custom-copilot-rag-microsoft365/.vscode/tasks.json b/templates/vsc/js/custom-copilot-rag-microsoft365/.vscode/tasks.json index 897205156c1..da1188569b2 100644 --- a/templates/vsc/js/custom-copilot-rag-microsoft365/.vscode/tasks.json +++ b/templates/vsc/js/custom-copilot-rag-microsoft365/.vscode/tasks.json @@ -33,6 +33,24 @@ ] } }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", // Validate available ports to ensure those debug ones are not occupied. + "sandbox", + "nodejs" // Validate if Node.js is installed. + ], + "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. @@ -57,6 +75,30 @@ "isBackground": true, "problemMatcher": "$teamsfx-local-tunnel-watch" }, + { + // 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 (Sandbox)", + "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": "sandbox" + }, + "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. @@ -67,6 +109,14 @@ "env": "local" } }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox", + } + }, { // Build project. // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. @@ -78,29 +128,27 @@ } }, { - "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": "app listening to|Bot/ME service listening at|[nodemon] app crashed" - } + // Build project. + // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" } }, + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Desktop Client", "dependsOn": [ diff --git a/templates/vsc/js/custom-copilot-rag-microsoft365/env/.env.sandbox b/templates/vsc/js/custom-copilot-rag-microsoft365/env/.env.sandbox new file mode 100644 index 00000000000..9f8a6a1172d --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-microsoft365/env/.env.sandbox @@ -0,0 +1,17 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= +AAD_APP_CLIENT_ID= +AAD_APP_OBJECT_ID= +AAD_APP_TENANT_ID= +AAD_APP_OAUTH_AUTHORITY= +AAD_APP_OAUTH_AUTHORITY_HOST= +AAD_APP_ACCESS_AS_USER_PERMISSION_ID= diff --git a/templates/vsc/js/custom-copilot-rag-microsoft365/env/.env.sandbox.user.tpl b/templates/vsc/js/custom-copilot-rag-microsoft365/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..a6d09c4c591 --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-microsoft365/env/.env.sandbox.user.tpl @@ -0,0 +1,34 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +SECRET_AAD_APP_CLIENT_SECRET= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/custom-copilot-rag-microsoft365/m365agents.sandbox.yml.tpl b/templates/vsc/js/custom-copilot-rag-microsoft365/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..48188f35c6a --- /dev/null +++ b/templates/vsc/js/custom-copilot-rag-microsoft365/m365agents.sandbox.yml.tpl @@ -0,0 +1,128 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + - uses: aadApp/create # Creates a new Azure Active Directory (AAD) app to authenticate users if the environment variable that stores clientId is empty + with: + name: {{appName}}-aad # Note: when you run aadApp/update, the AAD app name will be updated based on the definition in manifest. If you don't want to change the name, make sure the name in AAD manifest is the same with the name defined here. + generateClientSecret: true # If the value is false, the action will not generate client secret for you + signInAudience: "AzureADMyOrg" # Authenticate users with a Microsoft work or school account in your organization's Azure AD tenant (for example, single tenant). + writeToEnvironmentFile: # Write the information of created resources into environment file for the specified environment variable(s). + clientId: AAD_APP_CLIENT_ID + clientSecret: SECRET_AAD_APP_CLIENT_SECRET # Environment variable that starts with `SECRET_` will be stored to the .env.{envName}.user environment file + objectId: AAD_APP_OBJECT_ID + tenantId: AAD_APP_TENANT_ID + authority: AAD_APP_OAUTH_AUTHORITY + authorityHost: AAD_APP_OAUTH_AUTHORITY_HOST + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + - uses: aadApp/update # Apply the AAD manifest to an existing AAD app. Will use the object id in manifest file to determine which AAD app to update. + with: + manifestPath: ./aad.manifest.json # Relative path to teamsfx folder. Environment variables in manifest will be replaced before apply to AAD app + outputFilePath: ./build/aad.manifest.${{TEAMSFX_ENV}}.json + + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + BOT_DOMAIN: ${{BOT_DOMAIN}} + AAD_APP_CLIENT_ID: ${{AAD_APP_CLIENT_ID}} + AAD_APP_CLIENT_SECRET: ${{SECRET_AAD_APP_CLIENT_SECRET}} + AAD_APP_TENANT_ID: ${{AAD_APP_TENANT_ID}} + AAD_APP_OAUTH_AUTHORITY_HOST: ${{AAD_APP_OAUTH_AUTHORITY_HOST}} + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/js/weather-agent/env/.env.sandbox b/templates/vsc/js/weather-agent/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/js/weather-agent/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/js/weather-agent/m365agents.sandbox.yml.tpl b/templates/vsc/js/weather-agent/m365agents.sandbox.yml.tpl index f915939fd6f..3cfa8a04fed 100644 --- a/templates/vsc/js/weather-agent/m365agents.sandbox.yml.tpl +++ b/templates/vsc/js/weather-agent/m365agents.sandbox.yml.tpl @@ -90,15 +90,6 @@ provision: appId: M365_APP_ID deploy: -{{#SandBoxedTeam}} - # Sideload app in sandboxed team. - - uses: devChannel/installApp - with: - teamId: ${{TEAM_ID}} - channelId: ${{CHANNEL_ID}} - appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip -{{/SandBoxedTeam}} - # Run npm command - uses: cli/runNpmCommand name: install dependencies @@ -110,9 +101,8 @@ deploy: with: target: ./.localConfigs envs: - BOT_ID: ${{BOT_ID}} - BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} - BOT_TYPE: 'MultiTenant' + clientId: ${{BOT_ID}} + clientSecret: ${{SECRET_BOT_PASSWORD}} {{#useOpenAI}} OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} {{/useOpenAI}} diff --git a/templates/vsc/ts/basic-custom-engine-agent/.vscode/launch.json.tpl b/templates/vsc/ts/basic-custom-engine-agent/.vscode/launch.json.tpl index 9774495742f..d28ece44629 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/.vscode/launch.json.tpl +++ b/templates/vsc/ts/basic-custom-engine-agent/.vscode/launch.json.tpl @@ -154,9 +154,10 @@ "--remote-debugging-port=9223", "--no-first-run" ] + + } {{#SandBoxedTeam}} - }, - { + ,{ "name": "Launch App to channel (Edge)", "type": "msedge", "request": "launch", @@ -170,8 +171,8 @@ }, "internalConsoleOptions": "neverOpen", "perScriptSourcemaps": "yes" -{{/SandBoxedTeam}} } +{{/SandBoxedTeam}} ], "compounds": [ { diff --git a/templates/vsc/ts/basic-custom-engine-agent/env/.env.sandbox b/templates/vsc/ts/basic-custom-engine-agent/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/ts/basic-custom-engine-agent/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/ts/basic-custom-engine-agent/m365agents.sandbox.yml.tpl b/templates/vsc/ts/basic-custom-engine-agent/m365agents.sandbox.yml.tpl index 55a85783ce8..3cfa8a04fed 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/m365agents.sandbox.yml.tpl +++ b/templates/vsc/ts/basic-custom-engine-agent/m365agents.sandbox.yml.tpl @@ -103,7 +103,6 @@ deploy: envs: clientId: ${{BOT_ID}} clientSecret: ${{SECRET_BOT_PASSWORD}} - BOT_TYPE: 'MultiTenant' {{#useOpenAI}} OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} {{/useOpenAI}} diff --git a/templates/vsc/ts/custom-copilot-assistant-assistants-api/.vscode/launch.json.tpl b/templates/vsc/ts/custom-copilot-assistant-assistants-api/.vscode/launch.json.tpl index 068383cb455..7a1f95c0eeb 100644 --- a/templates/vsc/ts/custom-copilot-assistant-assistants-api/.vscode/launch.json.tpl +++ b/templates/vsc/ts/custom-copilot-assistant-assistants-api/.vscode/launch.json.tpl @@ -75,6 +75,23 @@ }, "internalConsoleOptions": "neverOpen" }, +{{#SandBoxedTeam}} + { + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + }, +{{/SandBoxedTeam}} { "name": "Launch Remote in Teams (Desktop)", "type": "node", @@ -178,6 +195,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ diff --git a/templates/vsc/ts/custom-copilot-assistant-assistants-api/.vscode/tasks.json b/templates/vsc/ts/custom-copilot-assistant-assistants-api/.vscode/tasks.json index 0ced6235bda..21b9b936471 100644 --- a/templates/vsc/ts/custom-copilot-assistant-assistants-api/.vscode/tasks.json +++ b/templates/vsc/ts/custom-copilot-assistant-assistants-api/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -200,6 +212,66 @@ } } }, + { + // 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 (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", // Validate available ports to ensure those debug ones are not occupied. + "sandbox", + "nodejs" // Validate if Node.js is installed. + ], + "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 (Sandbox)", + "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": "sandbox" + }, + "isBackground": true, + "problemMatcher": "$teamsfx-local-tunnel-watch" + }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox", + } + }, + { + // Build project. + // See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args. + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, { "label": "Start Agent in Desktop Client", "dependsOn": [ @@ -227,6 +299,15 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip", + } } ] } \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-assistant-assistants-api/env/.env.sandbox b/templates/vsc/ts/custom-copilot-assistant-assistants-api/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/ts/custom-copilot-assistant-assistants-api/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/ts/custom-copilot-assistant-assistants-api/env/.env.sandbox.user.tpl b/templates/vsc/ts/custom-copilot-assistant-assistants-api/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..85717badf18 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-assistant-assistants-api/env/.env.sandbox.user.tpl @@ -0,0 +1,29 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +OPENAI_ASSISTANT_ID= # See README.md for how to fill in this value. +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +AZURE_OPENAI_ASSISTANT_ID= # See README.md for how to fill in this value. +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-assistant-assistants-api/m365agents.sandbox.yml.tpl b/templates/vsc/ts/custom-copilot-assistant-assistants-api/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..45a4e870c65 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-assistant-assistants-api/m365agents.sandbox.yml.tpl @@ -0,0 +1,119 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + OPENAI_ASSISTANT_ID: ${{OPENAI_ASSISTANT_ID}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_ASSISTANT_ID: ${{AZURE_OPENAI_ASSISTANT_ID}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-assistant-new/.vscode/launch.json.tpl b/templates/vsc/ts/custom-copilot-assistant-new/.vscode/launch.json.tpl index 89bcf36c8b1..2f972571bf7 100644 --- a/templates/vsc/ts/custom-copilot-assistant-new/.vscode/launch.json.tpl +++ b/templates/vsc/ts/custom-copilot-assistant-new/.vscode/launch.json.tpl @@ -75,6 +75,23 @@ }, "internalConsoleOptions": "neverOpen" }, +{{#SandBoxedTeam}} + { + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + }, +{{/SandBoxedTeam}} { "name": "Launch Remote in Teams (Desktop)", "type": "node", @@ -177,6 +194,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ diff --git a/templates/vsc/ts/custom-copilot-assistant-new/.vscode/tasks.json b/templates/vsc/ts/custom-copilot-assistant-new/.vscode/tasks.json index 0ced6235bda..64103e83b33 100644 --- a/templates/vsc/ts/custom-copilot-assistant-new/.vscode/tasks.json +++ b/templates/vsc/ts/custom-copilot-assistant-new/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -227,6 +239,69 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + "label": "Validate prerequisites (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "m365Account", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + "label": "Start local tunnel (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "isBackground": true, + "problemMatcher": "$teamsfx-local-tunnel-watch" + }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } } ] } \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-assistant-new/env/.env.sandbox b/templates/vsc/ts/custom-copilot-assistant-new/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/ts/custom-copilot-assistant-new/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/ts/custom-copilot-assistant-new/env/.env.sandbox.user.tpl b/templates/vsc/ts/custom-copilot-assistant-new/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..7dbda95bc90 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-assistant-new/env/.env.sandbox.user.tpl @@ -0,0 +1,33 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-assistant-new/m365agents.sandbox.yml.tpl b/templates/vsc/ts/custom-copilot-assistant-new/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..0c6b48d1562 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-assistant-new/m365agents.sandbox.yml.tpl @@ -0,0 +1,118 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-basic/.vscode/tasks.json b/templates/vsc/ts/custom-copilot-basic/.vscode/tasks.json index 48430c86158..a914b580204 100644 --- a/templates/vsc/ts/custom-copilot-basic/.vscode/tasks.json +++ b/templates/vsc/ts/custom-copilot-basic/.vscode/tasks.json @@ -12,6 +12,7 @@ "Provision (Sandbox)", "Deploy (Sandbox)", "Start application", + "Sideload App to channel" ], "dependsOrder": "sequence" }, @@ -298,6 +299,15 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } } ] } \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-basic/env/.env.sandbox b/templates/vsc/ts/custom-copilot-basic/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/ts/custom-copilot-basic/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/ts/custom-copilot-basic/m365agents.sandbox.yml.tpl b/templates/vsc/ts/custom-copilot-basic/m365agents.sandbox.yml.tpl index 6a26b0c7d0e..0c6b48d1562 100644 --- a/templates/vsc/ts/custom-copilot-basic/m365agents.sandbox.yml.tpl +++ b/templates/vsc/ts/custom-copilot-basic/m365agents.sandbox.yml.tpl @@ -94,15 +94,6 @@ provision: {{/CEAEnabled}} deploy: -{{#SandBoxedTeam}} - # Sideload app in sandboxed team. - - uses: devChannel/installApp - with: - teamId: ${{TEAM_ID}} - channelId: ${{CHANNEL_ID}} - appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip -{{/SandBoxedTeam}} - # Run npm command - uses: cli/runNpmCommand name: install dependencies diff --git a/templates/vsc/ts/custom-copilot-rag-azure-ai-search/.vscode/launch.json.tpl b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/.vscode/launch.json.tpl index 89bcf36c8b1..2f972571bf7 100644 --- a/templates/vsc/ts/custom-copilot-rag-azure-ai-search/.vscode/launch.json.tpl +++ b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/.vscode/launch.json.tpl @@ -75,6 +75,23 @@ }, "internalConsoleOptions": "neverOpen" }, +{{#SandBoxedTeam}} + { + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + }, +{{/SandBoxedTeam}} { "name": "Launch Remote in Teams (Desktop)", "type": "node", @@ -177,6 +194,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ diff --git a/templates/vsc/ts/custom-copilot-rag-azure-ai-search/.vscode/tasks.json b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/.vscode/tasks.json index 0ced6235bda..64103e83b33 100644 --- a/templates/vsc/ts/custom-copilot-rag-azure-ai-search/.vscode/tasks.json +++ b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -227,6 +239,69 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + "label": "Validate prerequisites (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "m365Account", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + "label": "Start local tunnel (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "isBackground": true, + "problemMatcher": "$teamsfx-local-tunnel-watch" + }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } } ] } \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-azure-ai-search/env/.env.sandbox b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/ts/custom-copilot-rag-azure-ai-search/env/.env.sandbox.user.tpl b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..67095b67c7c --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/env/.env.sandbox.user.tpl @@ -0,0 +1,51 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{#azureOpenAIEmbeddingDeploymentName}} +AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME='{{{azureOpenAIEmbeddingDeploymentName}}}' +{{/azureOpenAIEmbeddingDeploymentName}} +{{^azureOpenAIEmbeddingDeploymentName}} +AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME= +{{/azureOpenAIEmbeddingDeploymentName}} +{{/useAzureOpenAI}} +{{#secretAzureSearchKey}} +SECRET_AZURE_SEARCH_KEY='{{{secretAzureSearchKey}}}' +{{/secretAzureSearchKey}} +{{^secretAzureSearchKey}} +SECRET_AZURE_SEARCH_KEY= +{{/secretAzureSearchKey}} +{{#azureSearchEndpoint}} +AZURE_SEARCH_ENDPOINT='{{{azureSearchEndpoint}}}' +{{/azureSearchEndpoint}} +{{^azureSearchEndpoint}} +AZURE_SEARCH_ENDPOINT= +{{/azureSearchEndpoint}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-azure-ai-search/m365agents.sandbox.yml.tpl b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..2b833e649e5 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-azure-ai-search/m365agents.sandbox.yml.tpl @@ -0,0 +1,121 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME: ${{AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} + AZURE_SEARCH_KEY: ${{SECRET_AZURE_SEARCH_KEY}} + AZURE_SEARCH_ENDPOINT: ${{AZURE_SEARCH_ENDPOINT}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-custom-api/.vscode/launch.json.tpl b/templates/vsc/ts/custom-copilot-rag-custom-api/.vscode/launch.json.tpl index 89bcf36c8b1..2f972571bf7 100644 --- a/templates/vsc/ts/custom-copilot-rag-custom-api/.vscode/launch.json.tpl +++ b/templates/vsc/ts/custom-copilot-rag-custom-api/.vscode/launch.json.tpl @@ -75,6 +75,23 @@ }, "internalConsoleOptions": "neverOpen" }, +{{#SandBoxedTeam}} + { + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + }, +{{/SandBoxedTeam}} { "name": "Launch Remote in Teams (Desktop)", "type": "node", @@ -177,6 +194,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ diff --git a/templates/vsc/ts/custom-copilot-rag-custom-api/.vscode/tasks.json b/templates/vsc/ts/custom-copilot-rag-custom-api/.vscode/tasks.json index 0ced6235bda..64103e83b33 100644 --- a/templates/vsc/ts/custom-copilot-rag-custom-api/.vscode/tasks.json +++ b/templates/vsc/ts/custom-copilot-rag-custom-api/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -227,6 +239,69 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + "label": "Validate prerequisites (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "m365Account", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + "label": "Start local tunnel (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "isBackground": true, + "problemMatcher": "$teamsfx-local-tunnel-watch" + }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } } ] } \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-custom-api/env/.env.sandbox b/templates/vsc/ts/custom-copilot-rag-custom-api/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-custom-api/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/ts/custom-copilot-rag-custom-api/env/.env.sandbox.user.tpl b/templates/vsc/ts/custom-copilot-rag-custom-api/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..c67b5dfaaeb --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-custom-api/env/.env.sandbox.user.tpl @@ -0,0 +1,33 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_MODEL_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_MODEL_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT=' ' +{{/azureOpenAIEndpoint}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-custom-api/m365agents.sandbox.yml.tpl b/templates/vsc/ts/custom-copilot-rag-custom-api/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..6d20ef59923 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-custom-api/m365agents.sandbox.yml.tpl @@ -0,0 +1,118 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT: ${{AZURE_OPENAI_MODEL_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-customize/.vscode/launch.json.tpl b/templates/vsc/ts/custom-copilot-rag-customize/.vscode/launch.json.tpl index 89bcf36c8b1..2f972571bf7 100644 --- a/templates/vsc/ts/custom-copilot-rag-customize/.vscode/launch.json.tpl +++ b/templates/vsc/ts/custom-copilot-rag-customize/.vscode/launch.json.tpl @@ -75,6 +75,23 @@ }, "internalConsoleOptions": "neverOpen" }, +{{#SandBoxedTeam}} + { + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + }, +{{/SandBoxedTeam}} { "name": "Launch Remote in Teams (Desktop)", "type": "node", @@ -177,6 +194,21 @@ }, "stopAll": true }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { + "group": "1-local", + "order": 1 + }, + "stopAll": true + }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ diff --git a/templates/vsc/ts/custom-copilot-rag-customize/.vscode/tasks.json b/templates/vsc/ts/custom-copilot-rag-customize/.vscode/tasks.json index 0ced6235bda..64103e83b33 100644 --- a/templates/vsc/ts/custom-copilot-rag-customize/.vscode/tasks.json +++ b/templates/vsc/ts/custom-copilot-rag-customize/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent in Microsoft 365 Agents Playground", "dependsOn": [ @@ -227,6 +239,69 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + "label": "Validate prerequisites (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "m365Account", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + "label": "Start local tunnel (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "isBackground": true, + "problemMatcher": "$teamsfx-local-tunnel-watch" + }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } } ] } \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-customize/env/.env.sandbox b/templates/vsc/ts/custom-copilot-rag-customize/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-customize/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/ts/custom-copilot-rag-customize/env/.env.sandbox.user.tpl b/templates/vsc/ts/custom-copilot-rag-customize/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..7dbda95bc90 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-customize/env/.env.sandbox.user.tpl @@ -0,0 +1,33 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-customize/m365agents.sandbox.yml.tpl b/templates/vsc/ts/custom-copilot-rag-customize/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..0c6b48d1562 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-customize/m365agents.sandbox.yml.tpl @@ -0,0 +1,118 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + {{^CEAEnabled}} + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + {{/CEAEnabled}} + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + +{{#CEAEnabled}} + - uses: teamsApp/extendToM365 + with: + # Relative path to the build app package. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + titleId: M365_TITLE_ID + appId: M365_APP_ID +{{/CEAEnabled}} + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-microsoft365/.vscode/launch.json.tpl b/templates/vsc/ts/custom-copilot-rag-microsoft365/.vscode/launch.json.tpl index 4581d395378..41017b4e471 100644 --- a/templates/vsc/ts/custom-copilot-rag-microsoft365/.vscode/launch.json.tpl +++ b/templates/vsc/ts/custom-copilot-rag-microsoft365/.vscode/launch.json.tpl @@ -7,7 +7,12 @@ "request": "launch", "url": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}", "presentation": { +{{#enableTestToolByDefault}} + "group": "2-Teams", +{{/enableTestToolByDefault}} +{{^enableTestToolByDefault}} "group": "1-Teams", +{{/enableTestToolByDefault}} "order": 4 }, "internalConsoleOptions": "neverOpen" @@ -18,7 +23,12 @@ "request": "launch", "url": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}", "presentation": { +{{#enableTestToolByDefault}} + "group": "2-Teams", +{{/enableTestToolByDefault}} +{{^enableTestToolByDefault}} "group": "1-Teams", +{{/enableTestToolByDefault}} "order": 5 }, "internalConsoleOptions": "neverOpen" @@ -65,6 +75,23 @@ }, "internalConsoleOptions": "neverOpen" }, +{{#SandBoxedTeam}} + { + "name": "Launch Agent to channel (Edge)", + "type": "msedge", + "request": "launch", + "url": "${{sandbox:CHANNEL_WEB_URL}}&webjoin=true", + "cascadeTerminateToConfigurations": [ + "Attach to Local Service" + ], + "presentation": { + "group": "all", + "hidden": true + }, + "internalConsoleOptions": "neverOpen", + "perScriptSourcemaps": "yes" + }, +{{/SandBoxedTeam}} { "name": "Launch Remote in Teams (Desktop)", "type": "node", @@ -86,11 +113,31 @@ ], "preLaunchTask": "Start Agent Locally", "presentation": { +{{#enableTestToolByDefault}} + "group": "2-Teams", +{{/enableTestToolByDefault}} +{{^enableTestToolByDefault}} + "group": "1-Teams", +{{/enableTestToolByDefault}} + "order": 1 + }, + "stopAll": true + }, +{{#SandBoxedTeam}} + { + "name": "Debug in sandbox in Teams (Edge)", + "configurations": [ + "Launch Agent to channel (Edge)", + "Attach to Local Service" + ], + "preLaunchTask": "Start Agent (Sandbox)", + "presentation": { "group": "1-local", "order": 1 }, "stopAll": true }, +{{/SandBoxedTeam}} { "name": "Debug in Teams (Chrome)", "configurations": [ @@ -99,7 +146,12 @@ ], "preLaunchTask": "Start Agent Locally", "presentation": { - "group": "1-local", +{{#enableTestToolByDefault}} + "group": "2-Teams", +{{/enableTestToolByDefault}} +{{^enableTestToolByDefault}} + "group": "1-Teams", +{{/enableTestToolByDefault}} "order": 2 }, "stopAll": true @@ -111,7 +163,12 @@ ], "preLaunchTask": "Start Agent in Desktop Client", "presentation": { - "group": "1-local", +{{#enableTestToolByDefault}} + "group": "2-Teams", +{{/enableTestToolByDefault}} +{{^enableTestToolByDefault}} + "group": "1-Teams", +{{/enableTestToolByDefault}} "order": 3 }, "stopAll": true diff --git a/templates/vsc/ts/custom-copilot-rag-microsoft365/.vscode/tasks.json b/templates/vsc/ts/custom-copilot-rag-microsoft365/.vscode/tasks.json index 897205156c1..126c6e68459 100644 --- a/templates/vsc/ts/custom-copilot-rag-microsoft365/.vscode/tasks.json +++ b/templates/vsc/ts/custom-copilot-rag-microsoft365/.vscode/tasks.json @@ -4,6 +4,18 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Start Agent (Sandbox)", + "dependsOn": [ + "Validate prerequisites (Sandbox)", + "Start local tunnel (Sandbox)", + "Provision (Sandbox)", + "Deploy (Sandbox)", + "Start application", + "Sideload App to channel" + ], + "dependsOrder": "sequence" + }, { "label": "Start Agent Locally", "dependsOn": [ @@ -128,6 +140,69 @@ "args": { "url": "teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true" } + }, + { + "label": "Validate prerequisites (Sandbox)", + "type": "teamsfx", + "command": "debug-check-prerequisites", + "args": { + "prerequisites": [ + "portOccupancy", + "m365Account", + "nodejs" + ], + "portOccupancy": [ + 3978, + 9239 + ] + } + }, + { + "label": "Start local tunnel (Sandbox)", + "type": "teamsfx", + "command": "debug-start-local-tunnel", + "args": { + "type": "dev-tunnel", + "ports": [ + { + "portNumber": 3978, + "protocol": "http", + "access": "public", + "writeToEnvironmentFile": { + "endpoint": "BOT_ENDPOINT", + "domain": "BOT_DOMAIN" + } + } + ], + "env": "sandbox" + }, + "isBackground": true, + "problemMatcher": "$teamsfx-local-tunnel-watch" + }, + { + "label": "Provision (Sandbox)", + "type": "teamsfx", + "command": "provision", + "args": { + "env": "sandbox" + } + }, + { + "label": "Deploy (Sandbox)", + "type": "teamsfx", + "command": "deploy", + "args": { + "env": "sandbox" + } + }, + { + "label": "Sideload App to channel", + "type": "teamsfx", + "command": "install-app", + "args": { + "env": "sandbox", + "appPackagePath": "${workspaceFolder}/appPackage/build/appPackage.sandbox.zip" + } } ] } \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-microsoft365/env/.env.sandbox b/templates/vsc/ts/custom-copilot-rag-microsoft365/env/.env.sandbox new file mode 100644 index 00000000000..9f8a6a1172d --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-microsoft365/env/.env.sandbox @@ -0,0 +1,17 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= +AAD_APP_CLIENT_ID= +AAD_APP_OBJECT_ID= +AAD_APP_TENANT_ID= +AAD_APP_OAUTH_AUTHORITY= +AAD_APP_OAUTH_AUTHORITY_HOST= +AAD_APP_ACCESS_AS_USER_PERMISSION_ID= diff --git a/templates/vsc/ts/custom-copilot-rag-microsoft365/env/.env.sandbox.user.tpl b/templates/vsc/ts/custom-copilot-rag-microsoft365/env/.env.sandbox.user.tpl new file mode 100644 index 00000000000..a6d09c4c591 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-microsoft365/env/.env.sandbox.user.tpl @@ -0,0 +1,34 @@ +# This file includes environment variables that will not be committed to git by default. You can set these environment variables in your CI/CD system for your project. + +# If you're adding a secret value, add SECRET_ prefix to the name so Microsoft 365 Agents Toolkit can handle them properly +# Secrets. Keys prefixed with `SECRET_` will be masked in Microsoft 365 Agents Toolkit logs. +SECRET_BOT_PASSWORD= +SECRET_AAD_APP_CLIENT_SECRET= +{{#useOpenAI}} +{{#openAIKey}} +SECRET_OPENAI_API_KEY={{{openAIKey}}} +{{/openAIKey}} +{{^openAIKey}} +SECRET_OPENAI_API_KEY= +{{/openAIKey}} +{{/useOpenAI}} +{{#useAzureOpenAI}} +{{#azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY={{{azureOpenAIKey}}} +{{/azureOpenAIKey}} +{{^azureOpenAIKey}} +SECRET_AZURE_OPENAI_API_KEY= +{{/azureOpenAIKey}} +{{#azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT='{{{azureOpenAIEndpoint}}}' +{{/azureOpenAIEndpoint}} +{{^azureOpenAIEndpoint}} +AZURE_OPENAI_ENDPOINT= +{{/azureOpenAIEndpoint}} +{{#azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME='{{{azureOpenAIDeploymentName}}}' +{{/azureOpenAIDeploymentName}} +{{^azureOpenAIDeploymentName}} +AZURE_OPENAI_DEPLOYMENT_NAME= +{{/azureOpenAIDeploymentName}} +{{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/custom-copilot-rag-microsoft365/m365agents.sandbox.yml.tpl b/templates/vsc/ts/custom-copilot-rag-microsoft365/m365agents.sandbox.yml.tpl new file mode 100644 index 00000000000..94f181fea69 --- /dev/null +++ b/templates/vsc/ts/custom-copilot-rag-microsoft365/m365agents.sandbox.yml.tpl @@ -0,0 +1,128 @@ +# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json +# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file +# Visit https://aka.ms/teamsfx-actions for details on actions +version: v1.9 + +provision: +{{#SandBoxedTeam}} + # Creates a Teams channel in the specified team. + - uses: devChannel/create + with: + teamName: "App Development" # The name of the team in which to create the channel. + channelName: "{{appName}} App testing" # The default name for the channel. + description: "Team created via Microsoft 365 Agents Toolkit for development" # Optional team description. + writeToEnvironmentFile: + channelId: CHANNEL_ID # The ID of the created channel. + teamId: TEAM_ID # The ID of the team in which the channel was created. + channelWebUrl: CHANNEL_WEB_URL # A hyperlink to open Teams client +{{/SandBoxedTeam}} + +- uses: aadApp/create # Creates a new Azure Active Directory (AAD) app to authenticate users if the environment variable that stores clientId is empty + with: + name: {{appName}}-aad # Note: when you run aadApp/update, the AAD app name will be updated based on the definition in manifest. If you don't want to change the name, make sure the name in AAD manifest is the same with the name defined here. + generateClientSecret: true # If the value is false, the action will not generate client secret for you + signInAudience: "AzureADMyOrg" # Authenticate users with a Microsoft work or school account in your organization's Azure AD tenant (for example, single tenant). + writeToEnvironmentFile: # Write the information of created resources into environment file for the specified environment variable(s). + clientId: AAD_APP_CLIENT_ID + clientSecret: SECRET_AAD_APP_CLIENT_SECRET # Environment variable that starts with `SECRET_` will be stored to the .env.{envName}.user environment file + objectId: AAD_APP_OBJECT_ID + tenantId: AAD_APP_TENANT_ID + authority: AAD_APP_OAUTH_AUTHORITY + authorityHost: AAD_APP_OAUTH_AUTHORITY_HOST + + # Creates an app + - uses: teamsApp/create + with: + # app name + name: {{appName}}${{APP_NAME_SUFFIX}} + # Write the information of created resources into environment file for + # the specified environment variable(s). + writeToEnvironmentFile: + teamsAppId: TEAMS_APP_ID + + # Create or reuse an existing Microsoft Entra application for bot. + - uses: aadApp/create + with: + # The Microsoft Entra application's display name + name: {{appName}}${{APP_NAME_SUFFIX}} + generateClientSecret: true + signInAudience: AzureADMultipleOrgs + writeToEnvironmentFile: + # The Microsoft Entra application's client id created for bot. + clientId: BOT_ID + # The Microsoft Entra application's client secret created for bot. + clientSecret: SECRET_BOT_PASSWORD + # The Microsoft Entra application's object id created for bot. + objectId: BOT_OBJECT_ID + + # Create or update the bot registration on dev.botframework.com + - uses: botFramework/create + with: + botId: ${{BOT_ID}} + name: {{appName}} + messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages + description: "" + channels: + - name: msteams + + - uses: aadApp/update # Apply the AAD manifest to an existing AAD app. Will use the object id in manifest file to determine which AAD app to update. + with: + manifestPath: ./aad.manifest.json # Relative path to teamsfx folder. Environment variables in manifest will be replaced before apply to AAD app + outputFilePath: ./build/aad.manifest.${{TEAMSFX_ENV}}.json + + # Validate using manifest schema + - uses: teamsApp/validateManifest + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + + # Build app package with latest env value + - uses: teamsApp/zipAppPackage + with: + # Path to manifest template + manifestPath: ./appPackage/manifest.json + outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + outputFolder: ./appPackage/build + # Validate app package using validation rules + - uses: teamsApp/validateAppPackage + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + # Apply the app manifest to an existing app in + # Developer Portal. + # Will use the app id in manifest file to determine which app to update. + - uses: teamsApp/update + with: + # Relative path to this file. This is the path for built zip file. + appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip + + +deploy: + # Run npm command + - uses: cli/runNpmCommand + name: install dependencies + with: + args: install --no-audit + + # Generate runtime environment variables + - uses: file/createOrUpdateEnvironmentFile + with: + target: ./.localConfigs + envs: + BOT_ID: ${{BOT_ID}} + BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} + BOT_TYPE: 'MultiTenant' + BOT_DOMAIN: ${{BOT_DOMAIN}} + AAD_APP_CLIENT_ID: ${{AAD_APP_CLIENT_ID}} + AAD_APP_CLIENT_SECRET: ${{SECRET_AAD_APP_CLIENT_SECRET}} + AAD_APP_TENANT_ID: ${{AAD_APP_TENANT_ID}} + AAD_APP_OAUTH_AUTHORITY_HOST: ${{AAD_APP_OAUTH_AUTHORITY_HOST}} + {{#useOpenAI}} + OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} + {{/useOpenAI}} + {{#useAzureOpenAI}} + AZURE_OPENAI_API_KEY: ${{SECRET_AZURE_OPENAI_API_KEY}} + AZURE_OPENAI_ENDPOINT: ${{AZURE_OPENAI_ENDPOINT}} + AZURE_OPENAI_DEPLOYMENT_NAME: ${{AZURE_OPENAI_DEPLOYMENT_NAME}} + {{/useAzureOpenAI}} \ No newline at end of file diff --git a/templates/vsc/ts/weather-agent/env/.env.sandbox b/templates/vsc/ts/weather-agent/env/.env.sandbox new file mode 100644 index 00000000000..ef9112181da --- /dev/null +++ b/templates/vsc/ts/weather-agent/env/.env.sandbox @@ -0,0 +1,11 @@ +# This file includes environment variables that can be committed to git. It's gitignored by default because it represents your sandbox development environment. + +# Built-in environment variables +TEAMSFX_ENV=sandbox +APP_NAME_SUFFIX=sandbox + +# Generated during provision, you can also add your own variables. +BOT_ID= +TEAMS_APP_ID= +BOT_DOMAIN= +BOT_ENDPOINT= diff --git a/templates/vsc/ts/weather-agent/m365agents.sandbox.yml.tpl b/templates/vsc/ts/weather-agent/m365agents.sandbox.yml.tpl index f915939fd6f..3cfa8a04fed 100644 --- a/templates/vsc/ts/weather-agent/m365agents.sandbox.yml.tpl +++ b/templates/vsc/ts/weather-agent/m365agents.sandbox.yml.tpl @@ -90,15 +90,6 @@ provision: appId: M365_APP_ID deploy: -{{#SandBoxedTeam}} - # Sideload app in sandboxed team. - - uses: devChannel/installApp - with: - teamId: ${{TEAM_ID}} - channelId: ${{CHANNEL_ID}} - appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip -{{/SandBoxedTeam}} - # Run npm command - uses: cli/runNpmCommand name: install dependencies @@ -110,9 +101,8 @@ deploy: with: target: ./.localConfigs envs: - BOT_ID: ${{BOT_ID}} - BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}} - BOT_TYPE: 'MultiTenant' + clientId: ${{BOT_ID}} + clientSecret: ${{SECRET_BOT_PASSWORD}} {{#useOpenAI}} OPENAI_API_KEY: ${{SECRET_OPENAI_API_KEY}} {{/useOpenAI}}