page_type | description | products | languages | extensions | contentType | createdDate | ||||
---|---|---|---|---|---|---|---|---|---|---|
sample |
This sample illustrates how you programmatically manage lifecycle for your teams App in catalog by calling Microsoft Graph APIs. . |
|
|
samples |
07-07-2021 13:38:26 |
Bot Framework v4 AppCatalog sample.
This sample shows a AppCatalog bot and demonstrates teamsApp lifecycle in catalog followed by commands given to Bot.
- Microsoft Teams is installed and you have an account
- .NET Core SDK version 3.1
- ngrok or equivalent tunnelling solution
-
Clone the repository
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
B) Or from Visual Studio code
- Launch Visual Studio code
- File -> Open Folder
- Navigate to
samples/graph-appcatalog-lifecycle/node
folder - Select
AppCatalogSample
folder - Press
F5
to run the project
C) Run ngrok - point to port 3978
```bash
ngrok http -host-header=rewrite 3978
```
Register one Azure AD application in your tenant's directory: for the bot and tab app authentication.
-
Log in to the Azure portal from your subscription, and go to the "App registrations" blade here. Ensure that you use a tenant where admin consent for API permissions can be provided.
-
Click on "New registration", and create an Azure AD application.
-
Name: The name of your Teams app - if you are following the template for a default deployment, we recommend "App catalog lifecycle".
-
Supported account types: Select "Accounts in any organizational directory"
-
Leave the "Redirect URL" field blank.
-
Click on the "Register" button.
-
When the app is registered, you'll be taken to the app's "Overview" page. Copy the Application (client) ID; we will need it later. Verify that the "Supported account types" is set to Multiple organizations.
-
On the side rail in the Manage section, navigate to the "Certificates & secrets" section. In the Client secrets section, click on "+ New client secret". Add a description for the secret and select Expires as "Never". Click "Add".
-
Once the client secret is created, copy its Value, please take a note of the secret as it will be required later.
At this point you have 3 unique values:
- Application (client) ID which will be later used during Azure bot creation
- Client secret for the bot which will be later used during Azure bot creation
- Directory (tenant) ID
We recommend that you copy these values into a text file, using an application like Notepad. We will need these values later.
-
Under left menu, select Authentication under Manage section.
-
Select 'Accounts in any organizational directory (Any Azure AD directory - Multitenant)' under Supported account types and click "+Add a platform".
-
On the flyout menu, Select "Web"
-
Add
https://token.botframework.com/.auth/web/redirect
under Redirect URLs and click Configure button. -
Once the flyout menu close, scroll bottom to section 'Implicit Grant' and select check boxes "Access tokens" and "ID tokens" and click "Save" at the top bar.
-
Under left menu, navigate to API Permissions, and make sure to add the following permissions of Microsoft Graph API > Delegated permissions:
- AppCatalog.ReadWrite.All
- AppCatalog.Submit
Click on “Add Permissions” to commit your changes.
-
If you are logged in as the Global Administrator, click on the “Grant admin consent for %tenant-name%” button to grant admin consent else, inform your admin to do the same through the portal or follow the steps provided here to create a link and send it to your admin for consent.
-
Global Administrator can grant consent using following link: https://login.microsoftonline.com/common/adminconsent?client_id=<%appId%>
- Create new Azure Bot resource in Azure.
- Select Type of App as "Multi Tenant"
- Select Creation type as "Use existing app registration"
- Use the copied App Id and Client secret from above step and fill in App Id and App secret respectively.
- Click on Create on the Azure bot.
- Go to the created resource, navigate to channels and add "Microsoft Teams".
-
In the Azure portal, select your resource group from the dashboard.
-
Select your bot channel registration link.
-
Open the resource page and select Configuration under Settings.
-
Select Add OAuth Connection Settings.
-
Complete the form as follows:
a. Name: Enter a name for the connection. You'll use this name in your bot in the appsettings.json file. For example BotTeamsAuthADv1.
b. Service Provider: Select Azure Active Directory. Once you select this, the Azure AD-specific fields will be displayed.
c. Client id: Enter the Application (client) ID that you recorded for your Azure identity provider app in the steps above.
d. Client secret: Enter the secret that you recorded for your Azure identity provider app in the steps above.
e. Grant Type: Enter authorization_code.
f. Login URL: Enter https://login.microsoftonline.com.
g. Tenant ID: enter the Directory (tenant) ID that you recorded earlier for your Azure identity app or common depending on the supported account type selected when you created the identity provider app. h. For Resource URL, enter https://graph.microsoft.com/ i. Provide Scopes like "AppCatalog.Submit, AppCatalog.Read.All, AppCatalog.ReadWrite.All, Directory.Read.All, Directory.ReadWrite.All"
- Ensure that you've enabled the Teams Channel
- List all applications specific to the tenant : type "listapp" in chat and get all the app available in the same tenant.
- List applications with a given ID : type "app" in the chat and get deatils of app according to their appId.
- Find application based on the Teams app manifest ID : type "findapp" in the chat and get deatils of app according to their manifest Id.:
- List applications with a given ID, and return the submission review state: type "status" in the chat and get deatils of app either published or not.
- List the details of only those apps in the catalog that contain a bot: type "bot" in the chat and get deatils of available bot in appcatalog.
- type "publish" and upload the mainfest.zip of the teamsApp and app uploaded to appcatalog.
- type "update" and upload the mainfest.zip of the teamsApp and app updated to appcatalog against of the app id.