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 make API call to Developer Portal: AxiosError, Request failed with status code 502, API name: create-app #12154

Closed
ms-86 opened this issue Aug 5, 2024 · 17 comments
Assignees
Labels
investigating needs more info Need user to provide more info no recent activity The issue labeled needs more info gets no reply from issue owner in time TA:E2E Team Area: E2E

Comments

@ms-86
Copy link

ms-86 commented Aug 5, 2024

Describe the bug
I've tried to run a simple EchoBot from the Teams AI repo examples the Teams AI repo examples. My first problem was during Start local tunnel task:

[2024-08-05T08:32:36.212Z] [Info] - Running Visual Studio Code task: 'Start local tunnel'

(Total: 1 Step) Teams Toolkit is starting local tunneling service to forward public URL to local port. Open the terminal window for details.

(1/1) Starting dev tunnel service ... 

Summary:

(×) Error: Unable to execute dev tunnel operation 'create'. Tunnel service returned status code: 400 Bad Request

Visit https://aka.ms/teamsfx-local-tunnel-task to get more info about 'Start local tunnel' task.

[2024-08-05T08:32:36.985Z] [Error] - code:Ext.DevTunnelOperationError, message: Unable to execute dev tunnel operation 'create'. Tunnel service returned status code: 400 Bad Request
 Help link: https://aka.ms/teamsfx-local-tunnel-task

As a workaround I started tunnel myself in PowerShell terminal:

.\devtunnel host -p 3978 --protocol http --allow-anonymous
Hosting port: 3978
Connect via browser: https://*************.euw.devtunnels.ms
Inspect network activity: https://*************-inspect.euw.devtunnels.ms

Ready to accept connections for tunnel: *************

and then disabled this task from tasks.json
Now when I try to run the app by hitting F5 I'm stuck at provisioning stage

[2024-08-05T08:51:27.917Z] [Info] - Running 'Validate prerequisites' Visual Studio Code task.

(Total: 3 Steps) Teams Toolkit is checking the required prerequisites.

(1/3) Checking Node.js ...
(2/3) Checking Microsoft 365 Account ...
(3/3) Checking ports occupancy ...

Summary:

(√) Done: Node.js version (v18.20.2) is installed 
(√) Done: Microsoft 365 Account (***@*****.onmicrosoft.com) is logged in and custom app upload permission is enabled 
(√) Done: Ports (3978, 9239) are not occupied 

Visit https://aka.ms/teamsfx-tasks/check-prerequisites to get more info about 'Validate prerequisites' task.

[2024-08-05T08:51:54.008Z] [Info] - Finished 'Validate prerequisites' Visual Studio Code task in 26.09 seconds.
[2024-08-05T08:51:54.060Z] [Info] - Executing provision 

Lifecycle stage: provision(7 step(s) in total). The following actions will be executed: 
(1/7) Action teamsApp/create: create Teams app.
(2/7) Action botAadApp/create: create a new or reuse an existing bot Microsoft Entra app.
(3/7) Action botFramework/create: creates or updates the bot registration on dev.botframework.com
(4/7) Action teamsApp/validateManifest: validate Teams app.
(5/7) Action teamsApp/zipAppPackage: build Teams app package.
(6/7) Action teamsApp/validateAppPackage: validate Teams app.
(7/7) Action teamsApp/update: update Teams app.

[2024-08-05T08:51:54.060Z] [Info] - Executing lifecycle provision
[2024-08-05T08:52:20.017Z] [Error] - Failed to Execute lifecycle provision due to failed action: teamsApp/create. DeveloperPortalAPIFailedError:Unable to make API call to Developer Portal: AxiosError, Request failed with status code 502, API name: create-app, X-Correlation-ID: undefined. This may be due to a temporary service error. Try again after a few minutes.

Expected behavior
I should be prompted to sideload a bot into teams like described here

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

  • OS: Microsoft Windows 10 Enterprise (10.0.19045)
  • VS Code 1.91.1
  • Teams Toolkit 5.8.1

Additional context
I'm behind corporate proxy. I have following env variables configured:
HTTP_PROXY=****
HTTPS_PROXY=****
NO_PROXY=localhost

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Aug 5, 2024
@adashen adashen added investigating TA:E2E Team Area: E2E labels Aug 6, 2024
@anchenyi
Copy link
Contributor

anchenyi commented Aug 6, 2024

hi, thanks for reporting this issue. I am investagating and will get back to you ASAP.

@anchenyi
Copy link
Contributor

anchenyi commented Aug 7, 2024

hi @ms-86, I cannot reproduce this issue on my side. The error meesage "DeveloperPortalAPIFailedError:Unable to make API call to Developer Portal: AxiosError, Request failed with status code 502" was probably due to a brief service unavailability. Could you retry to see if this still happens? Sorry for the inconvenience.

@hirokika
Copy link

hirokika commented Aug 7, 2024

hi @anchenyi, in my environment, a similar error occurs although the error code is different.
I executed the following provision command using the teamsapp command behind corporate proxy:
npx teamsapp provision --env dev

An error occurs during the execution of teamsApp/create, and the Azure resources are not created successfully.
The same situation occurs no matter how many times I try.
Are there any solutions?

Costs may apply based on usage. Do you want to provision resources in prod environment using listed accounts? yes
Executing provision
Lifecycle stage: provision(7 step(s) in total). The following actions will be executed:
(1/7) Action teamsApp/create: create a Teams app.
(2/7) Action aadApp/create: Create a Microsoft Entra app to authenticate users
(3/7) Action arm/deploy: Deploy the given ARM templates to Azure.
(4/7) Action teamsApp/validateManifest: validate a Teams app.
(5/7) Action teamsApp/zipAppPackage: build a Teams app package.
(6/7) Action teamsApp/validateAppPackage: validate a Teams app.
(7/7) Action teamsApp/update: update a Teams app.
Executing lifecycle provision
(×) Error: Failed to Execute lifecycle provision due to failed action: teamsApp/create. DeveloperPortalAPIFailedError:Unable to make API call to Developer Portal: AxiosError, Requv output: {}
Execution summary:
Summary:
(×) Error: Lifecycle stage provision failed.
  (×) Error: teamsApp/create failed.
    (×) Error: Unable to make API call to Developer Portal: AxiosError, Request failed with status code 400, API name: create-app, X-Correlation-ID: undefined. This may be due to
  (!) Warning: aadApp/create was not executed.
  (!) Warning: arm/deploy was not executed.
  (!) Warning: teamsApp/validateManifest was not executed.
  (!) Warning: teamsApp/zipAppPackage was not executed.
  (!) Warning: teamsApp/validateAppPackage was not executed.
  (!) Warning: teamsApp/update was not executed.

@anchenyi
Copy link
Contributor

anchenyi commented Aug 7, 2024

hi @hirokika, the APIs look fine on my side. Could you provide your project code for further investigation? Thanks!

@hirokika
Copy link

hirokika commented Aug 7, 2024

@anchenyi Thank you for your reply!!

I am trying to log in to Azure and execute the provisioning commands using a shell script as shown below.
The environment variables are defined in a .env file and read by the shell script.

export AZURE_SERVICE_PRINCIPAL_CLIENT_ID=xxx
export AZURE_TENANT_ID=xxx
export AZURE_SERVICE_PRINCIPAL_CLIENT_SECRET=xxx

# install teamsapp-cli
npm install -g @microsoft/[email protected]

# login to Azure
npx teamsapp auth login azure --username $AZURE_SERVICE_PRINCIPAL_CLIENT_ID  \
                  --service-principal true \
                  --tenant $AZURE_TENANT_ID \
                  --password $AZURE_SERVICE_PRINCIPAL_CLIENT_SECRET \
                  --interactive false

# provision
npx teamsapp provision --env dev

The teamsapp.yml file looks like this:

provision:
    - uses: teamsApp/create
      with:
          name: my-project-bot
      writeToEnvironmentFile:
          teamsAppId: TEAMS_APP_ID

    - uses: aadApp/create
      with:
          name: my-project-bot
          generateClientSecret: true
          signInAudience: AzureADMultipleOrgs
      writeToEnvironmentFile:
          clientId: BOT_ID
          clientSecret: SECRET_BOT_PASSWORD
          objectId: BOT_OBJECT_ID

    - 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-bot
          bicepCliVersion: v0.9.1

    …

I have set the proxy with npm set proxy and http-proxy, and also set the environment variables HTTP_PROXY and HTTPS_PROXY.
While the npm library installation and login succeed, the aadApp/create step fails.
The commands complete successfully if not behind corporate proxy.

@anchenyi
Copy link
Contributor

anchenyi commented Aug 7, 2024

hi @hirokika, so currently, it is the aadApp/create that is failing, not teamsApp/create, right? Since in the previous post, the error was related to teamsApp/create.

@hirokika
Copy link

hirokika commented Aug 7, 2024

@anchenyi Oh, sorry about that.
That was a mistake on my part.
As I originally mentioned, the error occurs with teamsApp/create.

@anchenyi
Copy link
Contributor

anchenyi commented Aug 7, 2024

Got it, @hirokika . Could you provide all related error messages? If the command works fine without your corporate proxy, it may due to the network.

@hirokika
Copy link

hirokika commented Aug 7, 2024

Thanks @anchenyi, here is all the log from running the shell script.
It's not a problem if deprecated warnings appear during npm install, right?

$ ./provision.sh
npm WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
changed 422 packages in 33s
42 packages are looking for funding
  run npm fund for details
(√) Success: Successfully signed into Azure.
Your Azure account is: xxxxx. Your subscriptions are: [
  {
    "subscriptionName": "xxxxx",
    "subscriptionId": "xxxxx",
    "tenantId": "xxxxx"
  }
]
? Azure account:
Azure subscription: xxxxx
Microsoft 365 account: [xxxxx](xxxxx)
Costs may apply based on usage. Do you want to provision resources in prod environment using listed accounts? yes
Executing provision
Lifecycle stage: provision(7 step(s) in total). The following actions will be executed:
(1/7) Action teamsApp/create: create a Teams app.
(2/7) Action aadApp/create: Create a Microsoft Entra app to authenticate users
(3/7) Action arm/deploy: Deploy the given ARM templates to Azure.
(4/7) Action teamsApp/validateManifest: validate a Teams app.
(5/7) Action teamsApp/zipAppPackage: build a Teams app package.
(6/7) Action teamsApp/validateAppPackage: validate a Teams app.
(7/7) Action teamsApp/update: update a Teams app.
Executing lifecycle provision
(×) Error: Failed to Execute lifecycle provision due to failed action: teamsApp/create. DeveloperPortalAPIFailedError:Unable to make API call to Developer Portal: AxiosError, Request failed with status code 400, API name: create-app, X-Correlation-ID: undefined. This may be due to a temporary service error. Try again after a few minutes. data: "Bad request". Env output: {}
Execution summary:
Summary:
(×) Error: Lifecycle stage provision failed.
  (×) Error: teamsApp/create failed.
    (×) Error: Unable to make API call to Developer Portal: AxiosError, Request failed with status code 400, API name: create-app, X-Correlation-ID: undefined. This may be due to a temporary service error. Try again after a few minutes. data: "Bad request"
  (!) Warning: aadApp/create was not executed.
  (!) Warning: arm/deploy was not executed.
  (!) Warning: teamsApp/validateManifest was not executed.
  (!) Warning: teamsApp/zipAppPackage was not executed.
  (!) Warning: teamsApp/validateAppPackage was not executed.
  (!) Warning: teamsApp/update was not executed.
██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  9% | [1/7] Provision: Creating Teams app... (×) Failed.
(×) Error: AppStudioPlugin.DeveloperPortalAPIFailedError: Unable to make API call to Developer Portal: AxiosError, Request failed with status code 400, API name: create-app, X-Correlation-ID: undefined. This may be due to a temporary service error. Try again after a few minutes. data: "Bad request"

I want to run the deploy command after provisioning, but I can't proceed because the provisioning failed.
Since npm install succeeded, I thought the network might not be the issue, but I'll check further to confirm if there are any specific URLs being blocked.

@anchenyi
Copy link
Contributor

anchenyi commented Aug 7, 2024

Thanks @hirokika for providing these details.
"Request failed with status code 400, API name: create-app, X-Correlation-ID: undefined." This is the critical error message. Since the X-Correlation-ID is undefined, and I also checked the server-side logs, it looks like this request did not reach the server. If everything works fine without the corporate proxy, I think you might need to check the network settings.

For your information, the "create-app" API's url is https://dev.teams.microsoft.com/{region}/api/appdefinitions/v2/import

@hirokika
Copy link

hirokika commented Aug 7, 2024

Thank you @anchenyi, for the detailed explanation!
If the request isn’t reaching the server, it indeed suggests that the proxy is likely interfering…
I will check the network settings further.

@ms-86
Copy link
Author

ms-86 commented Aug 7, 2024

@anchenyi

I'm still getting Request failed with status code 502, API name: create-app, X-Correlation-ID: undefined

You wrote something about create-app URL. In a data field of the response I see an HTML in which there's such URL
https://dev.teams.microsoft.com/api/appdefinitions/v2/import?overwriteIfAppAlreadyExists=false
so it's not matching a pattern with region you wrote about.

For your information, the "create-app" API's url is https://dev.teams.microsoft.com/{region}/api/appdefinitions/v2/import

@anchenyi
Copy link
Contributor

anchenyi commented Aug 8, 2024

hi @ms-86 , the API url is account-based, and what you mentioned is a global endpoint, which is also valid. Could you share all the error response data for futher investigation? Thanks!

@kimizhu kimizhu removed the needs attention This issue needs the attention of a contributor. label Aug 8, 2024
@ms-86
Copy link
Author

ms-86 commented Aug 8, 2024

Hi @anchenyi this is an log from Teams Toolkit Output in VS Code
log.txt

Let me know if you need something else.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Aug 8, 2024
@anchenyi
Copy link
Contributor

anchenyi commented Aug 8, 2024

hi @ms-86, thanks for the details. It seems to be a network-related issue. Can the command succeed without your corporate proxy?

@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 Aug 12, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the no recent activity The issue labeled needs more info gets no reply from issue owner in time label Aug 20, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

Copy link
Contributor

Due to lack of details for further investigation, we will archive the issue for now. In case you still have following-up questions on this issue, please always feel free to reopen the issue by clicking ‘reopen issue’ button below the comment box. We will get back to you as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating needs more info Need user to provide more info no recent activity The issue labeled needs more info gets no reply from issue owner in time TA:E2E Team Area: E2E
Projects
None yet
Development

No branches or pull requests

5 participants