page_type | languages | products | name | urlFragment | description | extensions | ||||
---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
Containerized Tab App with Azure Backend |
officedev-teamsfx-samples-tab-hello-world-tab-docker |
A containerized Hello World app of Microsoft Teams Tab app which has a backend service. |
|
Microsoft Teams supports the ability to run web-based UI inside "custom tabs" that users can install either for just themselves (personal tabs) or within a team or group chat context.
Hello World Tab with Backend shows you how to build a tab app with an Azure Function as backend, how to get user login information with SSO and how to call Azure Function from frontend tab.
Note: This sample will only provision single tenant Azure Active Directory app. For multi-tenant support, please refer to this wiki.
- How to use Teams Toolkit to create a Teams tab app.
- How to use TeamsFx SDK to call Azure Functions.
- How to use TeamsFx SDK in Azure Function to call Graph to get user info.
- How to develop Teams tab app in Docker.
- Docker Engine
- A Microsoft 365 account. If you do not have Microsoft 365 account, apply one from 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
-
This sample has adopted On-Behalf-Of Flow to implement SSO.
-
This sample uses Azure Function as middle-tier service, and make authenticated requests to call Graph from Azure Function.
-
Due to system webview limitations, users in the tenant with conditional access policies applied cannot consent permissions when conduct an OAuth flow within the Teams mobile clients, it would show error: "xxx requires you to secure this device...".
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
-
Write a Compose File: Create a Docker Compose file that defines the services, networks and volumes, expecially when there are multiple containers. Refer to this Docker Compose file 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 in Teams (Edge)
orDebug in Teams (Chrome)
.
- hit
-
From Teams Toolkit CLI:
- Run command:
teamsapp provision --env local
. - Run command:
docker compose -f ./docker-compose.yml up -d
. - Run command:
teamsapp preview --open-only
.
- Run command:
-
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 auth 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 |
---|---|---|
Feb 27, 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!