Coder Social home page Coder Social logo

Comments (6)

amarzavery avatar amarzavery commented on August 18, 2024

We have an internal exponential retry mechanism for certain amount of time and then bail out if things still fail.

from azure-sdk-for-js.

ramya-rao-a avatar ramya-rao-a commented on August 18, 2024

@RodgeFu, @nickzhums, @qiaozha Can we close this issue with a pointer to show how to configure the retry policy?

from azure-sdk-for-js.

nickzhums avatar nickzhums commented on August 18, 2024

@RodgeFu @zikalino do we have any track 1 retry policy samples?

from azure-sdk-for-js.

changlong-liu avatar changlong-liu commented on August 18, 2024

Hi @itilitymaarten ,

You can find exponentialRetryPolicy, systemErrorRetryPolicy and throttlingRetryPolicy here: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/core-http/src/policies

They can be used as any other policies in JS SDK, a sample for policy assignment can be found here:

const clientOptions: coreHttp.ServiceClientOptions = {

from azure-sdk-for-js.

ramya-rao-a avatar ramya-rao-a commented on August 18, 2024

@changlong-liu That sample is for @azure/core-http where as the management libraries use @azure/ms-rest-js. Though the former is built on top of the latter, it might have had changes done to it. Have you tried that sample with @azure/arm-commerce package?

from azure-sdk-for-js.

changlong-liu avatar changlong-liu commented on August 18, 2024

Thank you @ramya-rao-a .
I have just had a try on @azure/arm-commerce, and found it's not using core-http, but the old @azure/ms-rest-js 1.x.x. And also an old version for ms-rest-nodeauth.
Correct the policy folder for ms-rest-js as: https://github.com/Azure/ms-rest-js/tree/1.x/lib/policies
Reference code for creating policy factory: https://github.com/Azure/ms-rest-js/blob/master/lib/serviceClient.ts#L401

Below are some details in my verification for @azure/[email protected]:
npm install "@azure/[email protected]"
npm install "@azure/ms-rest-nodeauth": "^2.0.4"

code:

import { UsageManagementClient, UsageManagementModels } from "@azure/arm-commerce"
import { exponentialRetryPolicy, signingPolicy, generateClientRequestIdPolicy, deserializationPolicy, redirectPolicy} from "@azure/ms-rest-js"
import { loginWithServicePrincipalSecret, ApplicationTokenCredentials } from "@azure/ms-rest-nodeauth";


function main() {
  loginWithServicePrincipalSecret(
    "[YOUR CLIENT ID]",
    "[YOUR SECRET]",
    "[YOUR TENANT]",
    (err: any, credentials: ApplicationTokenCredentials) => {
      if (err) throw err;

      const clientOptions: UsageManagementModels.UsageManagementClientOptions = {
        requestPolicyFactories: [
          generateClientRequestIdPolicy(),
          signingPolicy(credentials),
          redirectPolicy(),
          exponentialRetryPolicy(10, 10),
          deserializationPolicy()
        ]
      };

      const client = new UsageManagementClient(credentials, subscriptionId, clientOptions);
      const reportedStartTime = new Date("2019-3-1 0:00:00Z").toISOString();
      const reportedEndTime = new Date("2019-4-1 0:00:00Z").toISOString();
      client.usageAggregates.list(reportedStartTime, reportedEndTime).then((result) => {
        console.log("The result is:");
        console.log(result);
      });

    }
  );
}

main();

from azure-sdk-for-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.