Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provision command doesn`t work in Pipelines because it always asks for login #13024

Open
bastianveltin opened this issue Jan 8, 2025 · 3 comments
Assignees
Labels
TA:Compute Team Area: Compute

Comments

@bastianveltin
Copy link

Describe the bug
We wanna do the whole build and deployment process within a Github Actions Pipeline.
But The 'teamsapp provision' command is always asking for a login via Link:

'Log in to your Microsoft 365 account - opening default web browser at ....'

The 'deploy' step works fine without asking for a login.

To Reproduce
This is the github Action:
`

steps:
  - name: "Checkout GitHub Action"
    uses: actions/checkout@v4
  - name: "Setup Node ${{ env.NODE_VERSION }}"
    uses: actions/setup-node@v4
    with:
      node-version: ${{ env.NODE_VERSION }}

  - name: "Install CLI"
    run: |
      npm install @microsoft/teamsapp-cli@${{ env.TEAMSAPP_CLI_VERSION }}

  - name: "Azure Login as Service Principal"
    run: |
      npx teamsapp auth login azure --username ${{ vars.GA_WORKFLOW_CLIENT_ID }}  \
      --service-principal true \
      --tenant ${{ vars.AZURE_TENANT_ID }} \
      --password ${{ secrets.GA_WORKFLOW_CLIENT_SECRET }} \
      --interactive false

  - name: "Provision resources to hosting environment"
    run: |
      npx teamsapp provision --env ${{ inputs.environment }} --verbose --interactive false
  - name: "Deploy to hosting environment"
    run: |
      npx teamsapp deploy --env ${{ inputs.environment }} --verbose --interactive false

`

Expected behavior
Execute the provision step without user interaction.

Screenshots
image

VS Code Extension Information (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

CLI Information (please complete the following information):

  • OS: [e.g. iOS8.1]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Copy link

👋 Hi @bastianveltin,

Thank you for reporting this issue! We want to let you know that:

⏱️ Our team will personally review your issue
🎯 You can expect a response within 2 business days

✨ This is an AI-generated initial response
🤖 AI-Generated Preliminary Analysis:

The issue you are encountering is due to the teamsapp provision command prompting for login during the provisioning step, despite using the --interactive false flag. This is likely because the Teams Toolkit CLI requires authentication to Microsoft 365, which isn't being handled correctly in the non-interactive mode.

Here are some steps and suggestions to resolve this issue:

  1. Set Environment Variables for M365 Login: Ensure that you set the environment variables for M365 account name and password. This can help in bypassing the login prompt.
- name: "Azure Login as Service Principal"
  run: |
    npx teamsapp auth login azure --username ${{ vars.GA_WORKFLOW_CLIENT_ID }}  \
    --service-principal true \
    --tenant ${{ vars.AZURE_TENANT_ID }} \
    --password ${{ secrets.GA_WORKFLOW_CLIENT_SECRET }} \
    --interactive false
  env:
    M365_ACCOUNT_NAME: ${{ secrets.M365_ACCOUNT_NAME }}
    M365_ACCOUNT_PASSWORD: ${{ secrets.M365_ACCOUNT_PASSWORD }}
    CI_ENABLED: true
    M365_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
  1. Check for 2FA: If your M365 account has two-factor authentication (2FA) enabled, the environment variables method might not work. You may need to use a service principal or another method that does not require interactive login.

  2. Refer to Documentation: Refer to the GitHub issue and documentation that discuss this problem. They provide insights and potential solutions. Here is a link to the relevant GitHub issue and the Microsoft documentation.

  3. Example Workflow: Here is an example of a GitHub Actions workflow with the required environment variables and steps:

name: CI/CD Pipeline

on: [push]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    
    steps:
      - name: "Checkout GitHub Action"
        uses: actions/checkout@v4

      - name: "Setup Node ${{ env.NODE_VERSION }}"
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: "Install CLI"
        run: |
          npm install -g @microsoft/teamsapp-cli@${{ env.TEAMSAPP_CLI_VERSION }}

      - name: "Azure Login as Service Principal"
        run: |
          npx teamsapp auth login azure --username ${{ vars.GA_WORKFLOW_CLIENT_ID }}  \
          --service-principal true \
          --tenant ${{ vars.AZURE_TENANT_ID }} \
          --password ${{ secrets.GA_WORKFLOW_CLIENT_SECRET }} \
          --interactive false
        env:
          M365_ACCOUNT_NAME: ${{ secrets.M365_ACCOUNT_NAME }}
          M365_ACCOUNT_PASSWORD: ${{ secrets.M365_ACCOUNT_PASSWORD }}
          CI_ENABLED: true
          M365_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}

      - name: "Provision resources to hosting environment"
        run: |
          npx teamsapp provision --env ${{ inputs.environment }} --verbose --interactive false

      - name: "Deploy to hosting environment"
        run: |
          npx teamsapp deploy --env ${{ inputs.environment }} --verbose --interactive false

Following these steps and incorporating the necessary environment variables should help you bypass the login prompt during the teamsapp provision command in your CI/CD pipeline. If you continue to face issues, please provide additional details or error messages for further assistance.


Note: This is an automated first response generated by AI. A human team member will review your issue and provide a more detailed response soon. We appreciate your patience!

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Jan 8, 2025
@Nivedipa-MSFT
Copy link

@bastianveltin - Thank you for bringing this issue to our attention. Could you please share the document you are following for this?

@adashen adashen added investigating TA:Compute Team Area: Compute labels Jan 9, 2025
@huimiu huimiu assigned yukun-dong and unassigned Siglud Jan 9, 2025
@yukun-dong
Copy link
Contributor

yukun-dong commented Jan 9, 2025

Hi @bastianveltin ,
The "provision" command involves steps such as creating a Teams app ID, which requires your Microsoft 365 account. Since logging into a Microsoft 365 account in non-interactive mode is not supported, we recommend only including the deploy step in the pipeline.

@yukun-dong yukun-dong removed investigating needs attention This issue needs the attention of a contributor. labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TA:Compute Team Area: Compute
Projects
None yet
Development

No branches or pull requests

5 participants