-
Notifications
You must be signed in to change notification settings - Fork 189
Add app settings
This section describes the built-in app setting support by Teams Toolkit. You're free to use other approaches to configure your app settings.
In this document, you will learn:
- How to add app settings to bot / message extension hosted on Azure Web App
- How to add app settings to api hosted on Azure Functions
- How to add app settings for local debugging
- How to find app settings predefined by Teams Toolkit
- Understand how Teams Toolkit handles app setting for you
If you use Azure to host your application, you can declare your app settings for your Azure services via ARM template. We suggest you go through this document to gain deeper understanding about the provision behavior of Teams Toolkit as well as how to customize the ARM template in the project.
You can follow these steps to add app settings to the Azure Web App that hosts your bot:
- Open
{your_project_root}/.fx/configs/azure.parameters.{env}.json
- Add new properties to the value of provisionParameters, which will be available during provision. Here is an example:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "provisionParameters": { "value": { ... "valueOfMyAppSettingToBeAdded": "actual app setting value" } } } }
Note: You can reference environment variable when setting the value. Visit this document for more details.
- Open
{your_project_root}/templates/azure/provision/bot.bicep
- Find the
webApp
resource declaration in the file, the resource looks like this:resource webApp 'Microsoft.Web/sites@2021-02-01'
- Declare your app settings in the app settings property, and set the values your defined in parameter file to them. Here is an example:
resource webApp 'Microsoft.Web/sites@2021-02-01' = { kind: 'app' location: resourceGroup().location name: webAppName properties: { siteConfig: { appSettings: [ ... { name: 'MY_APP_SETTING_NAME' value: provisionParameters.valueOfMyAppSettingToBeAdded // the value comes from parameter file } ] } } }
- Run
Teams: Provision in the cloud
command to apply your changes to Azure
You can follow these steps to add app settings to the Azure Web App that hosts your bot:
- Open
{your_project_root}/.fx/configs/azure.parameters.{env}.json
- Add new properties to the value of provisionParameters, which will be available during provision. Here is an example:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "provisionParameters": { "value": { ... "valueOfMyAppSettingToBeAdded": "actual app setting value" } } } }
Note: You can reference environment variable when setting the value. Visit this document for more details.
- Open
{your_project_root}/templates/azure/provision/function.bicep
- Find the
functionApp
resource declaration in the file, the resource looks like this:resource functionApp 'Microsoft.Web/sites@2021-02-01'
- Declare your app settings in the app settings property, and set the values your defined in parameter file to them. Here is an example:
resource functionApp 'Microsoft.Web/sites@2021-02-01' = { kind: 'functionapp' location: resourceGroup().location name: functionAppName properties: { siteConfig: { appSettings: [ ... { name: 'MY_APP_SETTING_NAME' value: provisionParameters.valueOfMyAppSettingToBeAdded // the value comes from parameter file } ] } } }
- Run
Teams: Provision in the cloud
command to apply your changes to Azure
Each project (tab / bot / api) has .env.teamsfx.local
file in the root that defines environment variables available during local debugging. You can follow the syntax of dotenv package to add customized environment variables to it. If .env.teamsfx.local
file does not exist, you can create an empty file and modify it.
For example, to add CUSTOM_APP_SETTING
to your bot project, you can edit bot/.env.teamsfx.local
file and add following content to it:
CUSTOM_APP_SETTING=my_app_setting_value
Teams toolkit will define necessary app settings for your Teams app. You can refer following table to learn where to find the predefined app settings:
Project | Predefined app settings for Azure (via bicep) | Predefined app settings for local debugging (via dotenv) |
---|---|---|
tab | N/A | tabs/.env.teamsfx.local |
bot | templates/azure/teamsfx/bot.bicep | bot/.env.teamsfx.local |
api | templates/azure/teamsfx/function.bicep | api/.env.teamsfx.local |
Note: the .env.teamsfx.local is generated during local debugging. You need to local debug first to see this file.
When Teams Toolkit starts your app locally, it will read the .env.teamsfx.local
file under tab/api/bot folder and add environment variables defined in the file to your app process. There is no need to use packages like dotenv to read the file content in your app.
The Azure Web App and Azure Functions used to host your Teams app has configuration support. It will make all the configurations available as environment variables in your app. Teams Toolkit uses ARM template to update the service configurations. You can refer above tutorials to add your own app settings via ARM template too.
Teams Toolkit gives you ability to manage multiple environments. You can learn more about the multiple environment feature at here.
Here is an example about where to define different app setting values for different environment. Imaging you have 3 environments: local
, dev
, prod
, you need to add your app setting values to following files for each environment:
Environment | File to modify |
---|---|
local | .env.teamsfx.local under tab/api/bot folder |
dev (hosted on Azure) | .fx/configs/azure.parameters.dev.json |
prod (hosted on Azure) | .fx/configs/azure.parameters.prod.json |
Note: the
azure.parameters.{env}.json
file is consumed by ARM template undertemplates/azure
folder. You need to update the ARM template to reference the values in parameter file first before adding values to the parameter file. You can refer the tutorials at the beginning of this page to understand how to add an extra app settings.
Build Custom Engine Copilots
- Build a basic AI chatbot for Teams
- Build an AI agent chatbot for Teams
- Expand AI bot's knowledge with your content
Scenario-based Tutorials
- Send notifications to Teams
- Respond to chat commands in Teams
- Respond to card actions in Teams
- Embed a dashboard canvas in Teams
Extend your app across Microsoft 365
- Teams tabs in Microsoft 365 and Outlook
- Teams message extension for Outlook
- Add Outlook Add-in to a Teams app
App settings and Microsoft Entra Apps
- Manage Application settings with Teams Toolkit
- Manage Microsoft Entra Application Registration with Teams Toolkit
- Use an existing Microsoft Entra app
- Use a multi-tenant Microsoft Entra app
Configure multiple capabilities
- How to configure Tab capability within your Teams app
- How to configure Bot capability within your Teams app
- How to configure Message Extension capability within your Teams app
Add Authentication to your app
- How to add single sign on in Teams Toolkit for Visual Studio Code
- How to enable Single Sign-on in Teams Toolkit for Visual Studio
Connect to cloud resources
- How to integrate Azure Functions with your Teams app
- How to integrate Azure API Management
- Integrate with Azure SQL Database
- Integrate with Azure Key Vault
Deploy apps to production