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

Unable to Authorize Azure Functions in Teams Toolkit App Debugged on Edge Browser #12666

Open
lovey25 opened this issue Nov 5, 2024 · 7 comments
Assignees
Labels
TA:Compute Team Area: Compute upstream The issue is tracked external dependency

Comments

@lovey25
Copy link

lovey25 commented Nov 5, 2024

Describe the bug
When creating a new app in VS Code Teams Toolkit with the Fluent UI React template, the app fails to respond upon clicking the "Authorize and call Azure Functions" button during local debug on the Edge browser. The console shows an error indicating failure to initialize the Teams SDK.

To Reproduce
Steps to reproduce the behavior:

  1. Open VS Code Teams Toolkit and create a new app.
  2. Choose the Fluent UI template with React and JavaScript.
  3. Start local debugging with "Debug in Teams (Edge)".
  4. Once the Edge window opens, log in to Teams.
  5. Manually locate and open the newly installed app in Teams.
  6. Click on "Authorize and call Azure Functions" in the app.
  7. Observe no response in the app, and the following error appears in the console:
    [Tue, 05 Nov 2024 21:44:42 GMT] : @microsoft/teamsfx : Error - Initialize teams sdk failed due to not running inside Teams environment

Expected behavior
The app should authorize and call Azure Functions successfully, with no errors in the console, and perform as expected without issues.

Screenshots
image

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

  • OS: macOS
  • Version 15.1

CLI Information (please complete the following information):

  • OS: macOS
  • Version 15.1
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Nov 5, 2024
@adashen adashen added investigating TA:Compute Team Area: Compute labels Nov 6, 2024
@hund030
Copy link
Contributor

hund030 commented Nov 11, 2024

@lovey25 I can't reproduce your issue. The function app works perfectly in my side.
The issue looks like teams-js SDK failed to initialize, which usually happens when user open the app outside teams.
As long as you open your app in Teams, the error is not expected.

Could you provide the SDK version in your package-lock.json? The latest teams-js is 2.30.0 and the @microsoft/teamsfx is 2.3.3. You may want to update these packages and retry if you didn't use the latest.

@hund030 hund030 added needs more info Need user to provide more info and removed investigating needs attention This issue needs the attention of a contributor. labels Nov 11, 2024
@lovey25
Copy link
Author

lovey25 commented Nov 11, 2024

Hello,

Today, I started a new sample project in Teams Toolkit and observed the same issue as before. However, when I ran the same app in a Windows environment, it worked without any problems.
The issue still persists on my Mac environment, which is the same setup I used when initially reporting the bug.

Additionally,
The same project was working fine between November 1st and 3rd without any issues. I haven’t made a single code modification since then, but now it consistently fails on my Mac. (Same on new project.) I also removed all the previously problematic apps from Entra and tried again, but the issue persists. Do you have any insight as to why this might be happening?

Moreover, when I start a sample project in Teams Toolkit, it sets the library versions lower than those you mentioned. Could you guide me on the best way to update the libraries to the latest versions?

Thank you for your support.

Here is the information you requested:

  • Teams Toolkit version: v5.10.0
  • package.json:

{
"name": "test8",
"version": "0.1.0",
"engines": {
"node": "18 || 20"
},
"private": true,
"dependencies": {
"@fluentui/react-components": "^9.18.0",
"@microsoft/teams-js": "^2.22.0",
"@microsoft/teamsfx": "^2.2.0",
"@microsoft/teamsfx-react": "^3.0.0",
"axios": "^0.21.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.8.0",
"react-scripts": "^5.0.1"
},
"devDependencies": {
"@types/node": "^18.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/react-router-dom": "^5.3.3",
"concurrently": "^8.2.2",
"env-cmd": "^10.1.0"
},
"scripts": {
"dev:teamsfx": "concurrently "npm run dev-tab:teamsfx" "npm run dev-api:teamsfx"",
"dev-tab:teamsfx": "env-cmd --silent -f .localConfigs npm run start",
"dev-api:teamsfx": "cd api && npm run dev:teamsfx",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "echo "Error: no test specified" && exit 1",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "."
}

@microsoft-github-policy-service microsoft-github-policy-service bot added needs attention This issue needs the attention of a contributor. and removed needs more info Need user to provide more info labels Nov 11, 2024
@hund030
Copy link
Contributor

hund030 commented Nov 12, 2024

Your teams-js package are the latest. NPM will match the latest 2.x.x as your package.json specifies ^2.22.0.
Seems your issue is caused by teams-js in mac, Iet's track it in the upstream issue: OfficeDev/microsoft-teams-library-js#1181

@hund030 hund030 added upstream The issue is tracked external dependency and removed needs attention This issue needs the attention of a contributor. labels Nov 12, 2024
@lovey25
Copy link
Author

lovey25 commented Nov 12, 2024

Thank you for analyzing the error and providing feedback. However, the upstream issue you mentioned seems to be related to enhancing logging during teams-js initialization to better track errors, which doesn’t appear directly relevant to this particular issue.

Today, I came across some additional information that might be helpful, and I’d appreciate it if you could review it. The tenant I’m testing on is using an MDCA (Microsoft Defender for Cloud Apps) session control policy. Both Mac devices and PCs are subject to session control. Although there were no changes to the code, intermittent errors have been occurring. As a precaution, I decided to disable the session control policy, and since doing so, the issue discussed in this thread has not reproduced.

As an additional recommendation for your review, it might be worth testing under conditions similar to the original bug report environment but with an additional setup: an MDCA session control that blocks downloads on devices that are not hybrid Azure AD-joined. This may help to reproduce the issue.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Nov 12, 2024
@MuyangAmigo
Copy link
Collaborator

Thanks @lovey25 for your infirmation. Are yiu suggesting us to try reproduce the issue under MDCA session control policy?

@adashen adashen added needs more info Need user to provide more info and removed needs attention This issue needs the attention of a contributor. labels Nov 21, 2024
@lovey25
Copy link
Author

lovey25 commented Nov 22, 2024

Of course. I’ll share the MDCA conditions under which the issue is reproduced.

In Microsoft Defender for Cloud Apps, I configured the following policy under Policies > Policy Management > Conditional Access. The action for the policy is set to "Block." The purpose of this configuration is to block downloads when accessing under conditions that are not Intune compliant. Currently, only the devices using Teams Toolkit are set as an exception.

image
image

Let me know if you need further details.

@microsoft-github-policy-service microsoft-github-policy-service bot added needs attention This issue needs the attention of a contributor. and removed needs more info Need user to provide more info labels Nov 22, 2024
@MuyangAmigo
Copy link
Collaborator

@lovey25 Thank you for your test case, we will see if this can be reproduced and analyze further. @hund030 would you mind following up?

@adashen adashen removed the needs attention This issue needs the attention of a contributor. label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TA:Compute Team Area: Compute upstream The issue is tracked external dependency
Projects
None yet
Development

No branches or pull requests

4 participants