Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda