skip to Main Content

I am creating a Teams Tabs-based app. When I use the Teams toolkit locally I can deploy to multiple environments and I have state.(envname).json files for each environment I want to deploy to. However now that I want to set up CI/CD I have a pipeline in Azure Devops which I created with the teams toolkit, and even though the environments are provisioned and my state files are checked in I get the error below stating they are not provisioned. I can’t find any documentation telling me how to fix this, I tried to use the variables from the provisioning pipeline but that also does not work. Any help in figuring out how to get this deploying to my pre-provisioned app would be helpful. Here is my yaml file, Thanks in advance.

Note that the environment variables referenced here are set, and I can see my service principal access Azure when the pipeline runs.

trigger:
# When new commits are pushed onto the main branch.
- main 

pool:
  vmImage: ubuntu-latest

steps:
# Setup environment.
- task: NodeTool@0
  inputs:
    versionSpec: '14.17.0'
    checkLatest: true

- task: DownloadSecureFile@1
  name: envFile
  inputs:
    secureFile: '.env.teamsfx.test'

- task: CopyFiles@2
  inputs:
    SourceFolder: $(envFile.secureFilePath)
    Contents: '**'
    TargetFolder: 'tabs'

- task: Bash@3
  env:
    # To enable M365 account login by environment variables and non-interactive mode.
    M365_ACCOUNT_NAME: $(M365_ACCOUNT_NAME)
    M365_ACCOUNT_PASSWORD: $(M365_ACCOUNT_PASSWORD)
    M365_TENANT_ID: $(M365_TENANT_ID)
    CI_ENABLED: 'true'
    TEAMSFX_ENV_NAME: test
  inputs:
    targetType: 'inline'
    script: |
      set -evuxo pipefail
      
      # Install the local dev dependency of @microsoft/teamsfx-cli. 
      # 'npm ci' is used here to install dependencies and it depends on package-lock.json.
      # If you prefer to use 'npm ci', please make sure to commit package-lock.json first, or just change it to 'npm install'.
      npm ci

      # Build the project.
      # The way to build the current project depends on how you scaffold it.
      # Different folder structures require different commands set.
      # 'npm ci' may be used here to install dependencies and it depends on package-lock.json.
      # If you prefer to use 'npm ci', please make sure to commit package-lock.json first, or just change it to 'npm install'.  


      cd tabs; npm ci; npm run build; cd -;

      # Run unit test.
      # Currently, no opinioned solution for unit test provided during scaffolding, so,
      # set up any unit test framework you prefer (for example, mocha or jest) and update the commands accordingly in below.
      # npm run test

      # Login Azure by service principal
      npx teamsfx account login azure --service-principal --username $(AZURE_SERVICE_PRINCIPAL_NAME) --password $(AZURE_SERVICE_PRINCIPAL_PASSWORD) --tenant $(AZURE_TENANT_ID)

      # Deploy to hosting environment.
      npx teamsfx deploy --env ${TEAMSFX_ENV_NAME}
> ) [core] failed to get questions for deployArtifactsV2: Failed to deploy because the resources have not been provisioned yet. Make sure you do the provision first. Click Get Help to learn more about why you need to provision.
(✖) [Solution.CannotDeployBeforeProvision]: Failed to deploy because the resources have not been provisioned yet. Make sure you do the provision first. Click Get Help to learn more about why you need to provision.
(✖) Get help from https://aka.ms/teamsfx/whyneedprovision#SolutionCannotDeployBeforeProvision
##[error]Bash exited with code '255'.

2

Answers


  1. Chosen as BEST ANSWER

    I managed to figure out why this happens. When you use the Teams plugin to generate the pipeline.yaml, it changes your state.json file and marks "provisionSucceeded" to false. I didn't notice the Teams plugin changed that on me, but when I updated it to true everything worked. Hopefully someone finds this helpful.


  2. @cwhd I’ve reproduced the behavior using the latest Teams Toolkit, and will create a bug for tracking, thanks.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search