Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage Queue] How to use retry policy? #11338

Closed
1 of 6 tasks
gmantri opened this issue Sep 18, 2020 · 8 comments
Closed
1 of 6 tasks

[Storage Queue] How to use retry policy? #11338

gmantri opened this issue Sep 18, 2020 · 8 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Docs needs-author-feedback Workflow: More information is needed from author to address the issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage Storage Service (Queues, Blobs, Files)

Comments

@gmantri
Copy link

gmantri commented Sep 18, 2020

  • Package Name: @azure/storage-queue
  • Package Version: 12.1.0
  • Operating system: macOS
  • nodejs
    • version: 10.16.3
  • browser
    • name/version:
  • typescript
    • version:
  • Is the bug related to documentation in

Describe the bug
In the older versions of SDK, defining a retry policy was rather simple using something like the following:

const retryOperations = new azure.ExponentialRetryPolicyFilter(5);
return azure.createQueueService(connectionString).withFilter(retryOperations);

I am wondering how can we do the same with the new SDK. I looked around but could not find any information/code samples regarding that. Any pointers will be highly appreciated.

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 18, 2020
@ramya-rao-a
Copy link
Contributor

Thanks for reporting @gmantri

@xirzec This falls into the bucket of some common documentation we should have in this repo that applies across packages to cover topics like retries and logging. Can you log an issue to track all such documentation we want to have?

@jeremymeng Meanwhile, can you share pointers on how to use the retry policy?

@ramya-rao-a ramya-rao-a added Client This issue points to a problem in the data-plane of the library. Docs Storage Storage Service (Queues, Blobs, Files) labels Sep 21, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 21, 2020
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 21, 2020
@gmantri
Copy link
Author

gmantri commented Sep 22, 2020

Thanks @ramya-rao-a!

One more issue I would like to pile on with this is the ability to add client request id in the new SDK. I looked around but could not find a way to include that in the SDK. In the older SDK, it was as simple as clientRequestId as one of the request options. I would appreciate if documentation can be updated to include a sample for that as well.

On a different note, is there a way I can contribute towards improving the documentation? I have been using SDK quite extensively and there are places where documentation needs more details.

For example, take a look at the SignedIdentifier. The documentation simply states that accessPolicy should be an object however it fails to describe the structure of that object. When I used it, I found that the structure of this object should be something like the following:

{
  permissions: "<permission-string>",
  startsOn: Date/Time value or undefined,
  expiresOn: Date/Time value or undefined
}

I could possibly try and fix the documentation wherever it is possible.

@xirzec
Copy link
Member

xirzec commented Sep 22, 2020

@ramya-rao-a the tracking issue for core documentation is here: #10239

@gmantri We automatically set a client request id in this policy: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-http/src/policies/generateClientRequestIdPolicy.ts

If you really want to set your own header for this you could set a custom header with the correct name: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-http/src/operationOptions.ts#L31

The SignedIdentifier doc issue looks like something is broken in the docs pipeline, since the definition here looks similar to what you discovered:

export interface SignedIdentifier {

@gmantri
Copy link
Author

gmantri commented Sep 23, 2020

Thanks @xirzec for replying. I am wondering if you can share a code sample for setting custom header. I looked up the link you shared but unfortunately still clueless as to how you would go about using it. I would really appreciate that.

@jeremymeng
Copy link
Member

@gmantri Storage libraries don't use OperationOptions from core-http. So customHeaders does not exist in their option types. However if you are using JavaScript, you can add it to the options object like below:

blobServiceClient.listContainers({
        customHeaders: {
          myheader: "my header value"
        }
      })

We also have a sample showing how to set the x-ms-client-request-id using a custom policy.

@jeremymeng
Copy link
Member

For retry please use StorageRetryOptions to customize the pipeline:

retryOptions: {
maxTries: 4
}, // Retry options

@jeremymeng
Copy link
Member

@gmantri Please let us know if you have any further questions. We have tracked the doc issue of Object type in another system.

@jeremymeng jeremymeng added needs-author-feedback Workflow: More information is needed from author to address the issue. and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Sep 23, 2020
@gmantri
Copy link
Author

gmantri commented Sep 24, 2020

@jeremymeng Thank you for your help! I am all set.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Docs needs-author-feedback Workflow: More information is needed from author to address the issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

4 participants