Share Now
Share Now promotes the exchange of information between colleagues by enabling users to share content within the Teams environment. Users engage the app to share items of interest and discover new shared content.
Note: This sample will only provision single tenant Azure Active Directory app. For multi-tenant support, please refer to this wiki.
This sample illustrates
- How to build frontend hosting on Azure for your tab app.
- How to build backend hosting on Azure for your tab app.
- How to build message extension bot on Azure for your app.
- How to connect to Azure SQL DB and how to do CRUD operations in DB.
Prerequisite
- Node.js, supported versions: 16, 18
- 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 TeamsFx CLI
- An Azure subscription
Minimal path to awesome
Deploy the app to Azure
Here are the instructions to run the sample in Visual Studio Code. You can also try to run the app using TeamsFx CLI tool, refer to Try the Sample with TeamsFx CLI
- Clone the repo to your local workspace or directly download the source code.
- Open the project in Visual Studio Code.
- Open env/.env.dev.user file, set value for
SQL_USER_NAME
andSQL_PASSWORD
. - Open the command palette and select:
Teams: Provision
. The toolkit will help you to provision Azure SQL. - Once provision is completed, open the command palette and select:
Teams: Deploy
. - Open env/.env.dev file, you could get the database name in
PROVISIONOUTPUT__AZURESQLOUTPUT__DATABASENAME
output. Set IP address of your computer into server-level IP firewall rule from the database overview page. - In Azure portal, find the database by
databaseName
and use query editor with below query to create a table:CREATE TABLE [TeamPostEntity]( [PostID] [int] PRIMARY KEY IDENTITY, [ContentUrl] [nvarchar](400) NOT NULL, [CreatedByName] [nvarchar](50) NOT NULL, [CreatedDate] [datetime] NOT NULL, [Description] [nvarchar](500) NOT NULL, [IsRemoved] [bit] NOT NULL, [Tags] [nvarchar](100) NULL, [Title] [nvarchar](100) NOT NULL, [TotalVotes] [int] NOT NULL, [Type] [int] NOT NULL, [UpdatedDate] [datetime] NOT NULL, [UserID] [uniqueidentifier] NOT NULL, ) GO CREATE TABLE [UserVoteEntity]( [VoteID] [int] PRIMARY KEY IDENTITY, [PostID] [int] NOT NULL, [UserID] [uniqueidentifier] NOT NULL, ) GO
Launch the app in Teams
Once deployment is completed, you can preview the app running in Azure. In Visual Studio Code, open
Run and Debug
and selectLaunch Remote (Edge)
orLaunch Remote (Chrome)
in the dropdown list and PressF5
or green arrow button to open a browser.The app will look like this when it runs for the first time:
You can add new content by clicking "Suggest content" button.
You can update content created by you by clicking "..." and then choose "update" button.
You can delete content created by you by clicking "..." and then choose "delete" button.
You can add/delete your vote for the content by click the icon in the content.
You can search all/posted-by-me contents in compose box or command box by filtering based on title or tags of content and share with your colleagues.
(Optional) Run the app locally
To debug the project, you will need to configure an Azure SQL Database to be used locally:
- Create an Azure SQL Database
- Add IP address of your computer into allowlist of firewall of Azure SQL Server
- Use query editor with below query to create tables:
CREATE TABLE [TeamPostEntity]( [PostID] [int] PRIMARY KEY IDENTITY, [ContentUrl] [nvarchar](400) NOT NULL, [CreatedByName] [nvarchar](50) NOT NULL, [CreatedDate] [datetime] NOT NULL, [Description] [nvarchar](500) NOT NULL, [IsRemoved] [bit] NOT NULL, [Tags] [nvarchar](100) NULL, [Title] [nvarchar](100) NOT NULL, [TotalVotes] [int] NOT NULL, [Type] [int] NOT NULL, [UpdatedDate] [datetime] NOT NULL, [UserID] [uniqueidentifier] NOT NULL, ) GO CREATE TABLE [UserVoteEntity]( [VoteID] [int] PRIMARY KEY IDENTITY, [PostID] [int] NOT NULL, [UserID] [uniqueidentifier] NOT NULL, ) GO
- Open env/.env.local file, and set the values of below config with the Azure SQL Database you just created:
SQL_ENDPOINT= SQL_DATABASE_NAME=
- Open env/.env.local.user file, and set the values of below config with the Azure SQL Database you just created:
SQL_USER_NAME= SQL_PASSWORD=
- Open Debug View (
Ctrl+Shift+D
) and select "Debug in Teams (Edge)" or "Debug in Teams (Chrome)" in dropdown list. - Press "F5" to open a browser window and then select your package to view share now sample app.
Version History
Date | Author | Comments |
---|---|---|
May 13 2021 | xzf0587 | onboard |
May 18, 2022 | xzf0587 | update to support Teams Toolkit v4.0.0 |
Apr 3, 2023 | xzf0587 | update to support Teams Toolkit v5.0.0 |
Feedback
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!