I'm having problems deploying the application via toolkit, error appears -> Cannot redefine property: stack
stack: UnhandledError: Cannot redefine property: stack at getError (<REDACTED: user-file-path>:14:5819447) at Object.wrapRun (<REDACTED: user-file-path>:14:5819625) at processTicksAndRejections (node:<REDACTED: user-file-path>:95:5) at ArmDeployDriver.execute (<REDACTED: user-file-path>:14:5553122) at Lifecycle.executeImpl (<REDACTED: user-file-path>:14:5427203) at Lifecycle.execute (<REDACTED: user-file-path>:14:5424360) at Coordinator.provision (<REDACTED: user-file-path>:14:5470516) at Coordinator. (<REDACTED: user-file-path>:14:6119329) at FxCore.provisionResources (<REDACTED: user-file-path>:14:6047609) at FxCore.exports.EnvWriterMW (<REDACTED: user-file-path>:14:5958667) at FxCore.exports.ContextInjectorMW (<REDACTED: user-file-path>:14:6123081) at FxCore.exports.ConcurrentLockerMW (<REDACTED: user-file-path>:14:6122032) at envLoaderMWImpl (<REDACTED: user-file-path>:14:5958547) at FxCore. (<REDACTED: user-file-path>:14:5957475) at FxCore.exports.ProjectMigratorMWV3 (<REDACTED: user-file-path>:14:6153660) at FxCore.exports.ErrorHandlerMW (<REDACTED: user-file-path>:14:6123578) at FxCore. (<REDACTED: user-file-path>:14:6119329)
azure.bicep:
@maxLength(20)
@minLength(4)
param resourceBaseName string
param storageSku string
@description('Required when create Azure Bot service')
param botAadAppClientId string
@secure()
@description('Required by Bot Framework package in your bot project')
param botAadAppClientSecret string
param webAppSKU string
@maxLength(42)
param botDisplayName string
param serverfarmsName string = resourceBaseName
param webAppName string = resourceBaseName
param storageName string = resourceBaseName
param location string = resourceGroup().location
param microsoftAppTenantId string
param tabDomain string
// Azure Storage that hosts your static web site
resource storage 'Microsoft.Storage/storageAccounts@2021-06-01' = {
kind: 'StorageV2'
location: location
name: storageName
properties: {
supportsHttpsTrafficOnly: true
}
sku: {
name: storageSku
}
}
// Compute resources for your Web App
resource serverfarm 'Microsoft.Web/serverfarms@2021-02-01' = {
kind: 'app'
location: location
name: serverfarmsName
sku: {
name: webAppSKU
}
}
// Web App that hosts your bot
resource webApp 'Microsoft.Web/sites@2021-02-01' = {
kind: 'app'
location: location
name: webAppName
properties: {
serverFarmId: serverfarm.id
httpsOnly: true
siteConfig: {
alwaysOn: false
appSettings: [
{
name: 'WEBSITE_RUN_FROM_PACKAGE'
value: '1' // Run Azure APP Service from a package file
}
{
name: 'WEBSITE_NODE_DEFAULT_VERSION'
value: '~18' // Set NodeJS version to 18.x for your site
}
{
name: 'RUNNING_ON_AZURE'
value: '1'
}
{
name: 'BOT_ID'
value: botAadAppClientId
}
{
name: 'BOT_PASSWORD'
value: botAadAppClientSecret
}
]
ftpsState: 'FtpsOnly'
}
}
}
// Register your web service as a bot with the Bot Framework
module azureBotRegistration './botRegistration/azurebot.bicep' = {
name: 'Azure-Bot-registration'
params: {
resourceBaseName: resourceBaseName
botAadAppClientId: botAadAppClientId
botAppDomain: webApp.properties.defaultHostName
botDisplayName: botDisplayName
microsoftAppTenantId: microsoftAppTenantId
botAadAppClientSecret: botAadAppClientSecret
tabDomain: tabDomain
}
}
var siteDomain = replace(replace(storage.properties.primaryEndpoints.web, 'https://', ''), '/', '')
// The output will be persisted in .env.{envName}. Visit https://aka.ms/teamsfx-actions/arm-deploy for more details.
output TAB_AZURE_STORAGE_RESOURCE_ID string = storage.id // used in deploy stage
output TAB_DOMAIN string = siteDomain
output TAB_ENDPOINT string = 'https://${siteDomain}'
output BOT_AZURE_APP_SERVICE_RESOURCE_ID string = webApp.id
output BOT_DOMAIN string = webApp.properties.defaultHostName
azurebot.bicep:
@maxLength(20)
@minLength(4)
@description('Used to generate names for all resources in this file')
param resourceBaseName string
@maxLength(42)
param botDisplayName string
param botServiceName string = resourceBaseName
param botServiceSku string = 'F0'
param botAadAppClientId string
param botAppDomain string
param microsoftAppTenantId string
param tabDomain string
@secure()
@description('Required by Bot Framework package in your bot project')
param botAadAppClientSecret string
// Register your web service as a bot with the Bot Framework
resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
kind: 'azurebot'
location: 'global'
name: botServiceName
properties: {
displayName: botDisplayName
endpoint: 'https://${botAppDomain}/api/messages'
msaAppId: botAadAppClientId
}
sku: {
name: botServiceSku
}
}
// Connect the bot service to Microsoft Teams
resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2021-03-01' = {
parent: botService
location: 'global'
name: 'MsTeamsChannel'
properties: {
channelName: 'MsTeamsChannel'
}
}
resource botServiceConnection 'Microsoft.BotService/botServices/connections@2021-03-01' = {
parent: botService
name: 'conntectorGraph'
location: 'global'
properties: {
serviceProviderDisplayName: 'Azure Active Directory v2'
serviceProviderId: '30dd229c-58e3-4a48-bdfd-91ec48eb906c'
scopes: 'User.Read'
parameters: [
{
key: 'clientId'
value: botAadAppClientId
}
{
key: 'clientSecret'
value: botAadAppClientSecret
}
{
key: 'tenantID'
value: microsoftAppTenantId
}
{
key: 'tokenExchangeUrl'
value: 'api://${tabDomain}/botid-${botAadAppClientId}'
}
]
}
}
output CONNECTION_NAME string = botServiceConnection.name
azure.parameters.json:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceBaseName": {
"value": "tab${{RESOURCE_SUFFIX}}"
},
"storageSku": {
"value": "Standard_LRS"
},
"botAadAppClientId": {
"value": "${{BOT_ID}}"
},
"botAadAppClientSecret": {
"value": "${{SECRET_BOT_PASSWORD}}"
},
"webAppSKU": {
"value": "F1"
},
"botDisplayName": {
"value": "BOT"
},
"microsoftAppTenantId": {
"value": "${{AAD_APP_TENANT_ID}}"
},
"tabDomain": {
"value": "${{TAB_DOMAIN}}"
},
"botAppDomain": {
"value": "${{BOT_DOMAIN}}"
}
}
}
teamsapp.local.yml:
version: v1.2
additionalMetadata:
sampleTag: TeamsFx:msg-ext-with-tab
environmentFolderPath: ./env
provision:
- uses: teamsApp/create
with:
name: MS_TEAMS_TAB_MSGEXT_local
writeToEnvironmentFile:
teamsAppId: TEAMS_APP_ID
- uses: aadApp/create
with:
name: MS_TEAMS_TAB_MSGEXT_local
generateClientSecret: true
signInAudience: 'AzureADMyOrg'
writeToEnvironmentFile:
clientId: AAD_APP_CLIENT_ID
clientSecret: SECRET_AAD_APP_CLIENT_SECRET
objectId: AAD_APP_OBJECT_ID
tenantId: AAD_APP_TENANT_ID
authority: AAD_APP_OAUTH_AUTHORITY
authorityHost: AAD_APP_OAUTH_AUTHORITY_HOST
- uses: aadApp/update
with:
manifestPath: './aad.manifest.json'
outputFilePath: ./build/aad.manifest.${{TEAMSFX_ENV}}.json
- uses: botAadApp/create
with:
name: BOT-${{TEAMSFX_ENV}}
writeToEnvironmentFile:
botId: BOT_ID
botPassword: SECRET_BOT_PASSWORD
- uses: arm/deploy
with:
subscriptionId: ${{AZURE_SUBSCRIPTION_ID}}
resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}}
templates:
- path: ./infra/azure.bicep
parameters: ./infra/azure.parameters.json
deploymentName: Create-resources-for-tab
bicepCliVersion: v0.9.1
- uses: script
with:
run: echo "::set-teamsfx-env TAB_DOMAIN=localhost:53000";
echo "::set-teamsfx-env TAB_ENDPOINT=https://localhost:53000";
- uses: teamsApp/validateManifest
with:
manifestPath: ./appPackage/manifest.json
- uses: teamsApp/zipAppPackage
with:
manifestPath: ./appPackage/manifest.json
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
outputJsonPath: ./appPackage/build/manifest.${{TEAMSFX_ENV}}.json
- uses: teamsApp/validateAppPackage
with:
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
- uses: teamsApp/update
with:
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
deploy:
- uses: devTool/install
with:
devCert:
trust: true
writeToEnvironmentFile:
sslCertFile: SSL_CRT_FILE
sslKeyFile: SSL_KEY_FILE
- uses: file/createOrUpdateEnvironmentFile
with:
target: ./tab/.localConfigs
envs:
BROWSER: none
HTTPS: true
PORT: 53000
SSL_CRT_FILE: ${{SSL_CRT_FILE}}
SSL_KEY_FILE: ${{SSL_KEY_FILE}}
REACT_APP_CLIENT_ID: ${{AAD_APP_CLIENT_ID}}
REACT_APP_TENANT_ID: ${{AAD_APP_TENANT_ID}}
REACT_APP_TAB_ENDPOINT: ${{TAB_ENDPOINT}}
REACT_APP_START_LOGIN_PAGE_URL: ${{TAB_ENDPOINT}}/auth-start.html
- uses: file/createOrUpdateEnvironmentFile
with:
target: ./bot/.localConfigs
envs:
BOT_ID: ${{BOT_ID}}
BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}}
projectId: xxxxxxxxxxxxxxxxxxxx
How to fix it? what am I doing wrong?
It is an inner bug for Teams Toolkit and has been fixed in the pre-release version.
You can try to Switch to the pre-release version in VSCode extension. Or as this bug is triggered by azure deployment error(expected to show the deployment error to user, but blocked by the inner error), you can try to find the error deployment error in the resource group. Refer to this. If the deployment error is solved, the error will not be triggered.