page_type | languages | products | name | urlFragment | description | extensions | ||||
---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
Containerized Bot App with SSO Enabled |
officedev-teamsfx-samples-bot-sso-docker |
A containerized Microsoft Teams Bot app with SSO |
|
A bot, chatbot, or conversational bot is an app that responds to simple commands sent in chat and replies in meaningful ways. Examples of bots in everyday use include: bots that notify about build failures, bots that provide information about the weather or bus schedules, or provide travel information. A bot interaction can be a quick question and answer, or it can be a complex conversation. Being a cloud application, a bot can provide valuable and secure access to cloud services and corporate resources.
This is a sample chatbot application running in Docker container. It demonstrates Single Sign-on using botbuilder
and Teams Framework that can respond to a show
message.
- Use Teams Toolkit to create a Teams bot app.
- Use Microsoft Graph to get User info and picture in Teams app.
- Use TeamsFx SDK to implementing SSO for Teams bot.
- Use Docker to containerize a Teams bot.
- Docker Engine
- A Microsoft 365 tenant in which you have permission to upload Teams apps. You can get a free Microsoft 365 developer tenant by joining the Microsoft 365 developer program.
- Teams Toolkit Visual Studio Code Extension version 5.0.0 and higher or Teams Toolkit CLI
- Azure CLI for Azure Container Apps deployment
Teams applications can be developed and run locally using containerization, which provides a consistent and isolated environment for testing and deployment. Containerizing your Teams app makes it easier to manage dependencies, scale efficiently, and maintain your app in production. Below are steps and references to help you containerize your Teams app.
This sample demonstrate how to containerize a Teams App and integrate the Docker container into Teams Toolkit development lifecycle, which can serve as reference for your containerization process.
-
Write a Dockerfile: Create a Dockerfile that specifies the build instructions for your container image. Refer to this Dockerfile example
-
Configure Debugging: Configure
launch.json
andtasks.json
to run Docker locally for debugging. Refer to this VS Code launch.json example and VS Code tasks.json example -
Provision Infrastructure: Automate the provisioning of Azure Container Apps and Azure Container Registry using Bicep templates. Refer to this Azure Bicep example.
-
Build and Deploy to ACA: Using Azure CLI, build and push the Docker image to Azure Container Registry, then deploy it to Azure Container Apps. Refer to the deployment scripts in this teamsapp.yml example.
- From VS Code:
- hit
F5
to start debugging. Alternatively open theRun and Debug Activity
Panel and selectDebug (Edge)
orDebug (Chrome)
.
- hit
- From Teams Toolkit CLI:
- Install dev tunnel cli.
- Login with your M365 Account using the command
devtunnel user login
. - Start your local tunnel service by running the command
devtunnel host -p 3978 --protocol http --allow-anonymous
. - In the
env/.env.local
file, fill in the values forBOT_DOMAIN
andBOT_ENDPOINT
with your dev tunnel URL.BOT_DOMAIN=sample-id-3978.devtunnels.ms BOT_ENDPOINT=https://sample-id-3978.devtunnels.ms
- Run command:
teamsapp provision --env local
. - Run command:
docker build -t sso-bot ./
. - Run command:
docker run -p 3978:80 --env-file .localConfigs sso-bot
. - Run command:
teamsapp preview --open-only
.
- From VS Code:
- Sign into Azure by clicking the
Sign in to Azure
under theACCOUNTS
section from sidebar. - Click
Provision
fromLIFECYCLE
section or open the command palette and select:Teams: Provision
. - Login Azure CLI with commands:
az login
andaz account set -s <subscription-id>
. - Click
Deploy
or open the command palette and select:Teams: Deploy
.
- Sign into Azure by clicking the
- From Teams Toolkit CLI:
- Run command:
teamsapp account login azure
. - Run command:
teamsapp provision --env dev
. - Run command:
az login
. - Run command:
teamsapp deploy --env dev
.
- Run command:
- From VS Code:
- Open the
Run and Debug Activity
Panel. SelectLaunch Remote (Edge)
orLaunch Remote (Chrome)
from the launch configuration drop-down.
- Open the
- From Teams Toolkit CLI:
- Run command:
teamsapp preview --env dev
.
- Run command:
Date | Author | Comments |
---|---|---|
Jan 17, 2024 | hund030 | Onboard sample in Teams Toolkit V5.0.0 |
We really appreciate your feedback! If you encounter any issue or error, please report issues to us following the Supporting Guide. Meanwhile you can make recording of your journey with our product, they really make the product better. Thank you!