1
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");

module.exports = async function (context, req) {   
    let credentials = await msRestNodeAuth.loginWithServicePrincipalSecret(clientId, clientSecret, tenant);
    console.log('credentials==> ',credentials);

    context.res = {
        body: credentials
    };
}

While generating the credentials then getting the error. "Exception has occurred: Error: Entry not found in cache.".

Why I'm getting the above error ??

1
  • Do you have any concerns about this issue? Commented Dec 30, 2020 at 1:58

1 Answer 1

1

You can refer to offical document first.

Manage Azure websites with Node.js

I have test it, and it works for me. I use npm i @azure/ms-rest-nodeauth and npm i azure-arm-resource to run my test code.

const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
const resourceManagement = require("azure-arm-resource");

var clientId = "3b417***f7928ad";;
var domain = "72f9****1db47";
var secret = "RnX****7X1T";
var subscriptionId = 'b83***4c23f';
var resourceClient;

msRestNodeAuth.loginWithServicePrincipalSecret(clientId, secret, domain, function (err, credentials) {
  if (err) return console.log(err);
  resourceClient =new resourceManagement.ResourceManagementClient(credentials, subscriptionId);
  console.log('apiVersion==> ',resourceClient.apiVersion);
})

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.