Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
azure and javascript working with resource graph service

Hello I am new to Azure and Javascript, I am trying to run a code in order to get the list of VMs and its owners, I want to use Resource Graph service as it seems to be faster.

My inventory is more than 1000 so I need to run the function multiple times because of the pagination. The first 2 times it runs all good, but on the 3rd time it gives me this error, not sure why I am receiving this since the first 2 ran ok.

I do not see too much documentation for Javascript and this module, thus I am requesting your help.

let query =  async (x) => {
  //creates the client  
  credentials = new ClientSecretCredential(tenantId, clientId, secret);
  let client = new ResourceGraphClient(credentials);
  //in a loop to get the results since the limit is 1000 results per call/query,
  //if you have more than 1000 you will need to use skip token variable provided in the answer
  do
  {
    try
    {
        //first time is empty
        if (skipToken_=="")
        {
        result =  await client.resources(
            {
                query: x
            },
            { resultFormat: "objectArray" }
        );
        console.log("Records: " + result.totalRecords);
        console.log(result.data);
        console.log(result.skipToken);
        skipToken_=result.skipToken;
        console.log(result.data[0]);
        console.log(result);
        }
        else
        {
        
        result = await client.resources(
            {
                query: x
            },
            { resultFormat: "objectArray" },
            {skipToken:skipToken_}
        );
        console.log("Records: " + result.totalRecords);
        console.log(result.data);
        console.log(result.skipToken);
        skipToken_=result.skipToken;
        console.log(result.data[0]);
        console.log(result);
        }
    } catch (error) {console.log(error)}
  }while (skipToken_!= ""); 
}

 // this calls a query already saved instead of using commands
query("{{/subscriptions/*****/resourceGroups/******}}");

the error is below:

TypeError: cb is not a function
    at c:\Users\...\Desktop\last day work for cloud\node_modules\@azure\ms-rest-js\dist\msRest.node.js:4949:48

I googled it and found that cb is the callback function, what is odd is that as I said the first 2 times works well but on the third it breaks. Since this is part of the library I am thinking there is an error with the package/module/library?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

TypeError: cb is not a function at c:\Users...\Desktop\last day work for cloud\node_modules@azure\ms-rest-js\dist\msRest.node.js:4949:48

To resolve the above error, try either of the following options as suggested by allaura-dev:

Option 1:

  • In C:\Users(your username)\AppData\Roaming, delete the npm folder
  • If there is a npm cache folder, Run npm clean cache —force

Option 2:

  • In C:\Users(your username)\AppData\Roaming, delete the npm folder
  • If there is a mom cache folder, Run npm clean cache —force
  • Make sure everything related to Nodejs is deleted and uninstalled then reinstall Nodejs.

Reference: error cb.apply is not a function

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!