This is a sample notification app for demonstrating reuse existing resources for app deployment.
Customers don't have the permission to provision resources in a target Azure environment and M365 tenant (e.g. a prod
environment), but they still want to deploy the app against the pre-provisioned resources.
So the toolkit should allow customers to skip provisioning all resources for a remote environment, including
- Teams app registration
- Bot service (including the bot AAD app)
- Bot web app
And generate a state file for deployment.
- All azure resources are already provisioned and correctly configured in an existing subscription and resource group.
- The AAD app and Teams app are already provisioned in the target M365 tenant.
- Customers have the permission to deploy to the existing web app.
- If you don't really need to do the provision at all you can simply go for solution 1.
- If you may need our toolkit to provision some of the resources, for example, some resources need to be reused, some need to be provisioned by our tools, then you can go to solution 2 for bicep customization.
Manually create the state.<env>.json
and provide necessary information for app deployment/preview contract.
-
Create a new environment (e.g. a
prod
environment) for integration with pre-provisioned resources (including Teams app registration, Bot service, Bot Web app) -
Add a
state.prod.json
file in the.fx\states
folder, and add the following config for app deployment and preview.- the
solution
andfx-resource-bot
is the deployment contract for bot. - The
fx-resource-appstudio
contains the Teams app registration info which can be used for app preview.
{ "solution": { "subscriptionId": "<Your Azure subscription ID>", "resourceGroupName": "<Your resource group name>", "provisionSucceeded": true }, "fx-resource-appstudio": { "tenantId": "<Your M365 tenant ID>", "teamsAppId": "<Your Teams App ID>" }, "fx-resource-bot": { "botWebAppResourceId": "<Your bot web app resource ID, e.g. /subscriptions/mysub/resourceGroups/myrg/providers/Microsoft.Web/sites/mywebapp>", "siteEndpoint": "<The site endpoint of your bot web app>" } }
- the
-
Run
Teams: Deploy to the cloud
to deploy the app code to theprod
environment. -
Open the debug panel (
Ctrl+Shift+D
/⌘⇧-D
orView > Run
) from Visual Studio Code, selectLaunch Remote (Edge)
orLaunch Remote (Chrome)
to preview your remote app.
Customize the environment config files and BICEP template to let toolkit automatically generate the state.<env-name>.json
for deployment.
You can refer to this commit related code change.
-
Create a new environment (e.g. a
prod
environment) for integration with pre-provisioned resources (including Teams app registration, Bot service, Bot Web app) -
Set your bot password in environment variable, e.g.
BOT_PASSWORD_PROD
. -
Modify
config.prod.json
to include the following section:"azure": { "subscriptionId": "<Your existing subscription id>", "resourceGroupName": "<Your existing resource group name>" }, "bot": { "appId": "<Your existing app id for your bot service>", "appPassword": "{{$env.BOT_PASSWORD_PROD}}" }
-
Modify the
azure.parameters.prod.json
to include the following content for your existing bot service and bot app:"existingSubscription": "<Your existing subscription id>", "existingResourceGroup": "<Your existing resource group name>", "botServerfarmsName": "<The service plan of your existing bot app>", "botWebAppSKU": "<The SKU of your existing bot web app>", "botSitesName": "<The app name of your existing bot web app>", "botServiceName": "<The existing bot service name>"
-
Modify the bicep template in
templates\azure
folder:main.bicep
: comment out or remove theteamsFxConfig
section since we assume that the existing bot app is correctly configured.provision.bicep
: comment out or remove theuserAssignedIdentityProvision
section to skip creating user-assigned identity for the bot app.provision\bot.bicep
: re-sue existing resource for bot service and bot web app.
Please refer to this commit related code change or just copy-paste those files.
-
Manually add a
state.prod.json
file in the.fx\states
folder, and add the following config for your existing Teams app info."fx-resource-appstudio": { "tenantId": "<Your M365 tenant id where your app has been registered>", "teamsAppId": "<Your Teams App ID>" }
Note: this is a workaround since current toolkit is not able to configure the existing Teams App info through
config.<env-name>.json
.
-
Run
Teams: Provision in the cloud
against theprod
environment to generate resource info instate.prod.json
. In this step -
Run
Teams: Deploy to the cloud
to deploy the app code to theprod
environment. -
Open the debug panel (
Ctrl+Shift+D
/⌘⇧-D
orView > Run
) from Visual Studio Code, selectLaunch Remote (Edge)
orLaunch Remote (Chrome)
to preview your remote app.
- Toolkit should be able to skip provision Teams app registration by customizing the env config file (e.g.
config.prod.json
). - More explicit contract for Teams app deployment. The app deployment should not depends on the whole
state.<env-name>.json
, ideally it only requires user to provide the web app's info for the bot code deployment. - More explicit contract for integration with existing resources.