@azure/storage-blob 12.13.0-alpha.20230120.2 → 12.13.0-alpha.20230124.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,6 @@ import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tsli
2
2
  import { getDefaultProxySettings, } from "@azure/core-rest-pipeline";
3
3
  import { isTokenCredential } from "@azure/core-auth";
4
4
  import { isNode } from "@azure/core-util";
5
- import { SpanStatusCode } from "@azure/core-tracing";
6
5
  import { v4 as generateUuid } from "uuid";
7
6
  import { BlobDownloadResponse } from "./BlobDownloadResponse";
8
7
  import { BlobQueryResponse } from "./BlobQueryResponse";
@@ -17,7 +16,7 @@ import { StorageClient } from "./StorageClient";
17
16
  import { Batch } from "./utils/Batch";
18
17
  import { BufferScheduler } from "../../storage-common/src";
19
18
  import { BlobDoesNotUseCustomerSpecifiedEncryption, BlobUsesCustomerSpecifiedEncryptionMsg, BLOCK_BLOB_MAX_BLOCKS, BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES, BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES, DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES, DEFAULT_BLOCK_BUFFER_SIZE_BYTES, DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS, ETagAny, URLConstants, } from "./utils/constants";
20
- import { createSpan } from "./utils/tracing";
19
+ import { tracingClient } from "./utils/tracing";
21
20
  import { appendToURLPath, appendToURLQuery, assertResponse, extractConnectionStringParts, ExtractPageRangeInfoItems, generateBlockID, getURLParameter, httpAuthorizationToString, isIpEndpointStyle, parseObjectReplicationRecord, setURLParameter, toBlobTags, toBlobTagsString, toQuerySerialization, toTags, } from "./utils/utils.common";
22
21
  import { fsCreateReadStream, fsStat, readStreamToLocalFile, streamToBuffer, } from "./utils/utils.node";
23
22
  import { generateBlobSASQueryParameters } from "./sas/BlobSASSignatureValues";
@@ -209,12 +208,11 @@ export class BlobClient extends StorageClient {
209
208
  * ```
210
209
  */
211
210
  async download(offset = 0, count, options = {}) {
212
- var _a;
213
211
  options.conditions = options.conditions || {};
214
212
  options.conditions = options.conditions || {};
215
213
  ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
216
- const { span, updatedOptions } = createSpan("BlobClient-download", options);
217
- try {
214
+ return tracingClient.withSpan("BlobClient-download", options, async (updatedOptions) => {
215
+ var _a;
218
216
  const res = assertResponse(await this.blobContext.download({
219
217
  abortSignal: options.abortSignal,
220
218
  leaseAccessConditions: options.conditions,
@@ -280,17 +278,7 @@ export class BlobClient extends StorageClient {
280
278
  maxRetryRequests: options.maxRetryRequests,
281
279
  onProgress: options.onProgress,
282
280
  });
283
- }
284
- catch (e) {
285
- span.setStatus({
286
- code: SpanStatusCode.ERROR,
287
- message: e.message,
288
- });
289
- throw e;
290
- }
291
- finally {
292
- span.end();
293
- }
281
+ });
294
282
  }
295
283
  /**
296
284
  * Returns true if the Azure blob resource represented by this client exists; false otherwise.
@@ -302,37 +290,31 @@ export class BlobClient extends StorageClient {
302
290
  * @param options - options to Exists operation.
303
291
  */
304
292
  async exists(options = {}) {
305
- const { span, updatedOptions } = createSpan("BlobClient-exists", options);
306
- try {
307
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
308
- await this.getProperties({
309
- abortSignal: options.abortSignal,
310
- customerProvidedKey: options.customerProvidedKey,
311
- conditions: options.conditions,
312
- tracingOptions: updatedOptions.tracingOptions,
313
- });
314
- return true;
315
- }
316
- catch (e) {
317
- if (e.statusCode === 404) {
318
- // Expected exception when checking blob existence
319
- return false;
320
- }
321
- else if (e.statusCode === 409 &&
322
- (e.details.errorCode === BlobUsesCustomerSpecifiedEncryptionMsg ||
323
- e.details.errorCode === BlobDoesNotUseCustomerSpecifiedEncryption)) {
324
- // Expected exception when checking blob existence
293
+ return tracingClient.withSpan("BlobClient-exists", options, async (updatedOptions) => {
294
+ try {
295
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
296
+ await this.getProperties({
297
+ abortSignal: options.abortSignal,
298
+ customerProvidedKey: options.customerProvidedKey,
299
+ conditions: options.conditions,
300
+ tracingOptions: updatedOptions.tracingOptions,
301
+ });
325
302
  return true;
326
303
  }
327
- span.setStatus({
328
- code: SpanStatusCode.ERROR,
329
- message: e.message,
330
- });
331
- throw e;
332
- }
333
- finally {
334
- span.end();
335
- }
304
+ catch (e) {
305
+ if (e.statusCode === 404) {
306
+ // Expected exception when checking blob existence
307
+ return false;
308
+ }
309
+ else if (e.statusCode === 409 &&
310
+ (e.details.errorCode === BlobUsesCustomerSpecifiedEncryptionMsg ||
311
+ e.details.errorCode === BlobDoesNotUseCustomerSpecifiedEncryption)) {
312
+ // Expected exception when checking blob existence
313
+ return true;
314
+ }
315
+ throw e;
316
+ }
317
+ });
336
318
  }
337
319
  /**
338
320
  * Returns all user-defined metadata, standard HTTP properties, and system properties
@@ -347,11 +329,10 @@ export class BlobClient extends StorageClient {
347
329
  * @param options - Optional options to Get Properties operation.
348
330
  */
349
331
  async getProperties(options = {}) {
350
- var _a;
351
- const { span, updatedOptions } = createSpan("BlobClient-getProperties", options);
352
- try {
353
- options.conditions = options.conditions || {};
354
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
332
+ options.conditions = options.conditions || {};
333
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
334
+ return tracingClient.withSpan("BlobClient-getProperties", options, async (updatedOptions) => {
335
+ var _a;
355
336
  const res = assertResponse(await this.blobContext.getProperties({
356
337
  abortSignal: options.abortSignal,
357
338
  leaseAccessConditions: options.conditions,
@@ -360,17 +341,7 @@ export class BlobClient extends StorageClient {
360
341
  tracingOptions: updatedOptions.tracingOptions,
361
342
  }));
362
343
  return Object.assign(Object.assign({}, res), { _response: res._response, objectReplicationDestinationPolicyId: res.objectReplicationPolicyId, objectReplicationSourceProperties: parseObjectReplicationRecord(res.objectReplicationRules) });
363
- }
364
- catch (e) {
365
- span.setStatus({
366
- code: SpanStatusCode.ERROR,
367
- message: e.message,
368
- });
369
- throw e;
370
- }
371
- finally {
372
- span.end();
373
- }
344
+ });
374
345
  }
375
346
  /**
376
347
  * Marks the specified blob or snapshot for deletion. The blob is later deleted
@@ -382,10 +353,9 @@ export class BlobClient extends StorageClient {
382
353
  * @param options - Optional options to Blob Delete operation.
383
354
  */
384
355
  async delete(options = {}) {
385
- var _a;
386
- const { span, updatedOptions } = createSpan("BlobClient-delete", options);
387
356
  options.conditions = options.conditions || {};
388
- try {
357
+ return tracingClient.withSpan("BlobClient-delete", options, async (updatedOptions) => {
358
+ var _a;
389
359
  return assertResponse(await this.blobContext.delete({
390
360
  abortSignal: options.abortSignal,
391
361
  deleteSnapshots: options.deleteSnapshots,
@@ -393,17 +363,7 @@ export class BlobClient extends StorageClient {
393
363
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
394
364
  tracingOptions: updatedOptions.tracingOptions,
395
365
  }));
396
- }
397
- catch (e) {
398
- span.setStatus({
399
- code: SpanStatusCode.ERROR,
400
- message: e.message,
401
- });
402
- throw e;
403
- }
404
- finally {
405
- span.end();
406
- }
366
+ });
407
367
  }
408
368
  /**
409
369
  * Marks the specified blob or snapshot for deletion if it exists. The blob is later deleted
@@ -415,29 +375,19 @@ export class BlobClient extends StorageClient {
415
375
  * @param options - Optional options to Blob Delete operation.
416
376
  */
417
377
  async deleteIfExists(options = {}) {
418
- var _a, _b;
419
- const { span, updatedOptions } = createSpan("BlobClient-deleteIfExists", options);
420
- try {
421
- const res = assertResponse(await this.delete(updatedOptions));
422
- return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
423
- }
424
- catch (e) {
425
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobNotFound") {
426
- span.setStatus({
427
- code: SpanStatusCode.ERROR,
428
- message: "Expected exception when deleting a blob or snapshot only if it exists.",
429
- });
430
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
378
+ return tracingClient.withSpan("BlobClient-deleteIfExists", options, async (updatedOptions) => {
379
+ var _a, _b;
380
+ try {
381
+ const res = assertResponse(await this.delete(updatedOptions));
382
+ return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
431
383
  }
432
- span.setStatus({
433
- code: SpanStatusCode.ERROR,
434
- message: e.message,
435
- });
436
- throw e;
437
- }
438
- finally {
439
- span.end();
440
- }
384
+ catch (e) {
385
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobNotFound") {
386
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
387
+ }
388
+ throw e;
389
+ }
390
+ });
441
391
  }
442
392
  /**
443
393
  * Restores the contents and metadata of soft deleted blob and any associated
@@ -448,23 +398,12 @@ export class BlobClient extends StorageClient {
448
398
  * @param options - Optional options to Blob Undelete operation.
449
399
  */
450
400
  async undelete(options = {}) {
451
- const { span, updatedOptions } = createSpan("BlobClient-undelete", options);
452
- try {
401
+ return tracingClient.withSpan("BlobClient-undelete", options, async (updatedOptions) => {
453
402
  return assertResponse(await this.blobContext.undelete({
454
403
  abortSignal: options.abortSignal,
455
404
  tracingOptions: updatedOptions.tracingOptions,
456
405
  }));
457
- }
458
- catch (e) {
459
- span.setStatus({
460
- code: SpanStatusCode.ERROR,
461
- message: e.message,
462
- });
463
- throw e;
464
- }
465
- finally {
466
- span.end();
467
- }
406
+ });
468
407
  }
469
408
  /**
470
409
  * Sets system properties on the blob.
@@ -482,11 +421,10 @@ export class BlobClient extends StorageClient {
482
421
  * @param options - Optional options to Blob Set HTTP Headers operation.
483
422
  */
484
423
  async setHTTPHeaders(blobHTTPHeaders, options = {}) {
485
- var _a;
486
- const { span, updatedOptions } = createSpan("BlobClient-setHTTPHeaders", options);
487
424
  options.conditions = options.conditions || {};
488
- try {
489
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
425
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
426
+ return tracingClient.withSpan("BlobClient-setHTTPHeaders", options, async (updatedOptions) => {
427
+ var _a;
490
428
  return assertResponse(await this.blobContext.setHttpHeaders({
491
429
  abortSignal: options.abortSignal,
492
430
  blobHttpHeaders: blobHTTPHeaders,
@@ -495,17 +433,7 @@ export class BlobClient extends StorageClient {
495
433
  // cpkInfo: options.customerProvidedKey, // CPK is not included in Swagger, should change this back when this issue is fixed in Swagger.
496
434
  tracingOptions: updatedOptions.tracingOptions,
497
435
  }));
498
- }
499
- catch (e) {
500
- span.setStatus({
501
- code: SpanStatusCode.ERROR,
502
- message: e.message,
503
- });
504
- throw e;
505
- }
506
- finally {
507
- span.end();
508
- }
436
+ });
509
437
  }
510
438
  /**
511
439
  * Sets user-defined metadata for the specified blob as one or more name-value pairs.
@@ -519,11 +447,10 @@ export class BlobClient extends StorageClient {
519
447
  * @param options - Optional options to Set Metadata operation.
520
448
  */
521
449
  async setMetadata(metadata, options = {}) {
522
- var _a;
523
- const { span, updatedOptions } = createSpan("BlobClient-setMetadata", options);
524
450
  options.conditions = options.conditions || {};
525
- try {
526
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
451
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
452
+ return tracingClient.withSpan("BlobClient-setMetadata", options, async (updatedOptions) => {
453
+ var _a;
527
454
  return assertResponse(await this.blobContext.setMetadata({
528
455
  abortSignal: options.abortSignal,
529
456
  leaseAccessConditions: options.conditions,
@@ -533,17 +460,7 @@ export class BlobClient extends StorageClient {
533
460
  encryptionScope: options.encryptionScope,
534
461
  tracingOptions: updatedOptions.tracingOptions,
535
462
  }));
536
- }
537
- catch (e) {
538
- span.setStatus({
539
- code: SpanStatusCode.ERROR,
540
- message: e.message,
541
- });
542
- throw e;
543
- }
544
- finally {
545
- span.end();
546
- }
463
+ });
547
464
  }
548
465
  /**
549
466
  * Sets tags on the underlying blob.
@@ -555,9 +472,8 @@ export class BlobClient extends StorageClient {
555
472
  * @param options -
556
473
  */
557
474
  async setTags(tags, options = {}) {
558
- var _a;
559
- const { span, updatedOptions } = createSpan("BlobClient-setTags", options);
560
- try {
475
+ return tracingClient.withSpan("BlobClient-setTags", options, async (updatedOptions) => {
476
+ var _a;
561
477
  return assertResponse(await this.blobContext.setTags({
562
478
  abortSignal: options.abortSignal,
563
479
  leaseAccessConditions: options.conditions,
@@ -565,17 +481,7 @@ export class BlobClient extends StorageClient {
565
481
  tracingOptions: updatedOptions.tracingOptions,
566
482
  tags: toBlobTags(tags),
567
483
  }));
568
- }
569
- catch (e) {
570
- span.setStatus({
571
- code: SpanStatusCode.ERROR,
572
- message: e.message,
573
- });
574
- throw e;
575
- }
576
- finally {
577
- span.end();
578
- }
484
+ });
579
485
  }
580
486
  /**
581
487
  * Gets the tags associated with the underlying blob.
@@ -583,9 +489,8 @@ export class BlobClient extends StorageClient {
583
489
  * @param options -
584
490
  */
585
491
  async getTags(options = {}) {
586
- var _a;
587
- const { span, updatedOptions } = createSpan("BlobClient-getTags", options);
588
- try {
492
+ return tracingClient.withSpan("BlobClient-getTags", options, async (updatedOptions) => {
493
+ var _a;
589
494
  const response = assertResponse(await this.blobContext.getTags({
590
495
  abortSignal: options.abortSignal,
591
496
  leaseAccessConditions: options.conditions,
@@ -594,17 +499,7 @@ export class BlobClient extends StorageClient {
594
499
  }));
595
500
  const wrappedResponse = Object.assign(Object.assign({}, response), { _response: response._response, tags: toTags({ blobTagSet: response.blobTagSet }) || {} });
596
501
  return wrappedResponse;
597
- }
598
- catch (e) {
599
- span.setStatus({
600
- code: SpanStatusCode.ERROR,
601
- message: e.message,
602
- });
603
- throw e;
604
- }
605
- finally {
606
- span.end();
607
- }
502
+ });
608
503
  }
609
504
  /**
610
505
  * Get a {@link BlobLeaseClient} that manages leases on the blob.
@@ -622,11 +517,10 @@ export class BlobClient extends StorageClient {
622
517
  * @param options - Optional options to the Blob Create Snapshot operation.
623
518
  */
624
519
  async createSnapshot(options = {}) {
625
- var _a;
626
- const { span, updatedOptions } = createSpan("BlobClient-createSnapshot", options);
627
520
  options.conditions = options.conditions || {};
628
- try {
629
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
521
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
522
+ return tracingClient.withSpan("BlobClient-createSnapshot", options, async (updatedOptions) => {
523
+ var _a;
630
524
  return assertResponse(await this.blobContext.createSnapshot({
631
525
  abortSignal: options.abortSignal,
632
526
  leaseAccessConditions: options.conditions,
@@ -636,17 +530,7 @@ export class BlobClient extends StorageClient {
636
530
  encryptionScope: options.encryptionScope,
637
531
  tracingOptions: updatedOptions.tracingOptions,
638
532
  }));
639
- }
640
- catch (e) {
641
- span.setStatus({
642
- code: SpanStatusCode.ERROR,
643
- message: e.message,
644
- });
645
- throw e;
646
- }
647
- finally {
648
- span.end();
649
- }
533
+ });
650
534
  }
651
535
  /**
652
536
  * Asynchronously copies a blob to a destination within the storage account.
@@ -748,24 +632,13 @@ export class BlobClient extends StorageClient {
748
632
  * @param options - Optional options to the Blob Abort Copy From URL operation.
749
633
  */
750
634
  async abortCopyFromURL(copyId, options = {}) {
751
- const { span, updatedOptions } = createSpan("BlobClient-abortCopyFromURL", options);
752
- try {
635
+ return tracingClient.withSpan("BlobClient-abortCopyFromURL", options, async (updatedOptions) => {
753
636
  return assertResponse(await this.blobContext.abortCopyFromURL(copyId, {
754
637
  abortSignal: options.abortSignal,
755
638
  leaseAccessConditions: options.conditions,
756
639
  tracingOptions: updatedOptions.tracingOptions,
757
640
  }));
758
- }
759
- catch (e) {
760
- span.setStatus({
761
- code: SpanStatusCode.ERROR,
762
- message: e.message,
763
- });
764
- throw e;
765
- }
766
- finally {
767
- span.end();
768
- }
641
+ });
769
642
  }
770
643
  /**
771
644
  * The synchronous Copy From URL operation copies a blob or an internet resource to a new blob. It will not
@@ -776,44 +649,33 @@ export class BlobClient extends StorageClient {
776
649
  * @param options -
777
650
  */
778
651
  async syncCopyFromURL(copySource, options = {}) {
779
- var _a, _b, _c;
780
- const { span, updatedOptions } = createSpan("BlobClient-syncCopyFromURL", options);
781
652
  options.conditions = options.conditions || {};
782
653
  options.sourceConditions = options.sourceConditions || {};
783
- try {
654
+ return tracingClient.withSpan("BlobClient-syncCopyFromURL", options, async (updatedOptions) => {
655
+ var _a, _b, _c, _d, _e, _f, _g;
784
656
  return assertResponse(await this.blobContext.copyFromURL(copySource, {
785
657
  abortSignal: options.abortSignal,
786
658
  metadata: options.metadata,
787
659
  leaseAccessConditions: options.conditions,
788
660
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
789
661
  sourceModifiedAccessConditions: {
790
- sourceIfMatch: options.sourceConditions.ifMatch,
791
- sourceIfModifiedSince: options.sourceConditions.ifModifiedSince,
792
- sourceIfNoneMatch: options.sourceConditions.ifNoneMatch,
793
- sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince,
662
+ sourceIfMatch: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifMatch,
663
+ sourceIfModifiedSince: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifModifiedSince,
664
+ sourceIfNoneMatch: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch,
665
+ sourceIfUnmodifiedSince: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.ifUnmodifiedSince,
794
666
  },
795
667
  sourceContentMD5: options.sourceContentMD5,
796
668
  copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization),
797
669
  tier: toAccessTier(options.tier),
798
670
  blobTagsString: toBlobTagsString(options.tags),
799
- immutabilityPolicyExpiry: (_b = options.immutabilityPolicy) === null || _b === void 0 ? void 0 : _b.expiriesOn,
800
- immutabilityPolicyMode: (_c = options.immutabilityPolicy) === null || _c === void 0 ? void 0 : _c.policyMode,
671
+ immutabilityPolicyExpiry: (_f = options.immutabilityPolicy) === null || _f === void 0 ? void 0 : _f.expiriesOn,
672
+ immutabilityPolicyMode: (_g = options.immutabilityPolicy) === null || _g === void 0 ? void 0 : _g.policyMode,
801
673
  legalHold: options.legalHold,
802
674
  encryptionScope: options.encryptionScope,
803
675
  copySourceTags: options.copySourceTags,
804
676
  tracingOptions: updatedOptions.tracingOptions,
805
677
  }));
806
- }
807
- catch (e) {
808
- span.setStatus({
809
- code: SpanStatusCode.ERROR,
810
- message: e.message,
811
- });
812
- throw e;
813
- }
814
- finally {
815
- span.end();
816
- }
678
+ });
817
679
  }
818
680
  /**
819
681
  * Sets the tier on a blob. The operation is allowed on a page blob in a premium
@@ -827,9 +689,8 @@ export class BlobClient extends StorageClient {
827
689
  * @param options - Optional options to the Blob Set Tier operation.
828
690
  */
829
691
  async setAccessTier(tier, options = {}) {
830
- var _a;
831
- const { span, updatedOptions } = createSpan("BlobClient-setAccessTier", options);
832
- try {
692
+ return tracingClient.withSpan("BlobClient-setAccessTier", options, async (updatedOptions) => {
693
+ var _a;
833
694
  return assertResponse(await this.blobContext.setTier(toAccessTier(tier), {
834
695
  abortSignal: options.abortSignal,
835
696
  leaseAccessConditions: options.conditions,
@@ -837,19 +698,10 @@ export class BlobClient extends StorageClient {
837
698
  rehydratePriority: options.rehydratePriority,
838
699
  tracingOptions: updatedOptions.tracingOptions,
839
700
  }));
840
- }
841
- catch (e) {
842
- span.setStatus({
843
- code: SpanStatusCode.ERROR,
844
- message: e.message,
845
- });
846
- throw e;
847
- }
848
- finally {
849
- span.end();
850
- }
701
+ });
851
702
  }
852
703
  async downloadToBuffer(param1, param2, param3, param4 = {}) {
704
+ var _a;
853
705
  let buffer;
854
706
  let offset = 0;
855
707
  let count = 0;
@@ -864,26 +716,23 @@ export class BlobClient extends StorageClient {
864
716
  count = typeof param2 === "number" ? param2 : 0;
865
717
  options = param3 || {};
866
718
  }
867
- const { span, updatedOptions } = createSpan("BlobClient-downloadToBuffer", options);
868
- try {
869
- if (!options.blockSize) {
870
- options.blockSize = 0;
871
- }
872
- if (options.blockSize < 0) {
873
- throw new RangeError("blockSize option must be >= 0");
874
- }
875
- if (options.blockSize === 0) {
876
- options.blockSize = DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES;
877
- }
878
- if (offset < 0) {
879
- throw new RangeError("offset option must be >= 0");
880
- }
881
- if (count && count <= 0) {
882
- throw new RangeError("count option must be greater than 0");
883
- }
884
- if (!options.conditions) {
885
- options.conditions = {};
886
- }
719
+ let blockSize = (_a = options.blockSize) !== null && _a !== void 0 ? _a : 0;
720
+ if (blockSize < 0) {
721
+ throw new RangeError("blockSize option must be >= 0");
722
+ }
723
+ if (blockSize === 0) {
724
+ blockSize = DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES;
725
+ }
726
+ if (offset < 0) {
727
+ throw new RangeError("offset option must be >= 0");
728
+ }
729
+ if (count && count <= 0) {
730
+ throw new RangeError("count option must be greater than 0");
731
+ }
732
+ if (!options.conditions) {
733
+ options.conditions = {};
734
+ }
735
+ return tracingClient.withSpan("BlobClient-downloadToBuffer", options, async (updatedOptions) => {
887
736
  // Customer doesn't specify length, get it
888
737
  if (!count) {
889
738
  const response = await this.getProperties(Object.assign(Object.assign({}, options), { tracingOptions: updatedOptions.tracingOptions }));
@@ -906,12 +755,12 @@ export class BlobClient extends StorageClient {
906
755
  }
907
756
  let transferProgress = 0;
908
757
  const batch = new Batch(options.concurrency);
909
- for (let off = offset; off < offset + count; off = off + options.blockSize) {
758
+ for (let off = offset; off < offset + count; off = off + blockSize) {
910
759
  batch.addOperation(async () => {
911
760
  // Exclusive chunk end position
912
761
  let chunkEnd = offset + count;
913
- if (off + options.blockSize < chunkEnd) {
914
- chunkEnd = off + options.blockSize;
762
+ if (off + blockSize < chunkEnd) {
763
+ chunkEnd = off + blockSize;
915
764
  }
916
765
  const response = await this.download(off, chunkEnd - off, {
917
766
  abortSignal: options.abortSignal,
@@ -933,17 +782,7 @@ export class BlobClient extends StorageClient {
933
782
  }
934
783
  await batch.do();
935
784
  return buffer;
936
- }
937
- catch (e) {
938
- span.setStatus({
939
- code: SpanStatusCode.ERROR,
940
- message: e.message,
941
- });
942
- throw e;
943
- }
944
- finally {
945
- span.end();
946
- }
785
+ });
947
786
  }
948
787
  /**
949
788
  * ONLY AVAILABLE IN NODE.JS RUNTIME.
@@ -962,8 +801,7 @@ export class BlobClient extends StorageClient {
962
801
  * at the specified path.
963
802
  */
964
803
  async downloadToFile(filePath, offset = 0, count, options = {}) {
965
- const { span, updatedOptions } = createSpan("BlobClient-downloadToFile", options);
966
- try {
804
+ return tracingClient.withSpan("BlobClient-downloadToFile", options, async (updatedOptions) => {
967
805
  const response = await this.download(offset, count, Object.assign(Object.assign({}, options), { tracingOptions: updatedOptions.tracingOptions }));
968
806
  if (response.readableStreamBody) {
969
807
  await readStreamToLocalFile(response.readableStreamBody, filePath);
@@ -971,17 +809,7 @@ export class BlobClient extends StorageClient {
971
809
  // The stream is no longer accessible so setting it to undefined.
972
810
  response.blobDownloadStream = undefined;
973
811
  return response;
974
- }
975
- catch (e) {
976
- span.setStatus({
977
- code: SpanStatusCode.ERROR,
978
- message: e.message,
979
- });
980
- throw e;
981
- }
982
- finally {
983
- span.end();
984
- }
812
+ });
985
813
  }
986
814
  getBlobAndContainerNamesFromUrl() {
987
815
  let containerName;
@@ -1046,11 +874,10 @@ export class BlobClient extends StorageClient {
1046
874
  * @param options - Optional options to the Blob Start Copy From URL operation.
1047
875
  */
1048
876
  async startCopyFromURL(copySource, options = {}) {
1049
- var _a, _b, _c;
1050
- const { span, updatedOptions } = createSpan("BlobClient-startCopyFromURL", options);
1051
- options.conditions = options.conditions || {};
1052
- options.sourceConditions = options.sourceConditions || {};
1053
- try {
877
+ return tracingClient.withSpan("BlobClient-startCopyFromURL", options, async (updatedOptions) => {
878
+ var _a, _b, _c;
879
+ options.conditions = options.conditions || {};
880
+ options.sourceConditions = options.sourceConditions || {};
1054
881
  return assertResponse(await this.blobContext.startCopyFromURL(copySource, {
1055
882
  abortSignal: options.abortSignal,
1056
883
  leaseAccessConditions: options.conditions,
@@ -1072,17 +899,7 @@ export class BlobClient extends StorageClient {
1072
899
  sealBlob: options.sealBlob,
1073
900
  tracingOptions: updatedOptions.tracingOptions,
1074
901
  }));
1075
- }
1076
- catch (e) {
1077
- span.setStatus({
1078
- code: SpanStatusCode.ERROR,
1079
- message: e.message,
1080
- });
1081
- throw e;
1082
- }
1083
- finally {
1084
- span.end();
1085
- }
902
+ });
1086
903
  }
1087
904
  /**
1088
905
  * Only available for BlobClient constructed with a shared key credential.
@@ -1109,71 +926,38 @@ export class BlobClient extends StorageClient {
1109
926
  *
1110
927
  * @param options - Optional options to delete immutability policy on the blob.
1111
928
  */
1112
- async deleteImmutabilityPolicy(options) {
1113
- const { span, updatedOptions } = createSpan("BlobClient-deleteImmutabilityPolicy", options);
1114
- try {
929
+ async deleteImmutabilityPolicy(options = {}) {
930
+ return tracingClient.withSpan("BlobClient-deleteImmutabilityPolicy", options, async (updatedOptions) => {
1115
931
  return assertResponse(await this.blobContext.deleteImmutabilityPolicy({
1116
932
  tracingOptions: updatedOptions.tracingOptions,
1117
933
  }));
1118
- }
1119
- catch (e) {
1120
- span.setStatus({
1121
- code: SpanStatusCode.ERROR,
1122
- message: e.message,
1123
- });
1124
- throw e;
1125
- }
1126
- finally {
1127
- span.end();
1128
- }
934
+ });
1129
935
  }
1130
936
  /**
1131
- * Set immutablility policy on the blob.
937
+ * Set immutability policy on the blob.
1132
938
  *
1133
939
  * @param options - Optional options to set immutability policy on the blob.
1134
940
  */
1135
- async setImmutabilityPolicy(immutabilityPolicy, options) {
1136
- const { span, updatedOptions } = createSpan("BlobClient-setImmutabilityPolicy", options);
1137
- try {
941
+ async setImmutabilityPolicy(immutabilityPolicy, options = {}) {
942
+ return tracingClient.withSpan("BlobClient-setImmutabilityPolicy", options, async (updatedOptions) => {
1138
943
  return assertResponse(await this.blobContext.setImmutabilityPolicy({
1139
944
  immutabilityPolicyExpiry: immutabilityPolicy.expiriesOn,
1140
945
  immutabilityPolicyMode: immutabilityPolicy.policyMode,
1141
946
  tracingOptions: updatedOptions.tracingOptions,
1142
947
  }));
1143
- }
1144
- catch (e) {
1145
- span.setStatus({
1146
- code: SpanStatusCode.ERROR,
1147
- message: e.message,
1148
- });
1149
- throw e;
1150
- }
1151
- finally {
1152
- span.end();
1153
- }
948
+ });
1154
949
  }
1155
950
  /**
1156
951
  * Set legal hold on the blob.
1157
952
  *
1158
953
  * @param options - Optional options to set legal hold on the blob.
1159
954
  */
1160
- async setLegalHold(legalHoldEnabled, options) {
1161
- const { span, updatedOptions } = createSpan("BlobClient-setLegalHold", options);
1162
- try {
955
+ async setLegalHold(legalHoldEnabled, options = {}) {
956
+ return tracingClient.withSpan("BlobClient-setLegalHold", options, async (updatedOptions) => {
1163
957
  return assertResponse(await this.blobContext.setLegalHold(legalHoldEnabled, {
1164
958
  tracingOptions: updatedOptions.tracingOptions,
1165
959
  }));
1166
- }
1167
- catch (e) {
1168
- span.setStatus({
1169
- code: SpanStatusCode.ERROR,
1170
- message: e.message,
1171
- });
1172
- throw e;
1173
- }
1174
- finally {
1175
- span.end();
1176
- }
960
+ });
1177
961
  }
1178
962
  }
1179
963
  /**
@@ -1273,11 +1057,10 @@ export class AppendBlobClient extends BlobClient {
1273
1057
  * ```
1274
1058
  */
1275
1059
  async create(options = {}) {
1276
- var _a, _b, _c;
1277
- const { span, updatedOptions } = createSpan("AppendBlobClient-create", options);
1278
1060
  options.conditions = options.conditions || {};
1279
- try {
1280
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1061
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1062
+ return tracingClient.withSpan("AppendBlobClient-create", options, async (updatedOptions) => {
1063
+ var _a, _b, _c;
1281
1064
  return assertResponse(await this.appendBlobContext.create(0, {
1282
1065
  abortSignal: options.abortSignal,
1283
1066
  blobHttpHeaders: options.blobHTTPHeaders,
@@ -1292,17 +1075,7 @@ export class AppendBlobClient extends BlobClient {
1292
1075
  blobTagsString: toBlobTagsString(options.tags),
1293
1076
  tracingOptions: updatedOptions.tracingOptions,
1294
1077
  }));
1295
- }
1296
- catch (e) {
1297
- span.setStatus({
1298
- code: SpanStatusCode.ERROR,
1299
- message: e.message,
1300
- });
1301
- throw e;
1302
- }
1303
- finally {
1304
- span.end();
1305
- }
1078
+ });
1306
1079
  }
1307
1080
  /**
1308
1081
  * Creates a 0-length append blob. Call AppendBlock to append data to an append blob.
@@ -1312,30 +1085,20 @@ export class AppendBlobClient extends BlobClient {
1312
1085
  * @param options -
1313
1086
  */
1314
1087
  async createIfNotExists(options = {}) {
1315
- var _a, _b;
1316
- const { span, updatedOptions } = createSpan("AppendBlobClient-createIfNotExists", options);
1317
1088
  const conditions = { ifNoneMatch: ETagAny };
1318
- try {
1319
- const res = assertResponse(await this.create(Object.assign(Object.assign({}, updatedOptions), { conditions })));
1320
- return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
1321
- }
1322
- catch (e) {
1323
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobAlreadyExists") {
1324
- span.setStatus({
1325
- code: SpanStatusCode.ERROR,
1326
- message: "Expected exception when creating a blob only if it does not already exist.",
1327
- });
1328
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
1089
+ return tracingClient.withSpan("AppendBlobClient-createIfNotExists", options, async (updatedOptions) => {
1090
+ var _a, _b;
1091
+ try {
1092
+ const res = assertResponse(await this.create(Object.assign(Object.assign({}, updatedOptions), { conditions })));
1093
+ return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
1329
1094
  }
1330
- span.setStatus({
1331
- code: SpanStatusCode.ERROR,
1332
- message: e.message,
1333
- });
1334
- throw e;
1335
- }
1336
- finally {
1337
- span.end();
1338
- }
1095
+ catch (e) {
1096
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobAlreadyExists") {
1097
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
1098
+ }
1099
+ throw e;
1100
+ }
1101
+ });
1339
1102
  }
1340
1103
  /**
1341
1104
  * Seals the append blob, making it read only.
@@ -1343,10 +1106,9 @@ export class AppendBlobClient extends BlobClient {
1343
1106
  * @param options -
1344
1107
  */
1345
1108
  async seal(options = {}) {
1346
- var _a;
1347
- const { span, updatedOptions } = createSpan("AppendBlobClient-seal", options);
1348
1109
  options.conditions = options.conditions || {};
1349
- try {
1110
+ return tracingClient.withSpan("AppendBlobClient-seal", options, async (updatedOptions) => {
1111
+ var _a;
1350
1112
  return assertResponse(await this.appendBlobContext.seal({
1351
1113
  abortSignal: options.abortSignal,
1352
1114
  appendPositionAccessConditions: options.conditions,
@@ -1354,17 +1116,7 @@ export class AppendBlobClient extends BlobClient {
1354
1116
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
1355
1117
  tracingOptions: updatedOptions.tracingOptions,
1356
1118
  }));
1357
- }
1358
- catch (e) {
1359
- span.setStatus({
1360
- code: SpanStatusCode.ERROR,
1361
- message: e.message,
1362
- });
1363
- throw e;
1364
- }
1365
- finally {
1366
- span.end();
1367
- }
1119
+ });
1368
1120
  }
1369
1121
  /**
1370
1122
  * Commits a new block of data to the end of the existing append blob.
@@ -1391,11 +1143,10 @@ export class AppendBlobClient extends BlobClient {
1391
1143
  * ```
1392
1144
  */
1393
1145
  async appendBlock(body, contentLength, options = {}) {
1394
- var _a;
1395
- const { span, updatedOptions } = createSpan("AppendBlobClient-appendBlock", options);
1396
1146
  options.conditions = options.conditions || {};
1397
- try {
1398
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1147
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1148
+ return tracingClient.withSpan("AppendBlobClient-appendBlock", options, async (updatedOptions) => {
1149
+ var _a;
1399
1150
  return assertResponse(await this.appendBlobContext.appendBlock(contentLength, body, {
1400
1151
  abortSignal: options.abortSignal,
1401
1152
  appendPositionAccessConditions: options.conditions,
@@ -1410,17 +1161,7 @@ export class AppendBlobClient extends BlobClient {
1410
1161
  encryptionScope: options.encryptionScope,
1411
1162
  tracingOptions: updatedOptions.tracingOptions,
1412
1163
  }));
1413
- }
1414
- catch (e) {
1415
- span.setStatus({
1416
- code: SpanStatusCode.ERROR,
1417
- message: e.message,
1418
- });
1419
- throw e;
1420
- }
1421
- finally {
1422
- span.end();
1423
- }
1164
+ });
1424
1165
  }
1425
1166
  /**
1426
1167
  * The Append Block operation commits a new block of data to the end of an existing append blob
@@ -1437,12 +1178,11 @@ export class AppendBlobClient extends BlobClient {
1437
1178
  * @param options -
1438
1179
  */
1439
1180
  async appendBlockFromURL(sourceURL, sourceOffset, count, options = {}) {
1440
- var _a;
1441
- const { span, updatedOptions } = createSpan("AppendBlobClient-appendBlockFromURL", options);
1442
1181
  options.conditions = options.conditions || {};
1443
1182
  options.sourceConditions = options.sourceConditions || {};
1444
- try {
1445
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1183
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1184
+ return tracingClient.withSpan("AppendBlobClient-appendBlockFromURL", options, async (updatedOptions) => {
1185
+ var _a, _b, _c, _d, _e;
1446
1186
  return assertResponse(await this.appendBlobContext.appendBlockFromUrl(sourceURL, 0, {
1447
1187
  abortSignal: options.abortSignal,
1448
1188
  sourceRange: rangeToString({ offset: sourceOffset, count }),
@@ -1452,27 +1192,17 @@ export class AppendBlobClient extends BlobClient {
1452
1192
  appendPositionAccessConditions: options.conditions,
1453
1193
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
1454
1194
  sourceModifiedAccessConditions: {
1455
- sourceIfMatch: options.sourceConditions.ifMatch,
1456
- sourceIfModifiedSince: options.sourceConditions.ifModifiedSince,
1457
- sourceIfNoneMatch: options.sourceConditions.ifNoneMatch,
1458
- sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince,
1195
+ sourceIfMatch: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifMatch,
1196
+ sourceIfModifiedSince: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifModifiedSince,
1197
+ sourceIfNoneMatch: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch,
1198
+ sourceIfUnmodifiedSince: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.ifUnmodifiedSince,
1459
1199
  },
1460
1200
  copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization),
1461
1201
  cpkInfo: options.customerProvidedKey,
1462
1202
  encryptionScope: options.encryptionScope,
1463
1203
  tracingOptions: updatedOptions.tracingOptions,
1464
1204
  }));
1465
- }
1466
- catch (e) {
1467
- span.setStatus({
1468
- code: SpanStatusCode.ERROR,
1469
- message: e.message,
1470
- });
1471
- throw e;
1472
- }
1473
- finally {
1474
- span.end();
1475
- }
1205
+ });
1476
1206
  }
1477
1207
  }
1478
1208
  /**
@@ -1589,14 +1319,12 @@ export class BlockBlobClient extends BlobClient {
1589
1319
  * @param options -
1590
1320
  */
1591
1321
  async query(query, options = {}) {
1592
- var _a;
1593
1322
  ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1594
- const { span, updatedOptions } = createSpan("BlockBlobClient-query", options);
1595
- try {
1596
- if (!isNode) {
1597
- throw new Error("This operation currently is only supported in Node.js.");
1598
- }
1599
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1323
+ if (!isNode) {
1324
+ throw new Error("This operation currently is only supported in Node.js.");
1325
+ }
1326
+ return tracingClient.withSpan("BlockBlobClient-query", options, async (updatedOptions) => {
1327
+ var _a;
1600
1328
  const response = assertResponse(await this._blobContext.query({
1601
1329
  abortSignal: options.abortSignal,
1602
1330
  queryRequest: {
@@ -1615,17 +1343,7 @@ export class BlockBlobClient extends BlobClient {
1615
1343
  onProgress: options.onProgress,
1616
1344
  onError: options.onError,
1617
1345
  });
1618
- }
1619
- catch (e) {
1620
- span.setStatus({
1621
- code: SpanStatusCode.ERROR,
1622
- message: e.message,
1623
- });
1624
- throw e;
1625
- }
1626
- finally {
1627
- span.end();
1628
- }
1346
+ });
1629
1347
  }
1630
1348
  /**
1631
1349
  * Creates a new block blob, or updates the content of an existing block blob.
@@ -1655,11 +1373,10 @@ export class BlockBlobClient extends BlobClient {
1655
1373
  * ```
1656
1374
  */
1657
1375
  async upload(body, contentLength, options = {}) {
1658
- var _a, _b, _c;
1659
1376
  options.conditions = options.conditions || {};
1660
- const { span, updatedOptions } = createSpan("BlockBlobClient-upload", options);
1661
- try {
1662
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1377
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1378
+ return tracingClient.withSpan("BlockBlobClient-upload", options, async (updatedOptions) => {
1379
+ var _a, _b, _c;
1663
1380
  return assertResponse(await this.blockBlobContext.upload(contentLength, body, {
1664
1381
  abortSignal: options.abortSignal,
1665
1382
  blobHttpHeaders: options.blobHTTPHeaders,
@@ -1678,17 +1395,7 @@ export class BlockBlobClient extends BlobClient {
1678
1395
  blobTagsString: toBlobTagsString(options.tags),
1679
1396
  tracingOptions: updatedOptions.tracingOptions,
1680
1397
  }));
1681
- }
1682
- catch (e) {
1683
- span.setStatus({
1684
- code: SpanStatusCode.ERROR,
1685
- message: e.message,
1686
- });
1687
- throw e;
1688
- }
1689
- finally {
1690
- span.end();
1691
- }
1398
+ });
1692
1399
  }
1693
1400
  /**
1694
1401
  * Creates a new Block Blob where the contents of the blob are read from a given URL.
@@ -1709,29 +1416,18 @@ export class BlockBlobClient extends BlobClient {
1709
1416
  * @param options - Optional parameters.
1710
1417
  */
1711
1418
  async syncUploadFromURL(sourceURL, options = {}) {
1712
- var _a, _b, _c, _d, _e;
1713
1419
  options.conditions = options.conditions || {};
1714
- const { span, updatedOptions } = createSpan("BlockBlobClient-syncUploadFromURL", options);
1715
- try {
1716
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1717
- return assertResponse(await this.blockBlobContext.putBlobFromUrl(0, sourceURL, Object.assign(Object.assign({}, options), { blobHttpHeaders: options.blobHTTPHeaders, leaseAccessConditions: options.conditions, modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: options.conditions.tagConditions }), sourceModifiedAccessConditions: {
1718
- sourceIfMatch: (_a = options.sourceConditions) === null || _a === void 0 ? void 0 : _a.ifMatch,
1719
- sourceIfModifiedSince: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifModifiedSince,
1720
- sourceIfNoneMatch: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifNoneMatch,
1721
- sourceIfUnmodifiedSince: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifUnmodifiedSince,
1722
- sourceIfTags: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.tagConditions,
1420
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1421
+ return tracingClient.withSpan("BlockBlobClient-syncUploadFromURL", options, async (updatedOptions) => {
1422
+ var _a, _b, _c, _d, _e, _f;
1423
+ return assertResponse(await this.blockBlobContext.putBlobFromUrl(0, sourceURL, Object.assign(Object.assign({}, options), { blobHttpHeaders: options.blobHTTPHeaders, leaseAccessConditions: options.conditions, modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }), sourceModifiedAccessConditions: {
1424
+ sourceIfMatch: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifMatch,
1425
+ sourceIfModifiedSince: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifModifiedSince,
1426
+ sourceIfNoneMatch: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch,
1427
+ sourceIfUnmodifiedSince: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.ifUnmodifiedSince,
1428
+ sourceIfTags: (_f = options.sourceConditions) === null || _f === void 0 ? void 0 : _f.tagConditions,
1723
1429
  }, cpkInfo: options.customerProvidedKey, copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization), tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags), copySourceTags: options.copySourceTags, tracingOptions: updatedOptions.tracingOptions })));
1724
- }
1725
- catch (e) {
1726
- span.setStatus({
1727
- code: SpanStatusCode.ERROR,
1728
- message: e.message,
1729
- });
1730
- throw e;
1731
- }
1732
- finally {
1733
- span.end();
1734
- }
1430
+ });
1735
1431
  }
1736
1432
  /**
1737
1433
  * Uploads the specified block to the block blob's "staging area" to be later
@@ -1745,9 +1441,8 @@ export class BlockBlobClient extends BlobClient {
1745
1441
  * @returns Response data for the Block Blob Stage Block operation.
1746
1442
  */
1747
1443
  async stageBlock(blockId, body, contentLength, options = {}) {
1748
- const { span, updatedOptions } = createSpan("BlockBlobClient-stageBlock", options);
1749
- try {
1750
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1444
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1445
+ return tracingClient.withSpan("BlockBlobClient-stageBlock", options, async (updatedOptions) => {
1751
1446
  return assertResponse(await this.blockBlobContext.stageBlock(blockId, contentLength, body, {
1752
1447
  abortSignal: options.abortSignal,
1753
1448
  leaseAccessConditions: options.conditions,
@@ -1760,17 +1455,7 @@ export class BlockBlobClient extends BlobClient {
1760
1455
  encryptionScope: options.encryptionScope,
1761
1456
  tracingOptions: updatedOptions.tracingOptions,
1762
1457
  }));
1763
- }
1764
- catch (e) {
1765
- span.setStatus({
1766
- code: SpanStatusCode.ERROR,
1767
- message: e.message,
1768
- });
1769
- throw e;
1770
- }
1771
- finally {
1772
- span.end();
1773
- }
1458
+ });
1774
1459
  }
1775
1460
  /**
1776
1461
  * The Stage Block From URL operation creates a new block to be committed as part
@@ -1794,9 +1479,8 @@ export class BlockBlobClient extends BlobClient {
1794
1479
  * @returns Response data for the Block Blob Stage Block From URL operation.
1795
1480
  */
1796
1481
  async stageBlockFromURL(blockId, sourceURL, offset = 0, count, options = {}) {
1797
- const { span, updatedOptions } = createSpan("BlockBlobClient-stageBlockFromURL", options);
1798
- try {
1799
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1482
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1483
+ return tracingClient.withSpan("BlockBlobClient-stageBlockFromURL", options, async (updatedOptions) => {
1800
1484
  return assertResponse(await this.blockBlobContext.stageBlockFromURL(blockId, 0, sourceURL, {
1801
1485
  abortSignal: options.abortSignal,
1802
1486
  leaseAccessConditions: options.conditions,
@@ -1808,17 +1492,7 @@ export class BlockBlobClient extends BlobClient {
1808
1492
  copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization),
1809
1493
  tracingOptions: updatedOptions.tracingOptions,
1810
1494
  }));
1811
- }
1812
- catch (e) {
1813
- span.setStatus({
1814
- code: SpanStatusCode.ERROR,
1815
- message: e.message,
1816
- });
1817
- throw e;
1818
- }
1819
- finally {
1820
- span.end();
1821
- }
1495
+ });
1822
1496
  }
1823
1497
  /**
1824
1498
  * Writes a blob by specifying the list of block IDs that make up the blob.
@@ -1833,11 +1507,10 @@ export class BlockBlobClient extends BlobClient {
1833
1507
  * @returns Response data for the Block Blob Commit Block List operation.
1834
1508
  */
1835
1509
  async commitBlockList(blocks, options = {}) {
1836
- var _a, _b, _c;
1837
1510
  options.conditions = options.conditions || {};
1838
- const { span, updatedOptions } = createSpan("BlockBlobClient-commitBlockList", options);
1839
- try {
1840
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1511
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1512
+ return tracingClient.withSpan("BlockBlobClient-commitBlockList", options, async (updatedOptions) => {
1513
+ var _a, _b, _c;
1841
1514
  return assertResponse(await this.blockBlobContext.commitBlockList({ latest: blocks }, {
1842
1515
  abortSignal: options.abortSignal,
1843
1516
  blobHttpHeaders: options.blobHTTPHeaders,
@@ -1853,17 +1526,7 @@ export class BlockBlobClient extends BlobClient {
1853
1526
  blobTagsString: toBlobTagsString(options.tags),
1854
1527
  tracingOptions: updatedOptions.tracingOptions,
1855
1528
  }));
1856
- }
1857
- catch (e) {
1858
- span.setStatus({
1859
- code: SpanStatusCode.ERROR,
1860
- message: e.message,
1861
- });
1862
- throw e;
1863
- }
1864
- finally {
1865
- span.end();
1866
- }
1529
+ });
1867
1530
  }
1868
1531
  /**
1869
1532
  * Returns the list of blocks that have been uploaded as part of a block blob
@@ -1876,9 +1539,8 @@ export class BlockBlobClient extends BlobClient {
1876
1539
  * @returns Response data for the Block Blob Get Block List operation.
1877
1540
  */
1878
1541
  async getBlockList(listType, options = {}) {
1879
- var _a;
1880
- const { span, updatedOptions } = createSpan("BlockBlobClient-getBlockList", options);
1881
- try {
1542
+ return tracingClient.withSpan("BlockBlobClient-getBlockList", options, async (updatedOptions) => {
1543
+ var _a;
1882
1544
  const res = assertResponse(await this.blockBlobContext.getBlockList(listType, {
1883
1545
  abortSignal: options.abortSignal,
1884
1546
  leaseAccessConditions: options.conditions,
@@ -1892,17 +1554,7 @@ export class BlockBlobClient extends BlobClient {
1892
1554
  res.uncommittedBlocks = [];
1893
1555
  }
1894
1556
  return res;
1895
- }
1896
- catch (e) {
1897
- span.setStatus({
1898
- code: SpanStatusCode.ERROR,
1899
- message: e.message,
1900
- });
1901
- throw e;
1902
- }
1903
- finally {
1904
- span.end();
1905
- }
1557
+ });
1906
1558
  }
1907
1559
  // High level functions
1908
1560
  /**
@@ -1921,8 +1573,7 @@ export class BlockBlobClient extends BlobClient {
1921
1573
  * @param options -
1922
1574
  */
1923
1575
  async uploadData(data, options = {}) {
1924
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadData", options);
1925
- try {
1576
+ return tracingClient.withSpan("BlockBlobClient-uploadData", options, async (updatedOptions) => {
1926
1577
  if (isNode) {
1927
1578
  let buffer;
1928
1579
  if (data instanceof Buffer) {
@@ -1941,17 +1592,7 @@ export class BlockBlobClient extends BlobClient {
1941
1592
  const browserBlob = new Blob([data]);
1942
1593
  return this.uploadSeekableInternal((offset, size) => browserBlob.slice(offset, offset + size), browserBlob.size, updatedOptions);
1943
1594
  }
1944
- }
1945
- catch (e) {
1946
- span.setStatus({
1947
- code: SpanStatusCode.ERROR,
1948
- message: e.message,
1949
- });
1950
- throw e;
1951
- }
1952
- finally {
1953
- span.end();
1954
- }
1595
+ });
1955
1596
  }
1956
1597
  /**
1957
1598
  * ONLY AVAILABLE IN BROWSERS.
@@ -1973,21 +1614,10 @@ export class BlockBlobClient extends BlobClient {
1973
1614
  * @returns Response data for the Blob Upload operation.
1974
1615
  */
1975
1616
  async uploadBrowserData(browserData, options = {}) {
1976
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadBrowserData", options);
1977
- try {
1617
+ return tracingClient.withSpan("BlockBlobClient-uploadBrowserData", options, async (updatedOptions) => {
1978
1618
  const browserBlob = new Blob([browserData]);
1979
- return await this.uploadSeekableInternal((offset, size) => browserBlob.slice(offset, offset + size), browserBlob.size, updatedOptions);
1980
- }
1981
- catch (e) {
1982
- span.setStatus({
1983
- code: SpanStatusCode.ERROR,
1984
- message: e.message,
1985
- });
1986
- throw e;
1987
- }
1988
- finally {
1989
- span.end();
1990
- }
1619
+ return this.uploadSeekableInternal((offset, size) => browserBlob.slice(offset, offset + size), browserBlob.size, updatedOptions);
1620
+ });
1991
1621
  }
1992
1622
  /**
1993
1623
  *
@@ -2005,27 +1635,23 @@ export class BlockBlobClient extends BlobClient {
2005
1635
  * @returns Response data for the Blob Upload operation.
2006
1636
  */
2007
1637
  async uploadSeekableInternal(bodyFactory, size, options = {}) {
2008
- if (!options.blockSize) {
2009
- options.blockSize = 0;
2010
- }
2011
- if (options.blockSize < 0 || options.blockSize > BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES) {
1638
+ var _a, _b;
1639
+ let blockSize = (_a = options.blockSize) !== null && _a !== void 0 ? _a : 0;
1640
+ if (blockSize < 0 || blockSize > BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES) {
2012
1641
  throw new RangeError(`blockSize option must be >= 0 and <= ${BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES}`);
2013
1642
  }
2014
- if (options.maxSingleShotSize !== 0 && !options.maxSingleShotSize) {
2015
- options.maxSingleShotSize = BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES;
2016
- }
2017
- if (options.maxSingleShotSize < 0 ||
2018
- options.maxSingleShotSize > BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES) {
1643
+ const maxSingleShotSize = (_b = options.maxSingleShotSize) !== null && _b !== void 0 ? _b : BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES;
1644
+ if (maxSingleShotSize < 0 || maxSingleShotSize > BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES) {
2019
1645
  throw new RangeError(`maxSingleShotSize option must be >= 0 and <= ${BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES}`);
2020
1646
  }
2021
- if (options.blockSize === 0) {
1647
+ if (blockSize === 0) {
2022
1648
  if (size > BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES * BLOCK_BLOB_MAX_BLOCKS) {
2023
1649
  throw new RangeError(`${size} is too larger to upload to a block blob.`);
2024
1650
  }
2025
- if (size > options.maxSingleShotSize) {
2026
- options.blockSize = Math.ceil(size / BLOCK_BLOB_MAX_BLOCKS);
2027
- if (options.blockSize < DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES) {
2028
- options.blockSize = DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES;
1651
+ if (size > maxSingleShotSize) {
1652
+ blockSize = Math.ceil(size / BLOCK_BLOB_MAX_BLOCKS);
1653
+ if (blockSize < DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES) {
1654
+ blockSize = DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES;
2029
1655
  }
2030
1656
  }
2031
1657
  }
@@ -2035,12 +1661,11 @@ export class BlockBlobClient extends BlobClient {
2035
1661
  if (!options.conditions) {
2036
1662
  options.conditions = {};
2037
1663
  }
2038
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadSeekableInternal", options);
2039
- try {
2040
- if (size <= options.maxSingleShotSize) {
1664
+ return tracingClient.withSpan("BlockBlobClient-uploadSeekableInternal", options, async (updatedOptions) => {
1665
+ if (size <= maxSingleShotSize) {
2041
1666
  return assertResponse(await this.upload(bodyFactory(0, size), size, updatedOptions));
2042
1667
  }
2043
- const numBlocks = Math.floor((size - 1) / options.blockSize) + 1;
1668
+ const numBlocks = Math.floor((size - 1) / blockSize) + 1;
2044
1669
  if (numBlocks > BLOCK_BLOB_MAX_BLOCKS) {
2045
1670
  throw new RangeError(`The buffer's size is too big or the BlockSize is too small;` +
2046
1671
  `the number of blocks must be <= ${BLOCK_BLOB_MAX_BLOCKS}`);
@@ -2052,8 +1677,8 @@ export class BlockBlobClient extends BlobClient {
2052
1677
  for (let i = 0; i < numBlocks; i++) {
2053
1678
  batch.addOperation(async () => {
2054
1679
  const blockID = generateBlockID(blockIDPrefix, i);
2055
- const start = options.blockSize * i;
2056
- const end = i === numBlocks - 1 ? size : start + options.blockSize;
1680
+ const start = blockSize * i;
1681
+ const end = i === numBlocks - 1 ? size : start + blockSize;
2057
1682
  const contentLength = end - start;
2058
1683
  blockList.push(blockID);
2059
1684
  await this.stageBlock(blockID, bodyFactory(start, contentLength), contentLength, {
@@ -2074,17 +1699,7 @@ export class BlockBlobClient extends BlobClient {
2074
1699
  }
2075
1700
  await batch.do();
2076
1701
  return this.commitBlockList(blockList, updatedOptions);
2077
- }
2078
- catch (e) {
2079
- span.setStatus({
2080
- code: SpanStatusCode.ERROR,
2081
- message: e.message,
2082
- });
2083
- throw e;
2084
- }
2085
- finally {
2086
- span.end();
2087
- }
1702
+ });
2088
1703
  }
2089
1704
  /**
2090
1705
  * ONLY AVAILABLE IN NODE.JS RUNTIME.
@@ -2100,27 +1715,16 @@ export class BlockBlobClient extends BlobClient {
2100
1715
  * @returns Response data for the Blob Upload operation.
2101
1716
  */
2102
1717
  async uploadFile(filePath, options = {}) {
2103
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadFile", options);
2104
- try {
1718
+ return tracingClient.withSpan("BlockBlobClient-uploadFile", options, async (updatedOptions) => {
2105
1719
  const size = (await fsStat(filePath)).size;
2106
- return await this.uploadSeekableInternal((offset, count) => {
1720
+ return this.uploadSeekableInternal((offset, count) => {
2107
1721
  return () => fsCreateReadStream(filePath, {
2108
1722
  autoClose: true,
2109
1723
  end: count ? offset + count - 1 : Infinity,
2110
1724
  start: offset,
2111
1725
  });
2112
1726
  }, size, Object.assign(Object.assign({}, options), { tracingOptions: updatedOptions.tracingOptions }));
2113
- }
2114
- catch (e) {
2115
- span.setStatus({
2116
- code: SpanStatusCode.ERROR,
2117
- message: e.message,
2118
- });
2119
- throw e;
2120
- }
2121
- finally {
2122
- span.end();
2123
- }
1727
+ });
2124
1728
  }
2125
1729
  /**
2126
1730
  * ONLY AVAILABLE IN NODE.JS RUNTIME.
@@ -2145,8 +1749,7 @@ export class BlockBlobClient extends BlobClient {
2145
1749
  if (!options.conditions) {
2146
1750
  options.conditions = {};
2147
1751
  }
2148
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadStream", options);
2149
- try {
1752
+ return tracingClient.withSpan("BlockBlobClient-uploadStream", options, async (updatedOptions) => {
2150
1753
  let blockNum = 0;
2151
1754
  const blockIDPrefix = generateUuid();
2152
1755
  let transferProgress = 0;
@@ -2173,17 +1776,7 @@ export class BlockBlobClient extends BlobClient {
2173
1776
  Math.ceil((maxConcurrency / 4) * 3));
2174
1777
  await scheduler.do();
2175
1778
  return assertResponse(await this.commitBlockList(blockList, Object.assign(Object.assign({}, options), { tracingOptions: updatedOptions.tracingOptions })));
2176
- }
2177
- catch (e) {
2178
- span.setStatus({
2179
- code: SpanStatusCode.ERROR,
2180
- message: e.message,
2181
- });
2182
- throw e;
2183
- }
2184
- finally {
2185
- span.end();
2186
- }
1779
+ });
2187
1780
  }
2188
1781
  }
2189
1782
  /**
@@ -2278,11 +1871,10 @@ export class PageBlobClient extends BlobClient {
2278
1871
  * @returns Response data for the Page Blob Create operation.
2279
1872
  */
2280
1873
  async create(size, options = {}) {
2281
- var _a, _b, _c;
2282
1874
  options.conditions = options.conditions || {};
2283
- const { span, updatedOptions } = createSpan("PageBlobClient-create", options);
2284
- try {
2285
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1875
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1876
+ return tracingClient.withSpan("PageBlobClient-create", options, async (updatedOptions) => {
1877
+ var _a, _b, _c;
2286
1878
  return assertResponse(await this.pageBlobContext.create(0, size, {
2287
1879
  abortSignal: options.abortSignal,
2288
1880
  blobHttpHeaders: options.blobHTTPHeaders,
@@ -2299,17 +1891,7 @@ export class PageBlobClient extends BlobClient {
2299
1891
  blobTagsString: toBlobTagsString(options.tags),
2300
1892
  tracingOptions: updatedOptions.tracingOptions,
2301
1893
  }));
2302
- }
2303
- catch (e) {
2304
- span.setStatus({
2305
- code: SpanStatusCode.ERROR,
2306
- message: e.message,
2307
- });
2308
- throw e;
2309
- }
2310
- finally {
2311
- span.end();
2312
- }
1894
+ });
2313
1895
  }
2314
1896
  /**
2315
1897
  * Creates a page blob of the specified length. Call uploadPages to upload data
@@ -2321,30 +1903,20 @@ export class PageBlobClient extends BlobClient {
2321
1903
  * @param options -
2322
1904
  */
2323
1905
  async createIfNotExists(size, options = {}) {
2324
- var _a, _b;
2325
- const { span, updatedOptions } = createSpan("PageBlobClient-createIfNotExists", options);
2326
- try {
2327
- const conditions = { ifNoneMatch: ETagAny };
2328
- const res = assertResponse(await this.create(size, Object.assign(Object.assign({}, options), { conditions, tracingOptions: updatedOptions.tracingOptions })));
2329
- return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
2330
- }
2331
- catch (e) {
2332
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobAlreadyExists") {
2333
- span.setStatus({
2334
- code: SpanStatusCode.ERROR,
2335
- message: "Expected exception when creating a blob only if it does not already exist.",
2336
- });
2337
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
1906
+ return tracingClient.withSpan("PageBlobClient-createIfNotExists", options, async (updatedOptions) => {
1907
+ var _a, _b;
1908
+ try {
1909
+ const conditions = { ifNoneMatch: ETagAny };
1910
+ const res = assertResponse(await this.create(size, Object.assign(Object.assign({}, options), { conditions, tracingOptions: updatedOptions.tracingOptions })));
1911
+ return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
2338
1912
  }
2339
- span.setStatus({
2340
- code: SpanStatusCode.ERROR,
2341
- message: e.message,
2342
- });
2343
- throw e;
2344
- }
2345
- finally {
2346
- span.end();
2347
- }
1913
+ catch (e) {
1914
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobAlreadyExists") {
1915
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
1916
+ }
1917
+ throw e;
1918
+ }
1919
+ });
2348
1920
  }
2349
1921
  /**
2350
1922
  * Writes 1 or more pages to the page blob. The start and end offsets must be a multiple of 512.
@@ -2357,11 +1929,10 @@ export class PageBlobClient extends BlobClient {
2357
1929
  * @returns Response data for the Page Blob Upload Pages operation.
2358
1930
  */
2359
1931
  async uploadPages(body, offset, count, options = {}) {
2360
- var _a;
2361
1932
  options.conditions = options.conditions || {};
2362
- const { span, updatedOptions } = createSpan("PageBlobClient-uploadPages", options);
2363
- try {
2364
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1933
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1934
+ return tracingClient.withSpan("PageBlobClient-uploadPages", options, async (updatedOptions) => {
1935
+ var _a;
2365
1936
  return assertResponse(await this.pageBlobContext.uploadPages(count, body, {
2366
1937
  abortSignal: options.abortSignal,
2367
1938
  leaseAccessConditions: options.conditions,
@@ -2377,17 +1948,7 @@ export class PageBlobClient extends BlobClient {
2377
1948
  encryptionScope: options.encryptionScope,
2378
1949
  tracingOptions: updatedOptions.tracingOptions,
2379
1950
  }));
2380
- }
2381
- catch (e) {
2382
- span.setStatus({
2383
- code: SpanStatusCode.ERROR,
2384
- message: e.message,
2385
- });
2386
- throw e;
2387
- }
2388
- finally {
2389
- span.end();
2390
- }
1951
+ });
2391
1952
  }
2392
1953
  /**
2393
1954
  * The Upload Pages operation writes a range of pages to a page blob where the
@@ -2401,12 +1962,11 @@ export class PageBlobClient extends BlobClient {
2401
1962
  * @param options -
2402
1963
  */
2403
1964
  async uploadPagesFromURL(sourceURL, sourceOffset, destOffset, count, options = {}) {
2404
- var _a;
2405
1965
  options.conditions = options.conditions || {};
2406
1966
  options.sourceConditions = options.sourceConditions || {};
2407
- const { span, updatedOptions } = createSpan("PageBlobClient-uploadPagesFromURL", options);
2408
- try {
2409
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1967
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
1968
+ return tracingClient.withSpan("PageBlobClient-uploadPagesFromURL", options, async (updatedOptions) => {
1969
+ var _a, _b, _c, _d, _e;
2410
1970
  return assertResponse(await this.pageBlobContext.uploadPagesFromURL(sourceURL, rangeToString({ offset: sourceOffset, count }), 0, rangeToString({ offset: destOffset, count }), {
2411
1971
  abortSignal: options.abortSignal,
2412
1972
  sourceContentMD5: options.sourceContentMD5,
@@ -2415,27 +1975,17 @@ export class PageBlobClient extends BlobClient {
2415
1975
  sequenceNumberAccessConditions: options.conditions,
2416
1976
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
2417
1977
  sourceModifiedAccessConditions: {
2418
- sourceIfMatch: options.sourceConditions.ifMatch,
2419
- sourceIfModifiedSince: options.sourceConditions.ifModifiedSince,
2420
- sourceIfNoneMatch: options.sourceConditions.ifNoneMatch,
2421
- sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince,
1978
+ sourceIfMatch: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifMatch,
1979
+ sourceIfModifiedSince: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifModifiedSince,
1980
+ sourceIfNoneMatch: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch,
1981
+ sourceIfUnmodifiedSince: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.ifUnmodifiedSince,
2422
1982
  },
2423
1983
  cpkInfo: options.customerProvidedKey,
2424
1984
  encryptionScope: options.encryptionScope,
2425
1985
  copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization),
2426
1986
  tracingOptions: updatedOptions.tracingOptions,
2427
1987
  }));
2428
- }
2429
- catch (e) {
2430
- span.setStatus({
2431
- code: SpanStatusCode.ERROR,
2432
- message: e.message,
2433
- });
2434
- throw e;
2435
- }
2436
- finally {
2437
- span.end();
2438
- }
1988
+ });
2439
1989
  }
2440
1990
  /**
2441
1991
  * Frees the specified pages from the page blob.
@@ -2447,10 +1997,9 @@ export class PageBlobClient extends BlobClient {
2447
1997
  * @returns Response data for the Page Blob Clear Pages operation.
2448
1998
  */
2449
1999
  async clearPages(offset = 0, count, options = {}) {
2450
- var _a;
2451
2000
  options.conditions = options.conditions || {};
2452
- const { span, updatedOptions } = createSpan("PageBlobClient-clearPages", options);
2453
- try {
2001
+ return tracingClient.withSpan("PageBlobClient-clearPages", options, async (updatedOptions) => {
2002
+ var _a;
2454
2003
  return assertResponse(await this.pageBlobContext.clearPages(0, {
2455
2004
  abortSignal: options.abortSignal,
2456
2005
  leaseAccessConditions: options.conditions,
@@ -2461,17 +2010,7 @@ export class PageBlobClient extends BlobClient {
2461
2010
  encryptionScope: options.encryptionScope,
2462
2011
  tracingOptions: updatedOptions.tracingOptions,
2463
2012
  }));
2464
- }
2465
- catch (e) {
2466
- span.setStatus({
2467
- code: SpanStatusCode.ERROR,
2468
- message: e.message,
2469
- });
2470
- throw e;
2471
- }
2472
- finally {
2473
- span.end();
2474
- }
2013
+ });
2475
2014
  }
2476
2015
  /**
2477
2016
  * Returns the list of valid page ranges for a page blob or snapshot of a page blob.
@@ -2483,10 +2022,9 @@ export class PageBlobClient extends BlobClient {
2483
2022
  * @returns Response data for the Page Blob Get Ranges operation.
2484
2023
  */
2485
2024
  async getPageRanges(offset = 0, count, options = {}) {
2486
- var _a;
2487
2025
  options.conditions = options.conditions || {};
2488
- const { span, updatedOptions } = createSpan("PageBlobClient-getPageRanges", options);
2489
- try {
2026
+ return tracingClient.withSpan("PageBlobClient-getPageRanges", options, async (updatedOptions) => {
2027
+ var _a;
2490
2028
  const response = assertResponse(await this.pageBlobContext.getPageRanges({
2491
2029
  abortSignal: options.abortSignal,
2492
2030
  leaseAccessConditions: options.conditions,
@@ -2495,17 +2033,7 @@ export class PageBlobClient extends BlobClient {
2495
2033
  tracingOptions: updatedOptions.tracingOptions,
2496
2034
  }));
2497
2035
  return rangeResponseFromModel(response);
2498
- }
2499
- catch (e) {
2500
- span.setStatus({
2501
- code: SpanStatusCode.ERROR,
2502
- message: e.message,
2503
- });
2504
- throw e;
2505
- }
2506
- finally {
2507
- span.end();
2508
- }
2036
+ });
2509
2037
  }
2510
2038
  /**
2511
2039
  * getPageRangesSegment returns a single segment of page ranges starting from the
@@ -2520,9 +2048,8 @@ export class PageBlobClient extends BlobClient {
2520
2048
  * @param options - Options to PageBlob Get Page Ranges Segment operation.
2521
2049
  */
2522
2050
  async listPageRangesSegment(offset = 0, count, marker, options = {}) {
2523
- var _a;
2524
- const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesSegment", options);
2525
- try {
2051
+ return tracingClient.withSpan("PageBlobClient-getPageRangesSegment", options, async (updatedOptions) => {
2052
+ var _a;
2526
2053
  return assertResponse(await this.pageBlobContext.getPageRanges({
2527
2054
  abortSignal: options.abortSignal,
2528
2055
  leaseAccessConditions: options.conditions,
@@ -2532,17 +2059,7 @@ export class PageBlobClient extends BlobClient {
2532
2059
  maxPageSize: options.maxPageSize,
2533
2060
  tracingOptions: updatedOptions.tracingOptions,
2534
2061
  }));
2535
- }
2536
- catch (e) {
2537
- span.setStatus({
2538
- code: SpanStatusCode.ERROR,
2539
- message: e.message,
2540
- });
2541
- throw e;
2542
- }
2543
- finally {
2544
- span.end();
2545
- }
2062
+ });
2546
2063
  }
2547
2064
  /**
2548
2065
  * Returns an AsyncIterableIterator for {@link PageBlobGetPageRangesResponseModel}
@@ -2703,10 +2220,9 @@ export class PageBlobClient extends BlobClient {
2703
2220
  * @returns Response data for the Page Blob Get Page Range Diff operation.
2704
2221
  */
2705
2222
  async getPageRangesDiff(offset, count, prevSnapshot, options = {}) {
2706
- var _a;
2707
2223
  options.conditions = options.conditions || {};
2708
- const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesDiff", options);
2709
- try {
2224
+ return tracingClient.withSpan("PageBlobClient-getPageRangesDiff", options, async (updatedOptions) => {
2225
+ var _a;
2710
2226
  const result = assertResponse(await this.pageBlobContext.getPageRangesDiff({
2711
2227
  abortSignal: options.abortSignal,
2712
2228
  leaseAccessConditions: options.conditions,
@@ -2716,17 +2232,7 @@ export class PageBlobClient extends BlobClient {
2716
2232
  tracingOptions: updatedOptions.tracingOptions,
2717
2233
  }));
2718
2234
  return rangeResponseFromModel(result);
2719
- }
2720
- catch (e) {
2721
- span.setStatus({
2722
- code: SpanStatusCode.ERROR,
2723
- message: e.message,
2724
- });
2725
- throw e;
2726
- }
2727
- finally {
2728
- span.end();
2729
- }
2235
+ });
2730
2236
  }
2731
2237
  /**
2732
2238
  * getPageRangesDiffSegment returns a single segment of page ranges starting from the
@@ -2742,10 +2248,9 @@ export class PageBlobClient extends BlobClient {
2742
2248
  * @param marker - A string value that identifies the portion of the get to be returned with the next get operation.
2743
2249
  * @param options - Options to the Page Blob Get Page Ranges Diff operation.
2744
2250
  */
2745
- async listPageRangesDiffSegment(offset, count, prevSnapshotOrUrl, marker, options) {
2746
- var _a;
2747
- const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesDiffSegment", options);
2748
- try {
2251
+ async listPageRangesDiffSegment(offset, count, prevSnapshotOrUrl, marker, options = {}) {
2252
+ return tracingClient.withSpan("PageBlobClient-getPageRangesDiffSegment", options, async (updatedOptions) => {
2253
+ var _a;
2749
2254
  return assertResponse(await this.pageBlobContext.getPageRangesDiff({
2750
2255
  abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
2751
2256
  leaseAccessConditions: options === null || options === void 0 ? void 0 : options.conditions,
@@ -2759,17 +2264,7 @@ export class PageBlobClient extends BlobClient {
2759
2264
  maxPageSize: options === null || options === void 0 ? void 0 : options.maxPageSize,
2760
2265
  tracingOptions: updatedOptions.tracingOptions,
2761
2266
  }));
2762
- }
2763
- catch (e) {
2764
- span.setStatus({
2765
- code: SpanStatusCode.ERROR,
2766
- message: e.message,
2767
- });
2768
- throw e;
2769
- }
2770
- finally {
2771
- span.end();
2772
- }
2267
+ });
2773
2268
  }
2774
2269
  /**
2775
2270
  * Returns an AsyncIterableIterator for {@link PageBlobGetPageRangesDiffResponseModel}
@@ -2934,10 +2429,9 @@ export class PageBlobClient extends BlobClient {
2934
2429
  * @returns Response data for the Page Blob Get Page Range Diff operation.
2935
2430
  */
2936
2431
  async getPageRangesDiffForManagedDisks(offset, count, prevSnapshotUrl, options = {}) {
2937
- var _a;
2938
2432
  options.conditions = options.conditions || {};
2939
- const { span, updatedOptions } = createSpan("PageBlobClient-GetPageRangesDiffForManagedDisks", options);
2940
- try {
2433
+ return tracingClient.withSpan("PageBlobClient-GetPageRangesDiffForManagedDisks", options, async (updatedOptions) => {
2434
+ var _a;
2941
2435
  const response = assertResponse(await this.pageBlobContext.getPageRangesDiff({
2942
2436
  abortSignal: options.abortSignal,
2943
2437
  leaseAccessConditions: options.conditions,
@@ -2947,17 +2441,7 @@ export class PageBlobClient extends BlobClient {
2947
2441
  tracingOptions: updatedOptions.tracingOptions,
2948
2442
  }));
2949
2443
  return rangeResponseFromModel(response);
2950
- }
2951
- catch (e) {
2952
- span.setStatus({
2953
- code: SpanStatusCode.ERROR,
2954
- message: e.message,
2955
- });
2956
- throw e;
2957
- }
2958
- finally {
2959
- span.end();
2960
- }
2444
+ });
2961
2445
  }
2962
2446
  /**
2963
2447
  * Resizes the page blob to the specified size (which must be a multiple of 512).
@@ -2968,10 +2452,9 @@ export class PageBlobClient extends BlobClient {
2968
2452
  * @returns Response data for the Page Blob Resize operation.
2969
2453
  */
2970
2454
  async resize(size, options = {}) {
2971
- var _a;
2972
2455
  options.conditions = options.conditions || {};
2973
- const { span, updatedOptions } = createSpan("PageBlobClient-resize", options);
2974
- try {
2456
+ return tracingClient.withSpan("PageBlobClient-resize", options, async (updatedOptions) => {
2457
+ var _a;
2975
2458
  return assertResponse(await this.pageBlobContext.resize(size, {
2976
2459
  abortSignal: options.abortSignal,
2977
2460
  leaseAccessConditions: options.conditions,
@@ -2979,17 +2462,7 @@ export class PageBlobClient extends BlobClient {
2979
2462
  encryptionScope: options.encryptionScope,
2980
2463
  tracingOptions: updatedOptions.tracingOptions,
2981
2464
  }));
2982
- }
2983
- catch (e) {
2984
- span.setStatus({
2985
- code: SpanStatusCode.ERROR,
2986
- message: e.message,
2987
- });
2988
- throw e;
2989
- }
2990
- finally {
2991
- span.end();
2992
- }
2465
+ });
2993
2466
  }
2994
2467
  /**
2995
2468
  * Sets a page blob's sequence number.
@@ -3001,10 +2474,9 @@ export class PageBlobClient extends BlobClient {
3001
2474
  * @returns Response data for the Page Blob Update Sequence Number operation.
3002
2475
  */
3003
2476
  async updateSequenceNumber(sequenceNumberAction, sequenceNumber, options = {}) {
3004
- var _a;
3005
2477
  options.conditions = options.conditions || {};
3006
- const { span, updatedOptions } = createSpan("PageBlobClient-updateSequenceNumber", options);
3007
- try {
2478
+ return tracingClient.withSpan("PageBlobClient-updateSequenceNumber", options, async (updatedOptions) => {
2479
+ var _a;
3008
2480
  return assertResponse(await this.pageBlobContext.updateSequenceNumber(sequenceNumberAction, {
3009
2481
  abortSignal: options.abortSignal,
3010
2482
  blobSequenceNumber: sequenceNumber,
@@ -3012,17 +2484,7 @@ export class PageBlobClient extends BlobClient {
3012
2484
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
3013
2485
  tracingOptions: updatedOptions.tracingOptions,
3014
2486
  }));
3015
- }
3016
- catch (e) {
3017
- span.setStatus({
3018
- code: SpanStatusCode.ERROR,
3019
- message: e.message,
3020
- });
3021
- throw e;
3022
- }
3023
- finally {
3024
- span.end();
3025
- }
2487
+ });
3026
2488
  }
3027
2489
  /**
3028
2490
  * Begins an operation to start an incremental copy from one page blob's snapshot to this page blob.
@@ -3038,25 +2500,14 @@ export class PageBlobClient extends BlobClient {
3038
2500
  * @returns Response data for the Page Blob Copy Incremental operation.
3039
2501
  */
3040
2502
  async startCopyIncremental(copySource, options = {}) {
3041
- var _a;
3042
- const { span, updatedOptions } = createSpan("PageBlobClient-startCopyIncremental", options);
3043
- try {
2503
+ return tracingClient.withSpan("PageBlobClient-startCopyIncremental", options, async (updatedOptions) => {
2504
+ var _a;
3044
2505
  return assertResponse(await this.pageBlobContext.copyIncremental(copySource, {
3045
2506
  abortSignal: options.abortSignal,
3046
2507
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
3047
2508
  tracingOptions: updatedOptions.tracingOptions,
3048
2509
  }));
3049
- }
3050
- catch (e) {
3051
- span.setStatus({
3052
- code: SpanStatusCode.ERROR,
3053
- message: e.message,
3054
- });
3055
- throw e;
3056
- }
3057
- finally {
3058
- span.end();
3059
- }
2510
+ });
3060
2511
  }
3061
2512
  }
3062
2513
  //# sourceMappingURL=Clients.js.map