OfficeDev / TeamsFx

Developer tools for building Teams apps
Other
427 stars 165 forks source link

bug report: arm/deploy.UnhandledError #10902

Closed theodury closed 2 months ago

theodury commented 2 months ago

Cannot redefine property: stack

stack: UnhandledError: Cannot redefine property: stack at getError (:14:6313245) at Object.wrapRun (:14:6313423) at processTicksAndRejections (node::95:5) at ArmDeployDriver.execute (:14:6056370) at Lifecycle.executeImpl (:14:5935227) at Lifecycle.execute (:14:5932384) at Coordinator.provision (:14:5976180) at Coordinator. (:14:6600016) at FxCore.provisionResources (:14:6529125) at FxCore.exports.EnvWriterMW (:14:6441982) at FxCore.exports.ContextInjectorMW (:14:6603768) at FxCore.exports.ConcurrentLockerMW (:14:6602719) at envLoaderMWImpl (:14:6441929) at FxCore. (:14:6440843) at FxCore.exports.ProjectMigratorMWV3 (:14:6634319) at FxCore.exports.ErrorHandlerMW (:14:6604265) at FxCore. (:14:6600016)

theodury commented 2 months ago

Here is my bicep files :

azure.bicep:

@maxLength(20)
@minLength(4)
@description('Used to generate names for all resources in this file')
param resourceBaseName 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 location string = resourceGroup().location

// 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: true
      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
  }
}

// The output will be persisted in .env.{envName}. Visit https://aka.ms/teamsfx-actions/arm-deploy for more details.
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

// 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'
  }
}

Parameter.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "resourceBaseName": {
        "value": "lwsbot${{RESOURCE_SUFFIX}}"
      },
      "botAadAppClientId": {
        "value": "${{BOT_ID}}"
      },
      "botAadAppClientSecret": {
        "value": "${{SECRET_BOT_PASSWORD}}"
      },
      "webAppSKU": {
        "value": "B1"
      },
      "botDisplayName": {
        "value": "LWSBot"
      }
    }
  }
andremarques023 commented 2 months ago

We are facing the same issue.

italogoncalvessilveira commented 2 months ago

Same error here

chandanpjain commented 2 months ago

Facing same error when trying the sample python conversation bot.

jayzhang commented 2 months ago

@theodury Thanks for feedback. We will fix it.

theodury commented 2 months ago

@jayzhang Okay, if you need any more details, I would be happy to have a call with you if necessary.

I thought it was an authorization issue:

image

image

theodury commented 2 months ago

@jayzhang By the way i did comment this line because of this issue :

image

image


# yaml-language-server: $schema=https://aka.ms/teams-toolkit/1.0.0/yaml.schema.json
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
# Visit https://aka.ms/teamsfx-actions for details on actions
version: 1.0.0

environmentFolderPath: ./env

# Triggered when 'teamsfx provision' is executed
provision:
  - uses: teamsApp/create # Creates a Teams app
    with:
      name: TeamsChef-${{TEAMSFX_ENV}} # Teams app name
    writeToEnvironmentFile:
      # Write the information of installed dependencies into environment file for the specified environment variable(s).
      teamsAppId: TEAMS_APP_ID

  - uses: botAadApp/create # Creates a new AAD app for Bot Registration.
    with:
      name: TeamsChef
    writeToEnvironmentFile:
      botId: BOT_ID
      botPassword: SECRET_BOT_PASSWORD

  - uses: arm/deploy # Deploy given ARM templates parallelly.
    with:
      subscriptionId: ${{AZURE_SUBSCRIPTION_ID}} # The AZURE_SUBSCRIPTION_ID is a built-in environment variable. TeamsFx will ask you select one subscription if its value is empty. You're free to reference other environment varialbe here, but TeamsFx will not ask you to select subscription if it's empty in this case.
      resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}} # The AZURE_RESOURCE_GROUP_NAME is a built-in environment variable. TeamsFx will ask you to select or create one resource group if its value is empty. You're free to reference other environment varialbe here, but TeamsFx will not ask you to select or create resource grouop if it's empty in this case.
      templates:
        - path: ./infra/azure.bicep
          parameters: ./infra/azure.parameters.json
          deploymentName: Create-resources-for-bot
      bicepCliVersion: v0.9.1 # Teams Toolkit will download this bicep CLI version from github for you, will use bicep CLI in PATH if you remove this config.
    # Output: every bicep output will be persisted in current environment's .env file with certain naming conversion. Refer https://aka.ms/teamsfx-actions/arm-deploy for more details on the naming conversion rule.

  - uses: teamsApp/validateManifest # Validate using manifest schema
    with:
      manifestPath: ./teamsAppManifest/manifest.json # Path to manifest template
  - uses: teamsApp/zipAppPackage # Build Teams app package with latest env value
    with:
      manifestPath: ./teamsAppManifest/manifest.json # Path to manifest template
      outputZipPath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip
      outputJsonPath: ./build/teamsAppManifest/manifest.${{TEAMSFX_ENV}}.json
  - uses: teamsApp/update # Apply the Teams app manifest to an existing Teams app in Teams Developer Portal. Will use the app id in manifest file to determine which Teams app to update.
    with:
      appPackagePath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip # Relative path to this file. This is the path for built zip file.
    # writeToEnvironmentFile:
    #   # Write the information of installed dependencies into environment file for the specified environment variable(s).
    #   teamsAppId: TEAMS_APP_ID

# Triggered when 'teamsfx deploy' is executed
# deploy:
#   - uses: azureAppService/deploy # Deploy bits to Azure App Serivce
#     with:
#       distributionPath: . # Deploy base folder
#       ignoreFile: ./.appserviceignore # Can be changed to any ignore file location, leave blank will ignore nothing
#       resourceId: ${{BOT_AZURE_APP_SERVICE_RESOURCE_ID}} # The resource id of the cloud resource to be deployed to. This key will be generated by arm/deploy action automatically. You can replace it with your existing Azure Resource id or add it to your environment variable file.

# Triggered when 'teamsfx publish' is executed
publish:
  - uses: teamsApp/validateManifest # Validate using manifest schema
    with:
      manifestPath: ./teamsAppManifest/manifest.json # Path to manifest template
  - uses: teamsApp/zipAppPackage
    with:
      manifestPath: ./teamsAppManifest/manifest.json # Path to manifest template
      outputZipPath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip
      outputJsonPath: ./build/teamsAppManifest/manifest.${{TEAMSFX_ENV}}.json
  - uses: teamsApp/update # Apply the Teams app manifest to an existing Teams app in Teams Developer Portal. Will use the app id in manifest file to determine which Teams app to update.
    with:
      appPackagePath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip # Relative path to this file. This is the path for built zip file.
    # writeToEnvironmentFile:
    #   # Write the information of installed dependencies into environment file for the specified environment variable(s).
    #   teamsAppId: TEAMS_APP_ID
  - uses: teamsApp/publishAppPackage # Publish the app to Teams Admin Center (https://admin.teams.microsoft.com/policies/manage-apps) for review and approval
    with:
      appPackagePath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip
    writeToEnvironmentFile:
      # Write the information of installed dependencies into environment file for the specified environment variable(s).
      publishedAppId: TEAMS_APP_PUBLISHED_APP_ID
projectId: dc566bd8-248c-4295-8b72-9220810ffb6c
andremarques023 commented 2 months ago

@jayzhang any updates on the root cause of this issue?

jayzhang commented 2 months ago

@

@jayzhang By the way i did comment this line because of this issue :

image

image


# yaml-language-server: $schema=https://aka.ms/teams-toolkit/1.0.0/yaml.schema.json
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
# Visit https://aka.ms/teamsfx-actions for details on actions
version: 1.0.0

environmentFolderPath: ./env

# Triggered when 'teamsfx provision' is executed
provision:
  - uses: teamsApp/create # Creates a Teams app
    with:
      name: TeamsChef-${{TEAMSFX_ENV}} # Teams app name
    writeToEnvironmentFile:
      # Write the information of installed dependencies into environment file for the specified environment variable(s).
      teamsAppId: TEAMS_APP_ID

  - uses: botAadApp/create # Creates a new AAD app for Bot Registration.
    with:
      name: TeamsChef
    writeToEnvironmentFile:
      botId: BOT_ID
      botPassword: SECRET_BOT_PASSWORD

  - uses: arm/deploy # Deploy given ARM templates parallelly.
    with:
      subscriptionId: ${{AZURE_SUBSCRIPTION_ID}} # The AZURE_SUBSCRIPTION_ID is a built-in environment variable. TeamsFx will ask you select one subscription if its value is empty. You're free to reference other environment varialbe here, but TeamsFx will not ask you to select subscription if it's empty in this case.
      resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}} # The AZURE_RESOURCE_GROUP_NAME is a built-in environment variable. TeamsFx will ask you to select or create one resource group if its value is empty. You're free to reference other environment varialbe here, but TeamsFx will not ask you to select or create resource grouop if it's empty in this case.
      templates:
        - path: ./infra/azure.bicep
          parameters: ./infra/azure.parameters.json
          deploymentName: Create-resources-for-bot
      bicepCliVersion: v0.9.1 # Teams Toolkit will download this bicep CLI version from github for you, will use bicep CLI in PATH if you remove this config.
    # Output: every bicep output will be persisted in current environment's .env file with certain naming conversion. Refer https://aka.ms/teamsfx-actions/arm-deploy for more details on the naming conversion rule.

  - uses: teamsApp/validateManifest # Validate using manifest schema
    with:
      manifestPath: ./teamsAppManifest/manifest.json # Path to manifest template
  - uses: teamsApp/zipAppPackage # Build Teams app package with latest env value
    with:
      manifestPath: ./teamsAppManifest/manifest.json # Path to manifest template
      outputZipPath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip
      outputJsonPath: ./build/teamsAppManifest/manifest.${{TEAMSFX_ENV}}.json
  - uses: teamsApp/update # Apply the Teams app manifest to an existing Teams app in Teams Developer Portal. Will use the app id in manifest file to determine which Teams app to update.
    with:
      appPackagePath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip # Relative path to this file. This is the path for built zip file.
    # writeToEnvironmentFile:
    #   # Write the information of installed dependencies into environment file for the specified environment variable(s).
    #   teamsAppId: TEAMS_APP_ID

# Triggered when 'teamsfx deploy' is executed
# deploy:
#   - uses: azureAppService/deploy # Deploy bits to Azure App Serivce
#     with:
#       distributionPath: . # Deploy base folder
#       ignoreFile: ./.appserviceignore # Can be changed to any ignore file location, leave blank will ignore nothing
#       resourceId: ${{BOT_AZURE_APP_SERVICE_RESOURCE_ID}} # The resource id of the cloud resource to be deployed to. This key will be generated by arm/deploy action automatically. You can replace it with your existing Azure Resource id or add it to your environment variable file.

# Triggered when 'teamsfx publish' is executed
publish:
  - uses: teamsApp/validateManifest # Validate using manifest schema
    with:
      manifestPath: ./teamsAppManifest/manifest.json # Path to manifest template
  - uses: teamsApp/zipAppPackage
    with:
      manifestPath: ./teamsAppManifest/manifest.json # Path to manifest template
      outputZipPath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip
      outputJsonPath: ./build/teamsAppManifest/manifest.${{TEAMSFX_ENV}}.json
  - uses: teamsApp/update # Apply the Teams app manifest to an existing Teams app in Teams Developer Portal. Will use the app id in manifest file to determine which Teams app to update.
    with:
      appPackagePath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip # Relative path to this file. This is the path for built zip file.
    # writeToEnvironmentFile:
    #   # Write the information of installed dependencies into environment file for the specified environment variable(s).
    #   teamsAppId: TEAMS_APP_ID
  - uses: teamsApp/publishAppPackage # Publish the app to Teams Admin Center (https://admin.teams.microsoft.com/policies/manage-apps) for review and approval
    with:
      appPackagePath: ./build/teamsAppManifest/appPackage.${{TEAMSFX_ENV}}.zip
    writeToEnvironmentFile:
      # Write the information of installed dependencies into environment file for the specified environment variable(s).
      publishedAppId: TEAMS_APP_PUBLISHED_APP_ID
projectId: dc566bd8-248c-4295-8b72-9220810ffb6c

@theodury The yml schema version is too old to support writeToEnvironmentFile property. You can try to use the latest v1.3 instead of 1.0.0 and try again. I think not every action supports writeToEnvironmentFile property. You can troubleshoot by your self when you change the schema version.

jayzhang commented 2 months ago

@theodury @andremarques023 The reason why TTK not expose the root error is because there is a bug when the error is being constructed and so the root error is not exposed. This but is will be fixed in the next prerelease version.

maxsporer commented 2 months ago

@jayzhang When will the next prerelease version be available?

github-actions[bot] commented 2 months ago

The issue is milestoned with sprint milestone CY24Q1-2Wk12 (Feb 25 - Mar 09) and a work item created: https://msazure.visualstudio.com/9660fff2-2363-48b0-9e15-64df2283e932/_workitems/edit/27087028

evelyn-cristina commented 2 months ago

I'm experiencing the same problem. When will we have a fix to apply it, please?

evelyn-cristina commented 2 months ago

We are facing the same issue.

Me too!

evelyn-cristina commented 2 months ago

The issue is milestoned with sprint milestone CY24Q1-2Wk12 (Feb 25 - Mar 09) and a work item created: https://msazure.visualstudio.com/9660fff2-2363-48b0-9e15-64df2283e932/_workitems/edit/27087028

Since it should be finished last Friday, is it ready for download?

xzf0587 commented 2 months ago

@evelyn-cristina, as the pre-release version has fixed this bug. You can upgrade to the pre-release version in vscode extension. image And try it again.