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

"endpoints_resolution_error: Endpoints cannot be resolved" when calling an Azure Function in local development environment only #6684

Closed
oshihirii opened this issue Nov 10, 2023 · 2 comments
Assignees
Labels
bug-unconfirmed A reported bug that needs to be investigated and confirmed confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package question Customer is asking for a clarification, use case or information.

Comments

@oshihirii
Copy link

oshihirii commented Nov 10, 2023

Core Library

MSAL Node (@azure/msal-node)

Core Library Version

^2.5.1

Wrapper Library

Not Applicable

Wrapper Library Version

None

Public or Confidential Client?

Confidential

Description

Azure Functions, Node.js, v4 programming model.

Calling a local function endpoint in Postman returns this error:

"endpoints_resolution_error: Endpoints cannot be resolved"

Calling the live function endpoint in Postman works as expected with no errors.

I documented this issue in a comment on a closed issue here:

#4879 (comment)

I decided to create a new issue here because I don't think anyone will be looking at a closed issue.

I thought I found a solution yesterday, just requesting a token from my local computer to my tenant via Postman, even though I didn't use it afterwards, seems to have enabled my function code to request a token successfully.

However, 24 hours later, without any changes to the code, I am getting the same error and trying the solution that worked yesterday, ie getting an unrelated token in an unrelated call, is not resolving the issue today.

The function SUCCESSFULLY returns a result IF I comment out the code that requests a token.

As soon as I introduce the code that requests a token, I get the error.

package.json:

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "main": "src/functions/*.js",
  "scripts": {
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {
    "@azure/functions": "^4.0.0-alpha.1",
    "@azure/msal-node": "^2.5.1",
    "axios": "^1.6.0",
    "pino": "^8.16.1"
  },
  "devDependencies": {
    "azure-functions-core-tools": "^4.x"
  }
}

Error Message

endpoints_resolution_error: Endpoints cannot be resolved

Msal Logs

No response

MSAL Configuration

const msal_config = {
                auth: {
                    clientId: azure_ad_app_registration_client_id,
                    authority: `https://login.microsoftonline.com/${azure_ad_app_registration_tenant_id}`,
                    clientSecret: azure_ad_app_registration_client_secret,
                }
            };

Relevant Code Snippets

const msal = require('@azure/msal-node');  
const axios = require('axios');

const msal_config = {
    auth: {
        clientId: process.env["azure_ad_app_registration_client_id"],
        authority: `https://login.microsoftonline.com/${process.env["azure_ad_app_registration_tenant_id"]}`,
        clientSecret: process.env["azure_ad_app_registration_client_secret"],
    }
};

const cca = new msal.ConfidentialClientApplication(msal_config);

const clientCredentialRequest = {
    scopes: ["https://graph.microsoft.com/.default"],
};
const response = await cca.acquireTokenByClientCredential(clientCredentialRequest);

const token = response.accessToken;

return { jsonBody: {"some_key": "some value"} }

Reproduction Steps

Call the live function endpoint in Postman.
Don't get the error.
Call the local function endpoint in Postman.
Get the error.

Expected Behavior

That I don't get an error.

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

None (Server)

Regression

No response

Source

External (Customer)

@oshihirii oshihirii added bug-unconfirmed A reported bug that needs to be investigated and confirmed question Customer is asking for a clarification, use case or information. labels Nov 10, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Nov 10, 2023
@github-actions github-actions bot added confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package labels Nov 10, 2023
@oshihirii
Copy link
Author

On a whim, I tried connecting to a VPN, and the issue went away.

func start starts A LOT quicker, and I can call the local function endpoint with no errors.

I use Starlink, can anyone explain why using Starlink would prevent me from being able to get a token in a local development environment using msal-node?

@tnorling
Copy link
Collaborator

Closing as this is not related to MSAL itself nor can we comment on Starlink compatibility.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs: Attention 👋 Awaiting response from the MSAL.js team label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unconfirmed A reported bug that needs to be investigated and confirmed confidential-client Issues regarding ConfidentialClientApplications msal-node Related to msal-node package question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

2 participants