Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda