@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.
package/dist/index.js CHANGED
@@ -6,13 +6,13 @@ var coreRestPipeline = require('@azure/core-rest-pipeline');
6
6
  var tslib = require('tslib');
7
7
  var coreAuth = require('@azure/core-auth');
8
8
  var coreUtil = require('@azure/core-util');
9
- var coreTracing = require('@azure/core-tracing');
10
9
  var coreHttpCompat = require('@azure/core-http-compat');
11
10
  var coreClient = require('@azure/core-client');
12
11
  var coreXml = require('@azure/core-xml');
13
12
  var logger$1 = require('@azure/logger');
14
13
  var abortController = require('@azure/abort-controller');
15
14
  var crypto = require('crypto');
15
+ var coreTracing = require('@azure/core-tracing');
16
16
  var uuid = require('uuid');
17
17
  var stream = require('stream');
18
18
  require('@azure/core-paging');
@@ -15251,8 +15251,9 @@ class StorageClient {
15251
15251
  * Creates a span using the global tracer.
15252
15252
  * @internal
15253
15253
  */
15254
- const createSpan = coreTracing.createSpanFunction({
15255
- packagePrefix: "Azure.Storage.Blob",
15254
+ const tracingClient = coreTracing.createTracingClient({
15255
+ packageName: "@azure/storage-blob",
15256
+ packageVersion: SDK_VERSION,
15256
15257
  namespace: "Microsoft.Storage",
15257
15258
  });
15258
15259
 
@@ -16546,33 +16547,23 @@ class BlobLeaseClient {
16546
16547
  * @returns Response data for acquire lease operation.
16547
16548
  */
16548
16549
  async acquireLease(duration, options = {}) {
16549
- var _a, _b, _c, _d, _e, _f;
16550
- const { span, updatedOptions } = createSpan("BlobLeaseClient-acquireLease", options);
16550
+ var _a, _b, _c, _d, _e;
16551
16551
  if (this._isContainer &&
16552
16552
  ((((_a = options.conditions) === null || _a === void 0 ? void 0 : _a.ifMatch) && ((_b = options.conditions) === null || _b === void 0 ? void 0 : _b.ifMatch) !== ETagNone) ||
16553
16553
  (((_c = options.conditions) === null || _c === void 0 ? void 0 : _c.ifNoneMatch) && ((_d = options.conditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch) !== ETagNone) ||
16554
16554
  ((_e = options.conditions) === null || _e === void 0 ? void 0 : _e.tagConditions))) {
16555
16555
  throw new RangeError("The IfMatch, IfNoneMatch and tags access conditions are ignored by the service. Values other than undefined or their default values are not acceptable.");
16556
16556
  }
16557
- try {
16557
+ return tracingClient.withSpan("BlobLeaseClient-acquireLease", options, async (updatedOptions) => {
16558
+ var _a;
16558
16559
  return assertResponse(await this._containerOrBlobOperation.acquireLease({
16559
16560
  abortSignal: options.abortSignal,
16560
16561
  duration,
16561
- modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_f = options.conditions) === null || _f === void 0 ? void 0 : _f.tagConditions }),
16562
+ modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
16562
16563
  proposedLeaseId: this._leaseId,
16563
16564
  tracingOptions: updatedOptions.tracingOptions,
16564
16565
  }));
16565
- }
16566
- catch (e) {
16567
- span.setStatus({
16568
- code: coreTracing.SpanStatusCode.ERROR,
16569
- message: e.message,
16570
- });
16571
- throw e;
16572
- }
16573
- finally {
16574
- span.end();
16575
- }
16566
+ });
16576
16567
  }
16577
16568
  /**
16578
16569
  * To change the ID of the lease.
@@ -16585,33 +16576,23 @@ class BlobLeaseClient {
16585
16576
  * @returns Response data for change lease operation.
16586
16577
  */
16587
16578
  async changeLease(proposedLeaseId, options = {}) {
16588
- var _a, _b, _c, _d, _e, _f;
16589
- const { span, updatedOptions } = createSpan("BlobLeaseClient-changeLease", options);
16579
+ var _a, _b, _c, _d, _e;
16590
16580
  if (this._isContainer &&
16591
16581
  ((((_a = options.conditions) === null || _a === void 0 ? void 0 : _a.ifMatch) && ((_b = options.conditions) === null || _b === void 0 ? void 0 : _b.ifMatch) !== ETagNone) ||
16592
16582
  (((_c = options.conditions) === null || _c === void 0 ? void 0 : _c.ifNoneMatch) && ((_d = options.conditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch) !== ETagNone) ||
16593
16583
  ((_e = options.conditions) === null || _e === void 0 ? void 0 : _e.tagConditions))) {
16594
16584
  throw new RangeError("The IfMatch, IfNoneMatch and tags access conditions are ignored by the service. Values other than undefined or their default values are not acceptable.");
16595
16585
  }
16596
- try {
16586
+ return tracingClient.withSpan("BlobLeaseClient-changeLease", options, async (updatedOptions) => {
16587
+ var _a;
16597
16588
  const response = assertResponse(await this._containerOrBlobOperation.changeLease(this._leaseId, proposedLeaseId, {
16598
16589
  abortSignal: options.abortSignal,
16599
- modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_f = options.conditions) === null || _f === void 0 ? void 0 : _f.tagConditions }),
16590
+ modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
16600
16591
  tracingOptions: updatedOptions.tracingOptions,
16601
16592
  }));
16602
16593
  this._leaseId = proposedLeaseId;
16603
16594
  return response;
16604
- }
16605
- catch (e) {
16606
- span.setStatus({
16607
- code: coreTracing.SpanStatusCode.ERROR,
16608
- message: e.message,
16609
- });
16610
- throw e;
16611
- }
16612
- finally {
16613
- span.end();
16614
- }
16595
+ });
16615
16596
  }
16616
16597
  /**
16617
16598
  * To free the lease if it is no longer needed so that another client may
@@ -16624,31 +16605,21 @@ class BlobLeaseClient {
16624
16605
  * @returns Response data for release lease operation.
16625
16606
  */
16626
16607
  async releaseLease(options = {}) {
16627
- var _a, _b, _c, _d, _e, _f;
16628
- const { span, updatedOptions } = createSpan("BlobLeaseClient-releaseLease", options);
16608
+ var _a, _b, _c, _d, _e;
16629
16609
  if (this._isContainer &&
16630
16610
  ((((_a = options.conditions) === null || _a === void 0 ? void 0 : _a.ifMatch) && ((_b = options.conditions) === null || _b === void 0 ? void 0 : _b.ifMatch) !== ETagNone) ||
16631
16611
  (((_c = options.conditions) === null || _c === void 0 ? void 0 : _c.ifNoneMatch) && ((_d = options.conditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch) !== ETagNone) ||
16632
16612
  ((_e = options.conditions) === null || _e === void 0 ? void 0 : _e.tagConditions))) {
16633
16613
  throw new RangeError("The IfMatch, IfNoneMatch and tags access conditions are ignored by the service. Values other than undefined or their default values are not acceptable.");
16634
16614
  }
16635
- try {
16615
+ return tracingClient.withSpan("BlobLeaseClient-releaseLease", options, async (updatedOptions) => {
16616
+ var _a;
16636
16617
  return assertResponse(await this._containerOrBlobOperation.releaseLease(this._leaseId, {
16637
16618
  abortSignal: options.abortSignal,
16638
- modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_f = options.conditions) === null || _f === void 0 ? void 0 : _f.tagConditions }),
16619
+ modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
16639
16620
  tracingOptions: updatedOptions.tracingOptions,
16640
16621
  }));
16641
- }
16642
- catch (e) {
16643
- span.setStatus({
16644
- code: coreTracing.SpanStatusCode.ERROR,
16645
- message: e.message,
16646
- });
16647
- throw e;
16648
- }
16649
- finally {
16650
- span.end();
16651
- }
16622
+ });
16652
16623
  }
16653
16624
  /**
16654
16625
  * To renew the lease.
@@ -16660,31 +16631,21 @@ class BlobLeaseClient {
16660
16631
  * @returns Response data for renew lease operation.
16661
16632
  */
16662
16633
  async renewLease(options = {}) {
16663
- var _a, _b, _c, _d, _e, _f;
16664
- const { span, updatedOptions } = createSpan("BlobLeaseClient-renewLease", options);
16634
+ var _a, _b, _c, _d, _e;
16665
16635
  if (this._isContainer &&
16666
16636
  ((((_a = options.conditions) === null || _a === void 0 ? void 0 : _a.ifMatch) && ((_b = options.conditions) === null || _b === void 0 ? void 0 : _b.ifMatch) !== ETagNone) ||
16667
16637
  (((_c = options.conditions) === null || _c === void 0 ? void 0 : _c.ifNoneMatch) && ((_d = options.conditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch) !== ETagNone) ||
16668
16638
  ((_e = options.conditions) === null || _e === void 0 ? void 0 : _e.tagConditions))) {
16669
16639
  throw new RangeError("The IfMatch, IfNoneMatch and tags access conditions are ignored by the service. Values other than undefined or their default values are not acceptable.");
16670
16640
  }
16671
- try {
16672
- return await this._containerOrBlobOperation.renewLease(this._leaseId, {
16641
+ return tracingClient.withSpan("BlobLeaseClient-renewLease", options, async (updatedOptions) => {
16642
+ var _a;
16643
+ return this._containerOrBlobOperation.renewLease(this._leaseId, {
16673
16644
  abortSignal: options.abortSignal,
16674
- modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_f = options.conditions) === null || _f === void 0 ? void 0 : _f.tagConditions }),
16645
+ modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
16675
16646
  tracingOptions: updatedOptions.tracingOptions,
16676
16647
  });
16677
- }
16678
- catch (e) {
16679
- span.setStatus({
16680
- code: coreTracing.SpanStatusCode.ERROR,
16681
- message: e.message,
16682
- });
16683
- throw e;
16684
- }
16685
- finally {
16686
- span.end();
16687
- }
16648
+ });
16688
16649
  }
16689
16650
  /**
16690
16651
  * To end the lease but ensure that another client cannot acquire a new lease
@@ -16698,33 +16659,23 @@ class BlobLeaseClient {
16698
16659
  * @returns Response data for break lease operation.
16699
16660
  */
16700
16661
  async breakLease(breakPeriod, options = {}) {
16701
- var _a, _b, _c, _d, _e, _f;
16702
- const { span, updatedOptions } = createSpan("BlobLeaseClient-breakLease", options);
16662
+ var _a, _b, _c, _d, _e;
16703
16663
  if (this._isContainer &&
16704
16664
  ((((_a = options.conditions) === null || _a === void 0 ? void 0 : _a.ifMatch) && ((_b = options.conditions) === null || _b === void 0 ? void 0 : _b.ifMatch) !== ETagNone) ||
16705
16665
  (((_c = options.conditions) === null || _c === void 0 ? void 0 : _c.ifNoneMatch) && ((_d = options.conditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch) !== ETagNone) ||
16706
16666
  ((_e = options.conditions) === null || _e === void 0 ? void 0 : _e.tagConditions))) {
16707
16667
  throw new RangeError("The IfMatch, IfNoneMatch and tags access conditions are ignored by the service. Values other than undefined or their default values are not acceptable.");
16708
16668
  }
16709
- try {
16669
+ return tracingClient.withSpan("BlobLeaseClient-breakLease", options, async (updatedOptions) => {
16670
+ var _a;
16710
16671
  const operationOptions = {
16711
16672
  abortSignal: options.abortSignal,
16712
16673
  breakPeriod,
16713
- modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_f = options.conditions) === null || _f === void 0 ? void 0 : _f.tagConditions }),
16674
+ modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
16714
16675
  tracingOptions: updatedOptions.tracingOptions,
16715
16676
  };
16716
16677
  return assertResponse(await this._containerOrBlobOperation.breakLease(operationOptions));
16717
- }
16718
- catch (e) {
16719
- span.setStatus({
16720
- code: coreTracing.SpanStatusCode.ERROR,
16721
- message: e.message,
16722
- });
16723
- throw e;
16724
- }
16725
- finally {
16726
- span.end();
16727
- }
16678
+ });
16728
16679
  }
16729
16680
  }
16730
16681
 
@@ -19396,12 +19347,11 @@ class BlobClient extends StorageClient {
19396
19347
  * ```
19397
19348
  */
19398
19349
  async download(offset = 0, count, options = {}) {
19399
- var _a;
19400
19350
  options.conditions = options.conditions || {};
19401
19351
  options.conditions = options.conditions || {};
19402
19352
  ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19403
- const { span, updatedOptions } = createSpan("BlobClient-download", options);
19404
- try {
19353
+ return tracingClient.withSpan("BlobClient-download", options, async (updatedOptions) => {
19354
+ var _a;
19405
19355
  const res = assertResponse(await this.blobContext.download({
19406
19356
  abortSignal: options.abortSignal,
19407
19357
  leaseAccessConditions: options.conditions,
@@ -19467,17 +19417,7 @@ class BlobClient extends StorageClient {
19467
19417
  maxRetryRequests: options.maxRetryRequests,
19468
19418
  onProgress: options.onProgress,
19469
19419
  });
19470
- }
19471
- catch (e) {
19472
- span.setStatus({
19473
- code: coreTracing.SpanStatusCode.ERROR,
19474
- message: e.message,
19475
- });
19476
- throw e;
19477
- }
19478
- finally {
19479
- span.end();
19480
- }
19420
+ });
19481
19421
  }
19482
19422
  /**
19483
19423
  * Returns true if the Azure blob resource represented by this client exists; false otherwise.
@@ -19489,37 +19429,31 @@ class BlobClient extends StorageClient {
19489
19429
  * @param options - options to Exists operation.
19490
19430
  */
19491
19431
  async exists(options = {}) {
19492
- const { span, updatedOptions } = createSpan("BlobClient-exists", options);
19493
- try {
19494
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19495
- await this.getProperties({
19496
- abortSignal: options.abortSignal,
19497
- customerProvidedKey: options.customerProvidedKey,
19498
- conditions: options.conditions,
19499
- tracingOptions: updatedOptions.tracingOptions,
19500
- });
19501
- return true;
19502
- }
19503
- catch (e) {
19504
- if (e.statusCode === 404) {
19505
- // Expected exception when checking blob existence
19506
- return false;
19507
- }
19508
- else if (e.statusCode === 409 &&
19509
- (e.details.errorCode === BlobUsesCustomerSpecifiedEncryptionMsg ||
19510
- e.details.errorCode === BlobDoesNotUseCustomerSpecifiedEncryption)) {
19511
- // Expected exception when checking blob existence
19432
+ return tracingClient.withSpan("BlobClient-exists", options, async (updatedOptions) => {
19433
+ try {
19434
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19435
+ await this.getProperties({
19436
+ abortSignal: options.abortSignal,
19437
+ customerProvidedKey: options.customerProvidedKey,
19438
+ conditions: options.conditions,
19439
+ tracingOptions: updatedOptions.tracingOptions,
19440
+ });
19512
19441
  return true;
19513
19442
  }
19514
- span.setStatus({
19515
- code: coreTracing.SpanStatusCode.ERROR,
19516
- message: e.message,
19517
- });
19518
- throw e;
19519
- }
19520
- finally {
19521
- span.end();
19522
- }
19443
+ catch (e) {
19444
+ if (e.statusCode === 404) {
19445
+ // Expected exception when checking blob existence
19446
+ return false;
19447
+ }
19448
+ else if (e.statusCode === 409 &&
19449
+ (e.details.errorCode === BlobUsesCustomerSpecifiedEncryptionMsg ||
19450
+ e.details.errorCode === BlobDoesNotUseCustomerSpecifiedEncryption)) {
19451
+ // Expected exception when checking blob existence
19452
+ return true;
19453
+ }
19454
+ throw e;
19455
+ }
19456
+ });
19523
19457
  }
19524
19458
  /**
19525
19459
  * Returns all user-defined metadata, standard HTTP properties, and system properties
@@ -19534,11 +19468,10 @@ class BlobClient extends StorageClient {
19534
19468
  * @param options - Optional options to Get Properties operation.
19535
19469
  */
19536
19470
  async getProperties(options = {}) {
19537
- var _a;
19538
- const { span, updatedOptions } = createSpan("BlobClient-getProperties", options);
19539
- try {
19540
- options.conditions = options.conditions || {};
19541
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19471
+ options.conditions = options.conditions || {};
19472
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19473
+ return tracingClient.withSpan("BlobClient-getProperties", options, async (updatedOptions) => {
19474
+ var _a;
19542
19475
  const res = assertResponse(await this.blobContext.getProperties({
19543
19476
  abortSignal: options.abortSignal,
19544
19477
  leaseAccessConditions: options.conditions,
@@ -19547,17 +19480,7 @@ class BlobClient extends StorageClient {
19547
19480
  tracingOptions: updatedOptions.tracingOptions,
19548
19481
  }));
19549
19482
  return Object.assign(Object.assign({}, res), { _response: res._response, objectReplicationDestinationPolicyId: res.objectReplicationPolicyId, objectReplicationSourceProperties: parseObjectReplicationRecord(res.objectReplicationRules) });
19550
- }
19551
- catch (e) {
19552
- span.setStatus({
19553
- code: coreTracing.SpanStatusCode.ERROR,
19554
- message: e.message,
19555
- });
19556
- throw e;
19557
- }
19558
- finally {
19559
- span.end();
19560
- }
19483
+ });
19561
19484
  }
19562
19485
  /**
19563
19486
  * Marks the specified blob or snapshot for deletion. The blob is later deleted
@@ -19569,10 +19492,9 @@ class BlobClient extends StorageClient {
19569
19492
  * @param options - Optional options to Blob Delete operation.
19570
19493
  */
19571
19494
  async delete(options = {}) {
19572
- var _a;
19573
- const { span, updatedOptions } = createSpan("BlobClient-delete", options);
19574
19495
  options.conditions = options.conditions || {};
19575
- try {
19496
+ return tracingClient.withSpan("BlobClient-delete", options, async (updatedOptions) => {
19497
+ var _a;
19576
19498
  return assertResponse(await this.blobContext.delete({
19577
19499
  abortSignal: options.abortSignal,
19578
19500
  deleteSnapshots: options.deleteSnapshots,
@@ -19580,17 +19502,7 @@ class BlobClient extends StorageClient {
19580
19502
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
19581
19503
  tracingOptions: updatedOptions.tracingOptions,
19582
19504
  }));
19583
- }
19584
- catch (e) {
19585
- span.setStatus({
19586
- code: coreTracing.SpanStatusCode.ERROR,
19587
- message: e.message,
19588
- });
19589
- throw e;
19590
- }
19591
- finally {
19592
- span.end();
19593
- }
19505
+ });
19594
19506
  }
19595
19507
  /**
19596
19508
  * Marks the specified blob or snapshot for deletion if it exists. The blob is later deleted
@@ -19602,29 +19514,19 @@ class BlobClient extends StorageClient {
19602
19514
  * @param options - Optional options to Blob Delete operation.
19603
19515
  */
19604
19516
  async deleteIfExists(options = {}) {
19605
- var _a, _b;
19606
- const { span, updatedOptions } = createSpan("BlobClient-deleteIfExists", options);
19607
- try {
19608
- const res = assertResponse(await this.delete(updatedOptions));
19609
- return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
19610
- }
19611
- catch (e) {
19612
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobNotFound") {
19613
- span.setStatus({
19614
- code: coreTracing.SpanStatusCode.ERROR,
19615
- message: "Expected exception when deleting a blob or snapshot only if it exists.",
19616
- });
19617
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
19517
+ return tracingClient.withSpan("BlobClient-deleteIfExists", options, async (updatedOptions) => {
19518
+ var _a, _b;
19519
+ try {
19520
+ const res = assertResponse(await this.delete(updatedOptions));
19521
+ return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
19618
19522
  }
19619
- span.setStatus({
19620
- code: coreTracing.SpanStatusCode.ERROR,
19621
- message: e.message,
19622
- });
19623
- throw e;
19624
- }
19625
- finally {
19626
- span.end();
19627
- }
19523
+ catch (e) {
19524
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobNotFound") {
19525
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
19526
+ }
19527
+ throw e;
19528
+ }
19529
+ });
19628
19530
  }
19629
19531
  /**
19630
19532
  * Restores the contents and metadata of soft deleted blob and any associated
@@ -19635,23 +19537,12 @@ class BlobClient extends StorageClient {
19635
19537
  * @param options - Optional options to Blob Undelete operation.
19636
19538
  */
19637
19539
  async undelete(options = {}) {
19638
- const { span, updatedOptions } = createSpan("BlobClient-undelete", options);
19639
- try {
19540
+ return tracingClient.withSpan("BlobClient-undelete", options, async (updatedOptions) => {
19640
19541
  return assertResponse(await this.blobContext.undelete({
19641
19542
  abortSignal: options.abortSignal,
19642
19543
  tracingOptions: updatedOptions.tracingOptions,
19643
19544
  }));
19644
- }
19645
- catch (e) {
19646
- span.setStatus({
19647
- code: coreTracing.SpanStatusCode.ERROR,
19648
- message: e.message,
19649
- });
19650
- throw e;
19651
- }
19652
- finally {
19653
- span.end();
19654
- }
19545
+ });
19655
19546
  }
19656
19547
  /**
19657
19548
  * Sets system properties on the blob.
@@ -19669,11 +19560,10 @@ class BlobClient extends StorageClient {
19669
19560
  * @param options - Optional options to Blob Set HTTP Headers operation.
19670
19561
  */
19671
19562
  async setHTTPHeaders(blobHTTPHeaders, options = {}) {
19672
- var _a;
19673
- const { span, updatedOptions } = createSpan("BlobClient-setHTTPHeaders", options);
19674
19563
  options.conditions = options.conditions || {};
19675
- try {
19676
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19564
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19565
+ return tracingClient.withSpan("BlobClient-setHTTPHeaders", options, async (updatedOptions) => {
19566
+ var _a;
19677
19567
  return assertResponse(await this.blobContext.setHttpHeaders({
19678
19568
  abortSignal: options.abortSignal,
19679
19569
  blobHttpHeaders: blobHTTPHeaders,
@@ -19682,17 +19572,7 @@ class BlobClient extends StorageClient {
19682
19572
  // cpkInfo: options.customerProvidedKey, // CPK is not included in Swagger, should change this back when this issue is fixed in Swagger.
19683
19573
  tracingOptions: updatedOptions.tracingOptions,
19684
19574
  }));
19685
- }
19686
- catch (e) {
19687
- span.setStatus({
19688
- code: coreTracing.SpanStatusCode.ERROR,
19689
- message: e.message,
19690
- });
19691
- throw e;
19692
- }
19693
- finally {
19694
- span.end();
19695
- }
19575
+ });
19696
19576
  }
19697
19577
  /**
19698
19578
  * Sets user-defined metadata for the specified blob as one or more name-value pairs.
@@ -19706,11 +19586,10 @@ class BlobClient extends StorageClient {
19706
19586
  * @param options - Optional options to Set Metadata operation.
19707
19587
  */
19708
19588
  async setMetadata(metadata, options = {}) {
19709
- var _a;
19710
- const { span, updatedOptions } = createSpan("BlobClient-setMetadata", options);
19711
19589
  options.conditions = options.conditions || {};
19712
- try {
19713
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19590
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19591
+ return tracingClient.withSpan("BlobClient-setMetadata", options, async (updatedOptions) => {
19592
+ var _a;
19714
19593
  return assertResponse(await this.blobContext.setMetadata({
19715
19594
  abortSignal: options.abortSignal,
19716
19595
  leaseAccessConditions: options.conditions,
@@ -19720,17 +19599,7 @@ class BlobClient extends StorageClient {
19720
19599
  encryptionScope: options.encryptionScope,
19721
19600
  tracingOptions: updatedOptions.tracingOptions,
19722
19601
  }));
19723
- }
19724
- catch (e) {
19725
- span.setStatus({
19726
- code: coreTracing.SpanStatusCode.ERROR,
19727
- message: e.message,
19728
- });
19729
- throw e;
19730
- }
19731
- finally {
19732
- span.end();
19733
- }
19602
+ });
19734
19603
  }
19735
19604
  /**
19736
19605
  * Sets tags on the underlying blob.
@@ -19742,9 +19611,8 @@ class BlobClient extends StorageClient {
19742
19611
  * @param options -
19743
19612
  */
19744
19613
  async setTags(tags, options = {}) {
19745
- var _a;
19746
- const { span, updatedOptions } = createSpan("BlobClient-setTags", options);
19747
- try {
19614
+ return tracingClient.withSpan("BlobClient-setTags", options, async (updatedOptions) => {
19615
+ var _a;
19748
19616
  return assertResponse(await this.blobContext.setTags({
19749
19617
  abortSignal: options.abortSignal,
19750
19618
  leaseAccessConditions: options.conditions,
@@ -19752,17 +19620,7 @@ class BlobClient extends StorageClient {
19752
19620
  tracingOptions: updatedOptions.tracingOptions,
19753
19621
  tags: toBlobTags(tags),
19754
19622
  }));
19755
- }
19756
- catch (e) {
19757
- span.setStatus({
19758
- code: coreTracing.SpanStatusCode.ERROR,
19759
- message: e.message,
19760
- });
19761
- throw e;
19762
- }
19763
- finally {
19764
- span.end();
19765
- }
19623
+ });
19766
19624
  }
19767
19625
  /**
19768
19626
  * Gets the tags associated with the underlying blob.
@@ -19770,9 +19628,8 @@ class BlobClient extends StorageClient {
19770
19628
  * @param options -
19771
19629
  */
19772
19630
  async getTags(options = {}) {
19773
- var _a;
19774
- const { span, updatedOptions } = createSpan("BlobClient-getTags", options);
19775
- try {
19631
+ return tracingClient.withSpan("BlobClient-getTags", options, async (updatedOptions) => {
19632
+ var _a;
19776
19633
  const response = assertResponse(await this.blobContext.getTags({
19777
19634
  abortSignal: options.abortSignal,
19778
19635
  leaseAccessConditions: options.conditions,
@@ -19781,17 +19638,7 @@ class BlobClient extends StorageClient {
19781
19638
  }));
19782
19639
  const wrappedResponse = Object.assign(Object.assign({}, response), { _response: response._response, tags: toTags({ blobTagSet: response.blobTagSet }) || {} });
19783
19640
  return wrappedResponse;
19784
- }
19785
- catch (e) {
19786
- span.setStatus({
19787
- code: coreTracing.SpanStatusCode.ERROR,
19788
- message: e.message,
19789
- });
19790
- throw e;
19791
- }
19792
- finally {
19793
- span.end();
19794
- }
19641
+ });
19795
19642
  }
19796
19643
  /**
19797
19644
  * Get a {@link BlobLeaseClient} that manages leases on the blob.
@@ -19809,11 +19656,10 @@ class BlobClient extends StorageClient {
19809
19656
  * @param options - Optional options to the Blob Create Snapshot operation.
19810
19657
  */
19811
19658
  async createSnapshot(options = {}) {
19812
- var _a;
19813
- const { span, updatedOptions } = createSpan("BlobClient-createSnapshot", options);
19814
19659
  options.conditions = options.conditions || {};
19815
- try {
19816
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19660
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
19661
+ return tracingClient.withSpan("BlobClient-createSnapshot", options, async (updatedOptions) => {
19662
+ var _a;
19817
19663
  return assertResponse(await this.blobContext.createSnapshot({
19818
19664
  abortSignal: options.abortSignal,
19819
19665
  leaseAccessConditions: options.conditions,
@@ -19823,17 +19669,7 @@ class BlobClient extends StorageClient {
19823
19669
  encryptionScope: options.encryptionScope,
19824
19670
  tracingOptions: updatedOptions.tracingOptions,
19825
19671
  }));
19826
- }
19827
- catch (e) {
19828
- span.setStatus({
19829
- code: coreTracing.SpanStatusCode.ERROR,
19830
- message: e.message,
19831
- });
19832
- throw e;
19833
- }
19834
- finally {
19835
- span.end();
19836
- }
19672
+ });
19837
19673
  }
19838
19674
  /**
19839
19675
  * Asynchronously copies a blob to a destination within the storage account.
@@ -19935,24 +19771,13 @@ class BlobClient extends StorageClient {
19935
19771
  * @param options - Optional options to the Blob Abort Copy From URL operation.
19936
19772
  */
19937
19773
  async abortCopyFromURL(copyId, options = {}) {
19938
- const { span, updatedOptions } = createSpan("BlobClient-abortCopyFromURL", options);
19939
- try {
19774
+ return tracingClient.withSpan("BlobClient-abortCopyFromURL", options, async (updatedOptions) => {
19940
19775
  return assertResponse(await this.blobContext.abortCopyFromURL(copyId, {
19941
19776
  abortSignal: options.abortSignal,
19942
19777
  leaseAccessConditions: options.conditions,
19943
19778
  tracingOptions: updatedOptions.tracingOptions,
19944
19779
  }));
19945
- }
19946
- catch (e) {
19947
- span.setStatus({
19948
- code: coreTracing.SpanStatusCode.ERROR,
19949
- message: e.message,
19950
- });
19951
- throw e;
19952
- }
19953
- finally {
19954
- span.end();
19955
- }
19780
+ });
19956
19781
  }
19957
19782
  /**
19958
19783
  * The synchronous Copy From URL operation copies a blob or an internet resource to a new blob. It will not
@@ -19963,44 +19788,33 @@ class BlobClient extends StorageClient {
19963
19788
  * @param options -
19964
19789
  */
19965
19790
  async syncCopyFromURL(copySource, options = {}) {
19966
- var _a, _b, _c;
19967
- const { span, updatedOptions } = createSpan("BlobClient-syncCopyFromURL", options);
19968
19791
  options.conditions = options.conditions || {};
19969
19792
  options.sourceConditions = options.sourceConditions || {};
19970
- try {
19793
+ return tracingClient.withSpan("BlobClient-syncCopyFromURL", options, async (updatedOptions) => {
19794
+ var _a, _b, _c, _d, _e, _f, _g;
19971
19795
  return assertResponse(await this.blobContext.copyFromURL(copySource, {
19972
19796
  abortSignal: options.abortSignal,
19973
19797
  metadata: options.metadata,
19974
19798
  leaseAccessConditions: options.conditions,
19975
19799
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
19976
19800
  sourceModifiedAccessConditions: {
19977
- sourceIfMatch: options.sourceConditions.ifMatch,
19978
- sourceIfModifiedSince: options.sourceConditions.ifModifiedSince,
19979
- sourceIfNoneMatch: options.sourceConditions.ifNoneMatch,
19980
- sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince,
19801
+ sourceIfMatch: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifMatch,
19802
+ sourceIfModifiedSince: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifModifiedSince,
19803
+ sourceIfNoneMatch: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch,
19804
+ sourceIfUnmodifiedSince: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.ifUnmodifiedSince,
19981
19805
  },
19982
19806
  sourceContentMD5: options.sourceContentMD5,
19983
19807
  copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization),
19984
19808
  tier: toAccessTier(options.tier),
19985
19809
  blobTagsString: toBlobTagsString(options.tags),
19986
- immutabilityPolicyExpiry: (_b = options.immutabilityPolicy) === null || _b === void 0 ? void 0 : _b.expiriesOn,
19987
- immutabilityPolicyMode: (_c = options.immutabilityPolicy) === null || _c === void 0 ? void 0 : _c.policyMode,
19810
+ immutabilityPolicyExpiry: (_f = options.immutabilityPolicy) === null || _f === void 0 ? void 0 : _f.expiriesOn,
19811
+ immutabilityPolicyMode: (_g = options.immutabilityPolicy) === null || _g === void 0 ? void 0 : _g.policyMode,
19988
19812
  legalHold: options.legalHold,
19989
19813
  encryptionScope: options.encryptionScope,
19990
19814
  copySourceTags: options.copySourceTags,
19991
19815
  tracingOptions: updatedOptions.tracingOptions,
19992
19816
  }));
19993
- }
19994
- catch (e) {
19995
- span.setStatus({
19996
- code: coreTracing.SpanStatusCode.ERROR,
19997
- message: e.message,
19998
- });
19999
- throw e;
20000
- }
20001
- finally {
20002
- span.end();
20003
- }
19817
+ });
20004
19818
  }
20005
19819
  /**
20006
19820
  * Sets the tier on a blob. The operation is allowed on a page blob in a premium
@@ -20014,9 +19828,8 @@ class BlobClient extends StorageClient {
20014
19828
  * @param options - Optional options to the Blob Set Tier operation.
20015
19829
  */
20016
19830
  async setAccessTier(tier, options = {}) {
20017
- var _a;
20018
- const { span, updatedOptions } = createSpan("BlobClient-setAccessTier", options);
20019
- try {
19831
+ return tracingClient.withSpan("BlobClient-setAccessTier", options, async (updatedOptions) => {
19832
+ var _a;
20020
19833
  return assertResponse(await this.blobContext.setTier(toAccessTier(tier), {
20021
19834
  abortSignal: options.abortSignal,
20022
19835
  leaseAccessConditions: options.conditions,
@@ -20024,19 +19837,10 @@ class BlobClient extends StorageClient {
20024
19837
  rehydratePriority: options.rehydratePriority,
20025
19838
  tracingOptions: updatedOptions.tracingOptions,
20026
19839
  }));
20027
- }
20028
- catch (e) {
20029
- span.setStatus({
20030
- code: coreTracing.SpanStatusCode.ERROR,
20031
- message: e.message,
20032
- });
20033
- throw e;
20034
- }
20035
- finally {
20036
- span.end();
20037
- }
19840
+ });
20038
19841
  }
20039
19842
  async downloadToBuffer(param1, param2, param3, param4 = {}) {
19843
+ var _a;
20040
19844
  let buffer;
20041
19845
  let offset = 0;
20042
19846
  let count = 0;
@@ -20051,26 +19855,23 @@ class BlobClient extends StorageClient {
20051
19855
  count = typeof param2 === "number" ? param2 : 0;
20052
19856
  options = param3 || {};
20053
19857
  }
20054
- const { span, updatedOptions } = createSpan("BlobClient-downloadToBuffer", options);
20055
- try {
20056
- if (!options.blockSize) {
20057
- options.blockSize = 0;
20058
- }
20059
- if (options.blockSize < 0) {
20060
- throw new RangeError("blockSize option must be >= 0");
20061
- }
20062
- if (options.blockSize === 0) {
20063
- options.blockSize = DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES;
20064
- }
20065
- if (offset < 0) {
20066
- throw new RangeError("offset option must be >= 0");
20067
- }
20068
- if (count && count <= 0) {
20069
- throw new RangeError("count option must be greater than 0");
20070
- }
20071
- if (!options.conditions) {
20072
- options.conditions = {};
20073
- }
19858
+ let blockSize = (_a = options.blockSize) !== null && _a !== void 0 ? _a : 0;
19859
+ if (blockSize < 0) {
19860
+ throw new RangeError("blockSize option must be >= 0");
19861
+ }
19862
+ if (blockSize === 0) {
19863
+ blockSize = DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES;
19864
+ }
19865
+ if (offset < 0) {
19866
+ throw new RangeError("offset option must be >= 0");
19867
+ }
19868
+ if (count && count <= 0) {
19869
+ throw new RangeError("count option must be greater than 0");
19870
+ }
19871
+ if (!options.conditions) {
19872
+ options.conditions = {};
19873
+ }
19874
+ return tracingClient.withSpan("BlobClient-downloadToBuffer", options, async (updatedOptions) => {
20074
19875
  // Customer doesn't specify length, get it
20075
19876
  if (!count) {
20076
19877
  const response = await this.getProperties(Object.assign(Object.assign({}, options), { tracingOptions: updatedOptions.tracingOptions }));
@@ -20093,12 +19894,12 @@ class BlobClient extends StorageClient {
20093
19894
  }
20094
19895
  let transferProgress = 0;
20095
19896
  const batch = new Batch(options.concurrency);
20096
- for (let off = offset; off < offset + count; off = off + options.blockSize) {
19897
+ for (let off = offset; off < offset + count; off = off + blockSize) {
20097
19898
  batch.addOperation(async () => {
20098
19899
  // Exclusive chunk end position
20099
19900
  let chunkEnd = offset + count;
20100
- if (off + options.blockSize < chunkEnd) {
20101
- chunkEnd = off + options.blockSize;
19901
+ if (off + blockSize < chunkEnd) {
19902
+ chunkEnd = off + blockSize;
20102
19903
  }
20103
19904
  const response = await this.download(off, chunkEnd - off, {
20104
19905
  abortSignal: options.abortSignal,
@@ -20120,17 +19921,7 @@ class BlobClient extends StorageClient {
20120
19921
  }
20121
19922
  await batch.do();
20122
19923
  return buffer;
20123
- }
20124
- catch (e) {
20125
- span.setStatus({
20126
- code: coreTracing.SpanStatusCode.ERROR,
20127
- message: e.message,
20128
- });
20129
- throw e;
20130
- }
20131
- finally {
20132
- span.end();
20133
- }
19924
+ });
20134
19925
  }
20135
19926
  /**
20136
19927
  * ONLY AVAILABLE IN NODE.JS RUNTIME.
@@ -20149,8 +19940,7 @@ class BlobClient extends StorageClient {
20149
19940
  * at the specified path.
20150
19941
  */
20151
19942
  async downloadToFile(filePath, offset = 0, count, options = {}) {
20152
- const { span, updatedOptions } = createSpan("BlobClient-downloadToFile", options);
20153
- try {
19943
+ return tracingClient.withSpan("BlobClient-downloadToFile", options, async (updatedOptions) => {
20154
19944
  const response = await this.download(offset, count, Object.assign(Object.assign({}, options), { tracingOptions: updatedOptions.tracingOptions }));
20155
19945
  if (response.readableStreamBody) {
20156
19946
  await readStreamToLocalFile(response.readableStreamBody, filePath);
@@ -20158,17 +19948,7 @@ class BlobClient extends StorageClient {
20158
19948
  // The stream is no longer accessible so setting it to undefined.
20159
19949
  response.blobDownloadStream = undefined;
20160
19950
  return response;
20161
- }
20162
- catch (e) {
20163
- span.setStatus({
20164
- code: coreTracing.SpanStatusCode.ERROR,
20165
- message: e.message,
20166
- });
20167
- throw e;
20168
- }
20169
- finally {
20170
- span.end();
20171
- }
19951
+ });
20172
19952
  }
20173
19953
  getBlobAndContainerNamesFromUrl() {
20174
19954
  let containerName;
@@ -20233,11 +20013,10 @@ class BlobClient extends StorageClient {
20233
20013
  * @param options - Optional options to the Blob Start Copy From URL operation.
20234
20014
  */
20235
20015
  async startCopyFromURL(copySource, options = {}) {
20236
- var _a, _b, _c;
20237
- const { span, updatedOptions } = createSpan("BlobClient-startCopyFromURL", options);
20238
- options.conditions = options.conditions || {};
20239
- options.sourceConditions = options.sourceConditions || {};
20240
- try {
20016
+ return tracingClient.withSpan("BlobClient-startCopyFromURL", options, async (updatedOptions) => {
20017
+ var _a, _b, _c;
20018
+ options.conditions = options.conditions || {};
20019
+ options.sourceConditions = options.sourceConditions || {};
20241
20020
  return assertResponse(await this.blobContext.startCopyFromURL(copySource, {
20242
20021
  abortSignal: options.abortSignal,
20243
20022
  leaseAccessConditions: options.conditions,
@@ -20259,17 +20038,7 @@ class BlobClient extends StorageClient {
20259
20038
  sealBlob: options.sealBlob,
20260
20039
  tracingOptions: updatedOptions.tracingOptions,
20261
20040
  }));
20262
- }
20263
- catch (e) {
20264
- span.setStatus({
20265
- code: coreTracing.SpanStatusCode.ERROR,
20266
- message: e.message,
20267
- });
20268
- throw e;
20269
- }
20270
- finally {
20271
- span.end();
20272
- }
20041
+ });
20273
20042
  }
20274
20043
  /**
20275
20044
  * Only available for BlobClient constructed with a shared key credential.
@@ -20296,71 +20065,38 @@ class BlobClient extends StorageClient {
20296
20065
  *
20297
20066
  * @param options - Optional options to delete immutability policy on the blob.
20298
20067
  */
20299
- async deleteImmutabilityPolicy(options) {
20300
- const { span, updatedOptions } = createSpan("BlobClient-deleteImmutabilityPolicy", options);
20301
- try {
20068
+ async deleteImmutabilityPolicy(options = {}) {
20069
+ return tracingClient.withSpan("BlobClient-deleteImmutabilityPolicy", options, async (updatedOptions) => {
20302
20070
  return assertResponse(await this.blobContext.deleteImmutabilityPolicy({
20303
20071
  tracingOptions: updatedOptions.tracingOptions,
20304
20072
  }));
20305
- }
20306
- catch (e) {
20307
- span.setStatus({
20308
- code: coreTracing.SpanStatusCode.ERROR,
20309
- message: e.message,
20310
- });
20311
- throw e;
20312
- }
20313
- finally {
20314
- span.end();
20315
- }
20073
+ });
20316
20074
  }
20317
20075
  /**
20318
- * Set immutablility policy on the blob.
20076
+ * Set immutability policy on the blob.
20319
20077
  *
20320
20078
  * @param options - Optional options to set immutability policy on the blob.
20321
20079
  */
20322
- async setImmutabilityPolicy(immutabilityPolicy, options) {
20323
- const { span, updatedOptions } = createSpan("BlobClient-setImmutabilityPolicy", options);
20324
- try {
20080
+ async setImmutabilityPolicy(immutabilityPolicy, options = {}) {
20081
+ return tracingClient.withSpan("BlobClient-setImmutabilityPolicy", options, async (updatedOptions) => {
20325
20082
  return assertResponse(await this.blobContext.setImmutabilityPolicy({
20326
20083
  immutabilityPolicyExpiry: immutabilityPolicy.expiriesOn,
20327
20084
  immutabilityPolicyMode: immutabilityPolicy.policyMode,
20328
20085
  tracingOptions: updatedOptions.tracingOptions,
20329
20086
  }));
20330
- }
20331
- catch (e) {
20332
- span.setStatus({
20333
- code: coreTracing.SpanStatusCode.ERROR,
20334
- message: e.message,
20335
- });
20336
- throw e;
20337
- }
20338
- finally {
20339
- span.end();
20340
- }
20087
+ });
20341
20088
  }
20342
20089
  /**
20343
20090
  * Set legal hold on the blob.
20344
20091
  *
20345
20092
  * @param options - Optional options to set legal hold on the blob.
20346
20093
  */
20347
- async setLegalHold(legalHoldEnabled, options) {
20348
- const { span, updatedOptions } = createSpan("BlobClient-setLegalHold", options);
20349
- try {
20094
+ async setLegalHold(legalHoldEnabled, options = {}) {
20095
+ return tracingClient.withSpan("BlobClient-setLegalHold", options, async (updatedOptions) => {
20350
20096
  return assertResponse(await this.blobContext.setLegalHold(legalHoldEnabled, {
20351
20097
  tracingOptions: updatedOptions.tracingOptions,
20352
20098
  }));
20353
- }
20354
- catch (e) {
20355
- span.setStatus({
20356
- code: coreTracing.SpanStatusCode.ERROR,
20357
- message: e.message,
20358
- });
20359
- throw e;
20360
- }
20361
- finally {
20362
- span.end();
20363
- }
20099
+ });
20364
20100
  }
20365
20101
  }
20366
20102
  /**
@@ -20460,11 +20196,10 @@ class AppendBlobClient extends BlobClient {
20460
20196
  * ```
20461
20197
  */
20462
20198
  async create(options = {}) {
20463
- var _a, _b, _c;
20464
- const { span, updatedOptions } = createSpan("AppendBlobClient-create", options);
20465
20199
  options.conditions = options.conditions || {};
20466
- try {
20467
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20200
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20201
+ return tracingClient.withSpan("AppendBlobClient-create", options, async (updatedOptions) => {
20202
+ var _a, _b, _c;
20468
20203
  return assertResponse(await this.appendBlobContext.create(0, {
20469
20204
  abortSignal: options.abortSignal,
20470
20205
  blobHttpHeaders: options.blobHTTPHeaders,
@@ -20479,17 +20214,7 @@ class AppendBlobClient extends BlobClient {
20479
20214
  blobTagsString: toBlobTagsString(options.tags),
20480
20215
  tracingOptions: updatedOptions.tracingOptions,
20481
20216
  }));
20482
- }
20483
- catch (e) {
20484
- span.setStatus({
20485
- code: coreTracing.SpanStatusCode.ERROR,
20486
- message: e.message,
20487
- });
20488
- throw e;
20489
- }
20490
- finally {
20491
- span.end();
20492
- }
20217
+ });
20493
20218
  }
20494
20219
  /**
20495
20220
  * Creates a 0-length append blob. Call AppendBlock to append data to an append blob.
@@ -20499,30 +20224,20 @@ class AppendBlobClient extends BlobClient {
20499
20224
  * @param options -
20500
20225
  */
20501
20226
  async createIfNotExists(options = {}) {
20502
- var _a, _b;
20503
- const { span, updatedOptions } = createSpan("AppendBlobClient-createIfNotExists", options);
20504
20227
  const conditions = { ifNoneMatch: ETagAny };
20505
- try {
20506
- const res = assertResponse(await this.create(Object.assign(Object.assign({}, updatedOptions), { conditions })));
20507
- return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
20508
- }
20509
- catch (e) {
20510
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobAlreadyExists") {
20511
- span.setStatus({
20512
- code: coreTracing.SpanStatusCode.ERROR,
20513
- message: "Expected exception when creating a blob only if it does not already exist.",
20514
- });
20515
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
20228
+ return tracingClient.withSpan("AppendBlobClient-createIfNotExists", options, async (updatedOptions) => {
20229
+ var _a, _b;
20230
+ try {
20231
+ const res = assertResponse(await this.create(Object.assign(Object.assign({}, updatedOptions), { conditions })));
20232
+ return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
20516
20233
  }
20517
- span.setStatus({
20518
- code: coreTracing.SpanStatusCode.ERROR,
20519
- message: e.message,
20520
- });
20521
- throw e;
20522
- }
20523
- finally {
20524
- span.end();
20525
- }
20234
+ catch (e) {
20235
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobAlreadyExists") {
20236
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
20237
+ }
20238
+ throw e;
20239
+ }
20240
+ });
20526
20241
  }
20527
20242
  /**
20528
20243
  * Seals the append blob, making it read only.
@@ -20530,10 +20245,9 @@ class AppendBlobClient extends BlobClient {
20530
20245
  * @param options -
20531
20246
  */
20532
20247
  async seal(options = {}) {
20533
- var _a;
20534
- const { span, updatedOptions } = createSpan("AppendBlobClient-seal", options);
20535
20248
  options.conditions = options.conditions || {};
20536
- try {
20249
+ return tracingClient.withSpan("AppendBlobClient-seal", options, async (updatedOptions) => {
20250
+ var _a;
20537
20251
  return assertResponse(await this.appendBlobContext.seal({
20538
20252
  abortSignal: options.abortSignal,
20539
20253
  appendPositionAccessConditions: options.conditions,
@@ -20541,17 +20255,7 @@ class AppendBlobClient extends BlobClient {
20541
20255
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
20542
20256
  tracingOptions: updatedOptions.tracingOptions,
20543
20257
  }));
20544
- }
20545
- catch (e) {
20546
- span.setStatus({
20547
- code: coreTracing.SpanStatusCode.ERROR,
20548
- message: e.message,
20549
- });
20550
- throw e;
20551
- }
20552
- finally {
20553
- span.end();
20554
- }
20258
+ });
20555
20259
  }
20556
20260
  /**
20557
20261
  * Commits a new block of data to the end of the existing append blob.
@@ -20578,11 +20282,10 @@ class AppendBlobClient extends BlobClient {
20578
20282
  * ```
20579
20283
  */
20580
20284
  async appendBlock(body, contentLength, options = {}) {
20581
- var _a;
20582
- const { span, updatedOptions } = createSpan("AppendBlobClient-appendBlock", options);
20583
20285
  options.conditions = options.conditions || {};
20584
- try {
20585
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20286
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20287
+ return tracingClient.withSpan("AppendBlobClient-appendBlock", options, async (updatedOptions) => {
20288
+ var _a;
20586
20289
  return assertResponse(await this.appendBlobContext.appendBlock(contentLength, body, {
20587
20290
  abortSignal: options.abortSignal,
20588
20291
  appendPositionAccessConditions: options.conditions,
@@ -20597,17 +20300,7 @@ class AppendBlobClient extends BlobClient {
20597
20300
  encryptionScope: options.encryptionScope,
20598
20301
  tracingOptions: updatedOptions.tracingOptions,
20599
20302
  }));
20600
- }
20601
- catch (e) {
20602
- span.setStatus({
20603
- code: coreTracing.SpanStatusCode.ERROR,
20604
- message: e.message,
20605
- });
20606
- throw e;
20607
- }
20608
- finally {
20609
- span.end();
20610
- }
20303
+ });
20611
20304
  }
20612
20305
  /**
20613
20306
  * The Append Block operation commits a new block of data to the end of an existing append blob
@@ -20624,12 +20317,11 @@ class AppendBlobClient extends BlobClient {
20624
20317
  * @param options -
20625
20318
  */
20626
20319
  async appendBlockFromURL(sourceURL, sourceOffset, count, options = {}) {
20627
- var _a;
20628
- const { span, updatedOptions } = createSpan("AppendBlobClient-appendBlockFromURL", options);
20629
20320
  options.conditions = options.conditions || {};
20630
20321
  options.sourceConditions = options.sourceConditions || {};
20631
- try {
20632
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20322
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20323
+ return tracingClient.withSpan("AppendBlobClient-appendBlockFromURL", options, async (updatedOptions) => {
20324
+ var _a, _b, _c, _d, _e;
20633
20325
  return assertResponse(await this.appendBlobContext.appendBlockFromUrl(sourceURL, 0, {
20634
20326
  abortSignal: options.abortSignal,
20635
20327
  sourceRange: rangeToString({ offset: sourceOffset, count }),
@@ -20639,27 +20331,17 @@ class AppendBlobClient extends BlobClient {
20639
20331
  appendPositionAccessConditions: options.conditions,
20640
20332
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
20641
20333
  sourceModifiedAccessConditions: {
20642
- sourceIfMatch: options.sourceConditions.ifMatch,
20643
- sourceIfModifiedSince: options.sourceConditions.ifModifiedSince,
20644
- sourceIfNoneMatch: options.sourceConditions.ifNoneMatch,
20645
- sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince,
20334
+ sourceIfMatch: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifMatch,
20335
+ sourceIfModifiedSince: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifModifiedSince,
20336
+ sourceIfNoneMatch: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch,
20337
+ sourceIfUnmodifiedSince: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.ifUnmodifiedSince,
20646
20338
  },
20647
20339
  copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization),
20648
20340
  cpkInfo: options.customerProvidedKey,
20649
20341
  encryptionScope: options.encryptionScope,
20650
20342
  tracingOptions: updatedOptions.tracingOptions,
20651
20343
  }));
20652
- }
20653
- catch (e) {
20654
- span.setStatus({
20655
- code: coreTracing.SpanStatusCode.ERROR,
20656
- message: e.message,
20657
- });
20658
- throw e;
20659
- }
20660
- finally {
20661
- span.end();
20662
- }
20344
+ });
20663
20345
  }
20664
20346
  }
20665
20347
  /**
@@ -20776,14 +20458,12 @@ class BlockBlobClient extends BlobClient {
20776
20458
  * @param options -
20777
20459
  */
20778
20460
  async query(query, options = {}) {
20779
- var _a;
20780
20461
  ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20781
- const { span, updatedOptions } = createSpan("BlockBlobClient-query", options);
20782
- try {
20783
- if (!coreUtil.isNode) {
20784
- throw new Error("This operation currently is only supported in Node.js.");
20785
- }
20786
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20462
+ if (!coreUtil.isNode) {
20463
+ throw new Error("This operation currently is only supported in Node.js.");
20464
+ }
20465
+ return tracingClient.withSpan("BlockBlobClient-query", options, async (updatedOptions) => {
20466
+ var _a;
20787
20467
  const response = assertResponse(await this._blobContext.query({
20788
20468
  abortSignal: options.abortSignal,
20789
20469
  queryRequest: {
@@ -20802,17 +20482,7 @@ class BlockBlobClient extends BlobClient {
20802
20482
  onProgress: options.onProgress,
20803
20483
  onError: options.onError,
20804
20484
  });
20805
- }
20806
- catch (e) {
20807
- span.setStatus({
20808
- code: coreTracing.SpanStatusCode.ERROR,
20809
- message: e.message,
20810
- });
20811
- throw e;
20812
- }
20813
- finally {
20814
- span.end();
20815
- }
20485
+ });
20816
20486
  }
20817
20487
  /**
20818
20488
  * Creates a new block blob, or updates the content of an existing block blob.
@@ -20842,11 +20512,10 @@ class BlockBlobClient extends BlobClient {
20842
20512
  * ```
20843
20513
  */
20844
20514
  async upload(body, contentLength, options = {}) {
20845
- var _a, _b, _c;
20846
20515
  options.conditions = options.conditions || {};
20847
- const { span, updatedOptions } = createSpan("BlockBlobClient-upload", options);
20848
- try {
20849
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20516
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20517
+ return tracingClient.withSpan("BlockBlobClient-upload", options, async (updatedOptions) => {
20518
+ var _a, _b, _c;
20850
20519
  return assertResponse(await this.blockBlobContext.upload(contentLength, body, {
20851
20520
  abortSignal: options.abortSignal,
20852
20521
  blobHttpHeaders: options.blobHTTPHeaders,
@@ -20865,17 +20534,7 @@ class BlockBlobClient extends BlobClient {
20865
20534
  blobTagsString: toBlobTagsString(options.tags),
20866
20535
  tracingOptions: updatedOptions.tracingOptions,
20867
20536
  }));
20868
- }
20869
- catch (e) {
20870
- span.setStatus({
20871
- code: coreTracing.SpanStatusCode.ERROR,
20872
- message: e.message,
20873
- });
20874
- throw e;
20875
- }
20876
- finally {
20877
- span.end();
20878
- }
20537
+ });
20879
20538
  }
20880
20539
  /**
20881
20540
  * Creates a new Block Blob where the contents of the blob are read from a given URL.
@@ -20896,29 +20555,18 @@ class BlockBlobClient extends BlobClient {
20896
20555
  * @param options - Optional parameters.
20897
20556
  */
20898
20557
  async syncUploadFromURL(sourceURL, options = {}) {
20899
- var _a, _b, _c, _d, _e;
20900
20558
  options.conditions = options.conditions || {};
20901
- const { span, updatedOptions } = createSpan("BlockBlobClient-syncUploadFromURL", options);
20902
- try {
20903
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20904
- 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: {
20905
- sourceIfMatch: (_a = options.sourceConditions) === null || _a === void 0 ? void 0 : _a.ifMatch,
20906
- sourceIfModifiedSince: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifModifiedSince,
20907
- sourceIfNoneMatch: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifNoneMatch,
20908
- sourceIfUnmodifiedSince: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifUnmodifiedSince,
20909
- sourceIfTags: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.tagConditions,
20559
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20560
+ return tracingClient.withSpan("BlockBlobClient-syncUploadFromURL", options, async (updatedOptions) => {
20561
+ var _a, _b, _c, _d, _e, _f;
20562
+ 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: {
20563
+ sourceIfMatch: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifMatch,
20564
+ sourceIfModifiedSince: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifModifiedSince,
20565
+ sourceIfNoneMatch: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch,
20566
+ sourceIfUnmodifiedSince: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.ifUnmodifiedSince,
20567
+ sourceIfTags: (_f = options.sourceConditions) === null || _f === void 0 ? void 0 : _f.tagConditions,
20910
20568
  }, cpkInfo: options.customerProvidedKey, copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization), tier: toAccessTier(options.tier), blobTagsString: toBlobTagsString(options.tags), copySourceTags: options.copySourceTags, tracingOptions: updatedOptions.tracingOptions })));
20911
- }
20912
- catch (e) {
20913
- span.setStatus({
20914
- code: coreTracing.SpanStatusCode.ERROR,
20915
- message: e.message,
20916
- });
20917
- throw e;
20918
- }
20919
- finally {
20920
- span.end();
20921
- }
20569
+ });
20922
20570
  }
20923
20571
  /**
20924
20572
  * Uploads the specified block to the block blob's "staging area" to be later
@@ -20932,9 +20580,8 @@ class BlockBlobClient extends BlobClient {
20932
20580
  * @returns Response data for the Block Blob Stage Block operation.
20933
20581
  */
20934
20582
  async stageBlock(blockId, body, contentLength, options = {}) {
20935
- const { span, updatedOptions } = createSpan("BlockBlobClient-stageBlock", options);
20936
- try {
20937
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20583
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20584
+ return tracingClient.withSpan("BlockBlobClient-stageBlock", options, async (updatedOptions) => {
20938
20585
  return assertResponse(await this.blockBlobContext.stageBlock(blockId, contentLength, body, {
20939
20586
  abortSignal: options.abortSignal,
20940
20587
  leaseAccessConditions: options.conditions,
@@ -20947,17 +20594,7 @@ class BlockBlobClient extends BlobClient {
20947
20594
  encryptionScope: options.encryptionScope,
20948
20595
  tracingOptions: updatedOptions.tracingOptions,
20949
20596
  }));
20950
- }
20951
- catch (e) {
20952
- span.setStatus({
20953
- code: coreTracing.SpanStatusCode.ERROR,
20954
- message: e.message,
20955
- });
20956
- throw e;
20957
- }
20958
- finally {
20959
- span.end();
20960
- }
20597
+ });
20961
20598
  }
20962
20599
  /**
20963
20600
  * The Stage Block From URL operation creates a new block to be committed as part
@@ -20981,9 +20618,8 @@ class BlockBlobClient extends BlobClient {
20981
20618
  * @returns Response data for the Block Blob Stage Block From URL operation.
20982
20619
  */
20983
20620
  async stageBlockFromURL(blockId, sourceURL, offset = 0, count, options = {}) {
20984
- const { span, updatedOptions } = createSpan("BlockBlobClient-stageBlockFromURL", options);
20985
- try {
20986
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20621
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20622
+ return tracingClient.withSpan("BlockBlobClient-stageBlockFromURL", options, async (updatedOptions) => {
20987
20623
  return assertResponse(await this.blockBlobContext.stageBlockFromURL(blockId, 0, sourceURL, {
20988
20624
  abortSignal: options.abortSignal,
20989
20625
  leaseAccessConditions: options.conditions,
@@ -20995,17 +20631,7 @@ class BlockBlobClient extends BlobClient {
20995
20631
  copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization),
20996
20632
  tracingOptions: updatedOptions.tracingOptions,
20997
20633
  }));
20998
- }
20999
- catch (e) {
21000
- span.setStatus({
21001
- code: coreTracing.SpanStatusCode.ERROR,
21002
- message: e.message,
21003
- });
21004
- throw e;
21005
- }
21006
- finally {
21007
- span.end();
21008
- }
20634
+ });
21009
20635
  }
21010
20636
  /**
21011
20637
  * Writes a blob by specifying the list of block IDs that make up the blob.
@@ -21020,11 +20646,10 @@ class BlockBlobClient extends BlobClient {
21020
20646
  * @returns Response data for the Block Blob Commit Block List operation.
21021
20647
  */
21022
20648
  async commitBlockList(blocks, options = {}) {
21023
- var _a, _b, _c;
21024
20649
  options.conditions = options.conditions || {};
21025
- const { span, updatedOptions } = createSpan("BlockBlobClient-commitBlockList", options);
21026
- try {
21027
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20650
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
20651
+ return tracingClient.withSpan("BlockBlobClient-commitBlockList", options, async (updatedOptions) => {
20652
+ var _a, _b, _c;
21028
20653
  return assertResponse(await this.blockBlobContext.commitBlockList({ latest: blocks }, {
21029
20654
  abortSignal: options.abortSignal,
21030
20655
  blobHttpHeaders: options.blobHTTPHeaders,
@@ -21040,17 +20665,7 @@ class BlockBlobClient extends BlobClient {
21040
20665
  blobTagsString: toBlobTagsString(options.tags),
21041
20666
  tracingOptions: updatedOptions.tracingOptions,
21042
20667
  }));
21043
- }
21044
- catch (e) {
21045
- span.setStatus({
21046
- code: coreTracing.SpanStatusCode.ERROR,
21047
- message: e.message,
21048
- });
21049
- throw e;
21050
- }
21051
- finally {
21052
- span.end();
21053
- }
20668
+ });
21054
20669
  }
21055
20670
  /**
21056
20671
  * Returns the list of blocks that have been uploaded as part of a block blob
@@ -21063,9 +20678,8 @@ class BlockBlobClient extends BlobClient {
21063
20678
  * @returns Response data for the Block Blob Get Block List operation.
21064
20679
  */
21065
20680
  async getBlockList(listType, options = {}) {
21066
- var _a;
21067
- const { span, updatedOptions } = createSpan("BlockBlobClient-getBlockList", options);
21068
- try {
20681
+ return tracingClient.withSpan("BlockBlobClient-getBlockList", options, async (updatedOptions) => {
20682
+ var _a;
21069
20683
  const res = assertResponse(await this.blockBlobContext.getBlockList(listType, {
21070
20684
  abortSignal: options.abortSignal,
21071
20685
  leaseAccessConditions: options.conditions,
@@ -21079,17 +20693,7 @@ class BlockBlobClient extends BlobClient {
21079
20693
  res.uncommittedBlocks = [];
21080
20694
  }
21081
20695
  return res;
21082
- }
21083
- catch (e) {
21084
- span.setStatus({
21085
- code: coreTracing.SpanStatusCode.ERROR,
21086
- message: e.message,
21087
- });
21088
- throw e;
21089
- }
21090
- finally {
21091
- span.end();
21092
- }
20696
+ });
21093
20697
  }
21094
20698
  // High level functions
21095
20699
  /**
@@ -21108,8 +20712,7 @@ class BlockBlobClient extends BlobClient {
21108
20712
  * @param options -
21109
20713
  */
21110
20714
  async uploadData(data, options = {}) {
21111
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadData", options);
21112
- try {
20715
+ return tracingClient.withSpan("BlockBlobClient-uploadData", options, async (updatedOptions) => {
21113
20716
  if (coreUtil.isNode) {
21114
20717
  let buffer;
21115
20718
  if (data instanceof Buffer) {
@@ -21128,17 +20731,7 @@ class BlockBlobClient extends BlobClient {
21128
20731
  const browserBlob = new Blob([data]);
21129
20732
  return this.uploadSeekableInternal((offset, size) => browserBlob.slice(offset, offset + size), browserBlob.size, updatedOptions);
21130
20733
  }
21131
- }
21132
- catch (e) {
21133
- span.setStatus({
21134
- code: coreTracing.SpanStatusCode.ERROR,
21135
- message: e.message,
21136
- });
21137
- throw e;
21138
- }
21139
- finally {
21140
- span.end();
21141
- }
20734
+ });
21142
20735
  }
21143
20736
  /**
21144
20737
  * ONLY AVAILABLE IN BROWSERS.
@@ -21160,21 +20753,10 @@ class BlockBlobClient extends BlobClient {
21160
20753
  * @returns Response data for the Blob Upload operation.
21161
20754
  */
21162
20755
  async uploadBrowserData(browserData, options = {}) {
21163
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadBrowserData", options);
21164
- try {
20756
+ return tracingClient.withSpan("BlockBlobClient-uploadBrowserData", options, async (updatedOptions) => {
21165
20757
  const browserBlob = new Blob([browserData]);
21166
- return await this.uploadSeekableInternal((offset, size) => browserBlob.slice(offset, offset + size), browserBlob.size, updatedOptions);
21167
- }
21168
- catch (e) {
21169
- span.setStatus({
21170
- code: coreTracing.SpanStatusCode.ERROR,
21171
- message: e.message,
21172
- });
21173
- throw e;
21174
- }
21175
- finally {
21176
- span.end();
21177
- }
20758
+ return this.uploadSeekableInternal((offset, size) => browserBlob.slice(offset, offset + size), browserBlob.size, updatedOptions);
20759
+ });
21178
20760
  }
21179
20761
  /**
21180
20762
  *
@@ -21192,27 +20774,23 @@ class BlockBlobClient extends BlobClient {
21192
20774
  * @returns Response data for the Blob Upload operation.
21193
20775
  */
21194
20776
  async uploadSeekableInternal(bodyFactory, size, options = {}) {
21195
- if (!options.blockSize) {
21196
- options.blockSize = 0;
21197
- }
21198
- if (options.blockSize < 0 || options.blockSize > BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES) {
20777
+ var _a, _b;
20778
+ let blockSize = (_a = options.blockSize) !== null && _a !== void 0 ? _a : 0;
20779
+ if (blockSize < 0 || blockSize > BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES) {
21199
20780
  throw new RangeError(`blockSize option must be >= 0 and <= ${BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES}`);
21200
20781
  }
21201
- if (options.maxSingleShotSize !== 0 && !options.maxSingleShotSize) {
21202
- options.maxSingleShotSize = BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES;
21203
- }
21204
- if (options.maxSingleShotSize < 0 ||
21205
- options.maxSingleShotSize > BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES) {
20782
+ const maxSingleShotSize = (_b = options.maxSingleShotSize) !== null && _b !== void 0 ? _b : BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES;
20783
+ if (maxSingleShotSize < 0 || maxSingleShotSize > BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES) {
21206
20784
  throw new RangeError(`maxSingleShotSize option must be >= 0 and <= ${BLOCK_BLOB_MAX_UPLOAD_BLOB_BYTES}`);
21207
20785
  }
21208
- if (options.blockSize === 0) {
20786
+ if (blockSize === 0) {
21209
20787
  if (size > BLOCK_BLOB_MAX_STAGE_BLOCK_BYTES * BLOCK_BLOB_MAX_BLOCKS) {
21210
20788
  throw new RangeError(`${size} is too larger to upload to a block blob.`);
21211
20789
  }
21212
- if (size > options.maxSingleShotSize) {
21213
- options.blockSize = Math.ceil(size / BLOCK_BLOB_MAX_BLOCKS);
21214
- if (options.blockSize < DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES) {
21215
- options.blockSize = DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES;
20790
+ if (size > maxSingleShotSize) {
20791
+ blockSize = Math.ceil(size / BLOCK_BLOB_MAX_BLOCKS);
20792
+ if (blockSize < DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES) {
20793
+ blockSize = DEFAULT_BLOB_DOWNLOAD_BLOCK_BYTES;
21216
20794
  }
21217
20795
  }
21218
20796
  }
@@ -21222,12 +20800,11 @@ class BlockBlobClient extends BlobClient {
21222
20800
  if (!options.conditions) {
21223
20801
  options.conditions = {};
21224
20802
  }
21225
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadSeekableInternal", options);
21226
- try {
21227
- if (size <= options.maxSingleShotSize) {
20803
+ return tracingClient.withSpan("BlockBlobClient-uploadSeekableInternal", options, async (updatedOptions) => {
20804
+ if (size <= maxSingleShotSize) {
21228
20805
  return assertResponse(await this.upload(bodyFactory(0, size), size, updatedOptions));
21229
20806
  }
21230
- const numBlocks = Math.floor((size - 1) / options.blockSize) + 1;
20807
+ const numBlocks = Math.floor((size - 1) / blockSize) + 1;
21231
20808
  if (numBlocks > BLOCK_BLOB_MAX_BLOCKS) {
21232
20809
  throw new RangeError(`The buffer's size is too big or the BlockSize is too small;` +
21233
20810
  `the number of blocks must be <= ${BLOCK_BLOB_MAX_BLOCKS}`);
@@ -21239,8 +20816,8 @@ class BlockBlobClient extends BlobClient {
21239
20816
  for (let i = 0; i < numBlocks; i++) {
21240
20817
  batch.addOperation(async () => {
21241
20818
  const blockID = generateBlockID(blockIDPrefix, i);
21242
- const start = options.blockSize * i;
21243
- const end = i === numBlocks - 1 ? size : start + options.blockSize;
20819
+ const start = blockSize * i;
20820
+ const end = i === numBlocks - 1 ? size : start + blockSize;
21244
20821
  const contentLength = end - start;
21245
20822
  blockList.push(blockID);
21246
20823
  await this.stageBlock(blockID, bodyFactory(start, contentLength), contentLength, {
@@ -21261,17 +20838,7 @@ class BlockBlobClient extends BlobClient {
21261
20838
  }
21262
20839
  await batch.do();
21263
20840
  return this.commitBlockList(blockList, updatedOptions);
21264
- }
21265
- catch (e) {
21266
- span.setStatus({
21267
- code: coreTracing.SpanStatusCode.ERROR,
21268
- message: e.message,
21269
- });
21270
- throw e;
21271
- }
21272
- finally {
21273
- span.end();
21274
- }
20841
+ });
21275
20842
  }
21276
20843
  /**
21277
20844
  * ONLY AVAILABLE IN NODE.JS RUNTIME.
@@ -21287,27 +20854,16 @@ class BlockBlobClient extends BlobClient {
21287
20854
  * @returns Response data for the Blob Upload operation.
21288
20855
  */
21289
20856
  async uploadFile(filePath, options = {}) {
21290
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadFile", options);
21291
- try {
20857
+ return tracingClient.withSpan("BlockBlobClient-uploadFile", options, async (updatedOptions) => {
21292
20858
  const size = (await fsStat(filePath)).size;
21293
- return await this.uploadSeekableInternal((offset, count) => {
20859
+ return this.uploadSeekableInternal((offset, count) => {
21294
20860
  return () => fsCreateReadStream(filePath, {
21295
20861
  autoClose: true,
21296
20862
  end: count ? offset + count - 1 : Infinity,
21297
20863
  start: offset,
21298
20864
  });
21299
20865
  }, size, Object.assign(Object.assign({}, options), { tracingOptions: updatedOptions.tracingOptions }));
21300
- }
21301
- catch (e) {
21302
- span.setStatus({
21303
- code: coreTracing.SpanStatusCode.ERROR,
21304
- message: e.message,
21305
- });
21306
- throw e;
21307
- }
21308
- finally {
21309
- span.end();
21310
- }
20866
+ });
21311
20867
  }
21312
20868
  /**
21313
20869
  * ONLY AVAILABLE IN NODE.JS RUNTIME.
@@ -21332,8 +20888,7 @@ class BlockBlobClient extends BlobClient {
21332
20888
  if (!options.conditions) {
21333
20889
  options.conditions = {};
21334
20890
  }
21335
- const { span, updatedOptions } = createSpan("BlockBlobClient-uploadStream", options);
21336
- try {
20891
+ return tracingClient.withSpan("BlockBlobClient-uploadStream", options, async (updatedOptions) => {
21337
20892
  let blockNum = 0;
21338
20893
  const blockIDPrefix = uuid.v4();
21339
20894
  let transferProgress = 0;
@@ -21360,17 +20915,7 @@ class BlockBlobClient extends BlobClient {
21360
20915
  Math.ceil((maxConcurrency / 4) * 3));
21361
20916
  await scheduler.do();
21362
20917
  return assertResponse(await this.commitBlockList(blockList, Object.assign(Object.assign({}, options), { tracingOptions: updatedOptions.tracingOptions })));
21363
- }
21364
- catch (e) {
21365
- span.setStatus({
21366
- code: coreTracing.SpanStatusCode.ERROR,
21367
- message: e.message,
21368
- });
21369
- throw e;
21370
- }
21371
- finally {
21372
- span.end();
21373
- }
20918
+ });
21374
20919
  }
21375
20920
  }
21376
20921
  /**
@@ -21465,11 +21010,10 @@ class PageBlobClient extends BlobClient {
21465
21010
  * @returns Response data for the Page Blob Create operation.
21466
21011
  */
21467
21012
  async create(size, options = {}) {
21468
- var _a, _b, _c;
21469
21013
  options.conditions = options.conditions || {};
21470
- const { span, updatedOptions } = createSpan("PageBlobClient-create", options);
21471
- try {
21472
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
21014
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
21015
+ return tracingClient.withSpan("PageBlobClient-create", options, async (updatedOptions) => {
21016
+ var _a, _b, _c;
21473
21017
  return assertResponse(await this.pageBlobContext.create(0, size, {
21474
21018
  abortSignal: options.abortSignal,
21475
21019
  blobHttpHeaders: options.blobHTTPHeaders,
@@ -21486,17 +21030,7 @@ class PageBlobClient extends BlobClient {
21486
21030
  blobTagsString: toBlobTagsString(options.tags),
21487
21031
  tracingOptions: updatedOptions.tracingOptions,
21488
21032
  }));
21489
- }
21490
- catch (e) {
21491
- span.setStatus({
21492
- code: coreTracing.SpanStatusCode.ERROR,
21493
- message: e.message,
21494
- });
21495
- throw e;
21496
- }
21497
- finally {
21498
- span.end();
21499
- }
21033
+ });
21500
21034
  }
21501
21035
  /**
21502
21036
  * Creates a page blob of the specified length. Call uploadPages to upload data
@@ -21508,30 +21042,20 @@ class PageBlobClient extends BlobClient {
21508
21042
  * @param options -
21509
21043
  */
21510
21044
  async createIfNotExists(size, options = {}) {
21511
- var _a, _b;
21512
- const { span, updatedOptions } = createSpan("PageBlobClient-createIfNotExists", options);
21513
- try {
21514
- const conditions = { ifNoneMatch: ETagAny };
21515
- const res = assertResponse(await this.create(size, Object.assign(Object.assign({}, options), { conditions, tracingOptions: updatedOptions.tracingOptions })));
21516
- return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
21517
- }
21518
- catch (e) {
21519
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobAlreadyExists") {
21520
- span.setStatus({
21521
- code: coreTracing.SpanStatusCode.ERROR,
21522
- message: "Expected exception when creating a blob only if it does not already exist.",
21523
- });
21524
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
21045
+ return tracingClient.withSpan("PageBlobClient-createIfNotExists", options, async (updatedOptions) => {
21046
+ var _a, _b;
21047
+ try {
21048
+ const conditions = { ifNoneMatch: ETagAny };
21049
+ const res = assertResponse(await this.create(size, Object.assign(Object.assign({}, options), { conditions, tracingOptions: updatedOptions.tracingOptions })));
21050
+ return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
21525
21051
  }
21526
- span.setStatus({
21527
- code: coreTracing.SpanStatusCode.ERROR,
21528
- message: e.message,
21529
- });
21530
- throw e;
21531
- }
21532
- finally {
21533
- span.end();
21534
- }
21052
+ catch (e) {
21053
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "BlobAlreadyExists") {
21054
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
21055
+ }
21056
+ throw e;
21057
+ }
21058
+ });
21535
21059
  }
21536
21060
  /**
21537
21061
  * Writes 1 or more pages to the page blob. The start and end offsets must be a multiple of 512.
@@ -21544,11 +21068,10 @@ class PageBlobClient extends BlobClient {
21544
21068
  * @returns Response data for the Page Blob Upload Pages operation.
21545
21069
  */
21546
21070
  async uploadPages(body, offset, count, options = {}) {
21547
- var _a;
21548
21071
  options.conditions = options.conditions || {};
21549
- const { span, updatedOptions } = createSpan("PageBlobClient-uploadPages", options);
21550
- try {
21551
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
21072
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
21073
+ return tracingClient.withSpan("PageBlobClient-uploadPages", options, async (updatedOptions) => {
21074
+ var _a;
21552
21075
  return assertResponse(await this.pageBlobContext.uploadPages(count, body, {
21553
21076
  abortSignal: options.abortSignal,
21554
21077
  leaseAccessConditions: options.conditions,
@@ -21564,17 +21087,7 @@ class PageBlobClient extends BlobClient {
21564
21087
  encryptionScope: options.encryptionScope,
21565
21088
  tracingOptions: updatedOptions.tracingOptions,
21566
21089
  }));
21567
- }
21568
- catch (e) {
21569
- span.setStatus({
21570
- code: coreTracing.SpanStatusCode.ERROR,
21571
- message: e.message,
21572
- });
21573
- throw e;
21574
- }
21575
- finally {
21576
- span.end();
21577
- }
21090
+ });
21578
21091
  }
21579
21092
  /**
21580
21093
  * The Upload Pages operation writes a range of pages to a page blob where the
@@ -21588,12 +21101,11 @@ class PageBlobClient extends BlobClient {
21588
21101
  * @param options -
21589
21102
  */
21590
21103
  async uploadPagesFromURL(sourceURL, sourceOffset, destOffset, count, options = {}) {
21591
- var _a;
21592
21104
  options.conditions = options.conditions || {};
21593
21105
  options.sourceConditions = options.sourceConditions || {};
21594
- const { span, updatedOptions } = createSpan("PageBlobClient-uploadPagesFromURL", options);
21595
- try {
21596
- ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
21106
+ ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
21107
+ return tracingClient.withSpan("PageBlobClient-uploadPagesFromURL", options, async (updatedOptions) => {
21108
+ var _a, _b, _c, _d, _e;
21597
21109
  return assertResponse(await this.pageBlobContext.uploadPagesFromURL(sourceURL, rangeToString({ offset: sourceOffset, count }), 0, rangeToString({ offset: destOffset, count }), {
21598
21110
  abortSignal: options.abortSignal,
21599
21111
  sourceContentMD5: options.sourceContentMD5,
@@ -21602,27 +21114,17 @@ class PageBlobClient extends BlobClient {
21602
21114
  sequenceNumberAccessConditions: options.conditions,
21603
21115
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
21604
21116
  sourceModifiedAccessConditions: {
21605
- sourceIfMatch: options.sourceConditions.ifMatch,
21606
- sourceIfModifiedSince: options.sourceConditions.ifModifiedSince,
21607
- sourceIfNoneMatch: options.sourceConditions.ifNoneMatch,
21608
- sourceIfUnmodifiedSince: options.sourceConditions.ifUnmodifiedSince,
21117
+ sourceIfMatch: (_b = options.sourceConditions) === null || _b === void 0 ? void 0 : _b.ifMatch,
21118
+ sourceIfModifiedSince: (_c = options.sourceConditions) === null || _c === void 0 ? void 0 : _c.ifModifiedSince,
21119
+ sourceIfNoneMatch: (_d = options.sourceConditions) === null || _d === void 0 ? void 0 : _d.ifNoneMatch,
21120
+ sourceIfUnmodifiedSince: (_e = options.sourceConditions) === null || _e === void 0 ? void 0 : _e.ifUnmodifiedSince,
21609
21121
  },
21610
21122
  cpkInfo: options.customerProvidedKey,
21611
21123
  encryptionScope: options.encryptionScope,
21612
21124
  copySourceAuthorization: httpAuthorizationToString(options.sourceAuthorization),
21613
21125
  tracingOptions: updatedOptions.tracingOptions,
21614
21126
  }));
21615
- }
21616
- catch (e) {
21617
- span.setStatus({
21618
- code: coreTracing.SpanStatusCode.ERROR,
21619
- message: e.message,
21620
- });
21621
- throw e;
21622
- }
21623
- finally {
21624
- span.end();
21625
- }
21127
+ });
21626
21128
  }
21627
21129
  /**
21628
21130
  * Frees the specified pages from the page blob.
@@ -21634,10 +21136,9 @@ class PageBlobClient extends BlobClient {
21634
21136
  * @returns Response data for the Page Blob Clear Pages operation.
21635
21137
  */
21636
21138
  async clearPages(offset = 0, count, options = {}) {
21637
- var _a;
21638
21139
  options.conditions = options.conditions || {};
21639
- const { span, updatedOptions } = createSpan("PageBlobClient-clearPages", options);
21640
- try {
21140
+ return tracingClient.withSpan("PageBlobClient-clearPages", options, async (updatedOptions) => {
21141
+ var _a;
21641
21142
  return assertResponse(await this.pageBlobContext.clearPages(0, {
21642
21143
  abortSignal: options.abortSignal,
21643
21144
  leaseAccessConditions: options.conditions,
@@ -21648,17 +21149,7 @@ class PageBlobClient extends BlobClient {
21648
21149
  encryptionScope: options.encryptionScope,
21649
21150
  tracingOptions: updatedOptions.tracingOptions,
21650
21151
  }));
21651
- }
21652
- catch (e) {
21653
- span.setStatus({
21654
- code: coreTracing.SpanStatusCode.ERROR,
21655
- message: e.message,
21656
- });
21657
- throw e;
21658
- }
21659
- finally {
21660
- span.end();
21661
- }
21152
+ });
21662
21153
  }
21663
21154
  /**
21664
21155
  * Returns the list of valid page ranges for a page blob or snapshot of a page blob.
@@ -21670,10 +21161,9 @@ class PageBlobClient extends BlobClient {
21670
21161
  * @returns Response data for the Page Blob Get Ranges operation.
21671
21162
  */
21672
21163
  async getPageRanges(offset = 0, count, options = {}) {
21673
- var _a;
21674
21164
  options.conditions = options.conditions || {};
21675
- const { span, updatedOptions } = createSpan("PageBlobClient-getPageRanges", options);
21676
- try {
21165
+ return tracingClient.withSpan("PageBlobClient-getPageRanges", options, async (updatedOptions) => {
21166
+ var _a;
21677
21167
  const response = assertResponse(await this.pageBlobContext.getPageRanges({
21678
21168
  abortSignal: options.abortSignal,
21679
21169
  leaseAccessConditions: options.conditions,
@@ -21682,17 +21172,7 @@ class PageBlobClient extends BlobClient {
21682
21172
  tracingOptions: updatedOptions.tracingOptions,
21683
21173
  }));
21684
21174
  return rangeResponseFromModel(response);
21685
- }
21686
- catch (e) {
21687
- span.setStatus({
21688
- code: coreTracing.SpanStatusCode.ERROR,
21689
- message: e.message,
21690
- });
21691
- throw e;
21692
- }
21693
- finally {
21694
- span.end();
21695
- }
21175
+ });
21696
21176
  }
21697
21177
  /**
21698
21178
  * getPageRangesSegment returns a single segment of page ranges starting from the
@@ -21707,9 +21187,8 @@ class PageBlobClient extends BlobClient {
21707
21187
  * @param options - Options to PageBlob Get Page Ranges Segment operation.
21708
21188
  */
21709
21189
  async listPageRangesSegment(offset = 0, count, marker, options = {}) {
21710
- var _a;
21711
- const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesSegment", options);
21712
- try {
21190
+ return tracingClient.withSpan("PageBlobClient-getPageRangesSegment", options, async (updatedOptions) => {
21191
+ var _a;
21713
21192
  return assertResponse(await this.pageBlobContext.getPageRanges({
21714
21193
  abortSignal: options.abortSignal,
21715
21194
  leaseAccessConditions: options.conditions,
@@ -21719,17 +21198,7 @@ class PageBlobClient extends BlobClient {
21719
21198
  maxPageSize: options.maxPageSize,
21720
21199
  tracingOptions: updatedOptions.tracingOptions,
21721
21200
  }));
21722
- }
21723
- catch (e) {
21724
- span.setStatus({
21725
- code: coreTracing.SpanStatusCode.ERROR,
21726
- message: e.message,
21727
- });
21728
- throw e;
21729
- }
21730
- finally {
21731
- span.end();
21732
- }
21201
+ });
21733
21202
  }
21734
21203
  /**
21735
21204
  * Returns an AsyncIterableIterator for {@link PageBlobGetPageRangesResponseModel}
@@ -21890,10 +21359,9 @@ class PageBlobClient extends BlobClient {
21890
21359
  * @returns Response data for the Page Blob Get Page Range Diff operation.
21891
21360
  */
21892
21361
  async getPageRangesDiff(offset, count, prevSnapshot, options = {}) {
21893
- var _a;
21894
21362
  options.conditions = options.conditions || {};
21895
- const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesDiff", options);
21896
- try {
21363
+ return tracingClient.withSpan("PageBlobClient-getPageRangesDiff", options, async (updatedOptions) => {
21364
+ var _a;
21897
21365
  const result = assertResponse(await this.pageBlobContext.getPageRangesDiff({
21898
21366
  abortSignal: options.abortSignal,
21899
21367
  leaseAccessConditions: options.conditions,
@@ -21903,17 +21371,7 @@ class PageBlobClient extends BlobClient {
21903
21371
  tracingOptions: updatedOptions.tracingOptions,
21904
21372
  }));
21905
21373
  return rangeResponseFromModel(result);
21906
- }
21907
- catch (e) {
21908
- span.setStatus({
21909
- code: coreTracing.SpanStatusCode.ERROR,
21910
- message: e.message,
21911
- });
21912
- throw e;
21913
- }
21914
- finally {
21915
- span.end();
21916
- }
21374
+ });
21917
21375
  }
21918
21376
  /**
21919
21377
  * getPageRangesDiffSegment returns a single segment of page ranges starting from the
@@ -21929,10 +21387,9 @@ class PageBlobClient extends BlobClient {
21929
21387
  * @param marker - A string value that identifies the portion of the get to be returned with the next get operation.
21930
21388
  * @param options - Options to the Page Blob Get Page Ranges Diff operation.
21931
21389
  */
21932
- async listPageRangesDiffSegment(offset, count, prevSnapshotOrUrl, marker, options) {
21933
- var _a;
21934
- const { span, updatedOptions } = createSpan("PageBlobClient-getPageRangesDiffSegment", options);
21935
- try {
21390
+ async listPageRangesDiffSegment(offset, count, prevSnapshotOrUrl, marker, options = {}) {
21391
+ return tracingClient.withSpan("PageBlobClient-getPageRangesDiffSegment", options, async (updatedOptions) => {
21392
+ var _a;
21936
21393
  return assertResponse(await this.pageBlobContext.getPageRangesDiff({
21937
21394
  abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
21938
21395
  leaseAccessConditions: options === null || options === void 0 ? void 0 : options.conditions,
@@ -21946,17 +21403,7 @@ class PageBlobClient extends BlobClient {
21946
21403
  maxPageSize: options === null || options === void 0 ? void 0 : options.maxPageSize,
21947
21404
  tracingOptions: updatedOptions.tracingOptions,
21948
21405
  }));
21949
- }
21950
- catch (e) {
21951
- span.setStatus({
21952
- code: coreTracing.SpanStatusCode.ERROR,
21953
- message: e.message,
21954
- });
21955
- throw e;
21956
- }
21957
- finally {
21958
- span.end();
21959
- }
21406
+ });
21960
21407
  }
21961
21408
  /**
21962
21409
  * Returns an AsyncIterableIterator for {@link PageBlobGetPageRangesDiffResponseModel}
@@ -22121,10 +21568,9 @@ class PageBlobClient extends BlobClient {
22121
21568
  * @returns Response data for the Page Blob Get Page Range Diff operation.
22122
21569
  */
22123
21570
  async getPageRangesDiffForManagedDisks(offset, count, prevSnapshotUrl, options = {}) {
22124
- var _a;
22125
21571
  options.conditions = options.conditions || {};
22126
- const { span, updatedOptions } = createSpan("PageBlobClient-GetPageRangesDiffForManagedDisks", options);
22127
- try {
21572
+ return tracingClient.withSpan("PageBlobClient-GetPageRangesDiffForManagedDisks", options, async (updatedOptions) => {
21573
+ var _a;
22128
21574
  const response = assertResponse(await this.pageBlobContext.getPageRangesDiff({
22129
21575
  abortSignal: options.abortSignal,
22130
21576
  leaseAccessConditions: options.conditions,
@@ -22134,17 +21580,7 @@ class PageBlobClient extends BlobClient {
22134
21580
  tracingOptions: updatedOptions.tracingOptions,
22135
21581
  }));
22136
21582
  return rangeResponseFromModel(response);
22137
- }
22138
- catch (e) {
22139
- span.setStatus({
22140
- code: coreTracing.SpanStatusCode.ERROR,
22141
- message: e.message,
22142
- });
22143
- throw e;
22144
- }
22145
- finally {
22146
- span.end();
22147
- }
21583
+ });
22148
21584
  }
22149
21585
  /**
22150
21586
  * Resizes the page blob to the specified size (which must be a multiple of 512).
@@ -22155,10 +21591,9 @@ class PageBlobClient extends BlobClient {
22155
21591
  * @returns Response data for the Page Blob Resize operation.
22156
21592
  */
22157
21593
  async resize(size, options = {}) {
22158
- var _a;
22159
21594
  options.conditions = options.conditions || {};
22160
- const { span, updatedOptions } = createSpan("PageBlobClient-resize", options);
22161
- try {
21595
+ return tracingClient.withSpan("PageBlobClient-resize", options, async (updatedOptions) => {
21596
+ var _a;
22162
21597
  return assertResponse(await this.pageBlobContext.resize(size, {
22163
21598
  abortSignal: options.abortSignal,
22164
21599
  leaseAccessConditions: options.conditions,
@@ -22166,17 +21601,7 @@ class PageBlobClient extends BlobClient {
22166
21601
  encryptionScope: options.encryptionScope,
22167
21602
  tracingOptions: updatedOptions.tracingOptions,
22168
21603
  }));
22169
- }
22170
- catch (e) {
22171
- span.setStatus({
22172
- code: coreTracing.SpanStatusCode.ERROR,
22173
- message: e.message,
22174
- });
22175
- throw e;
22176
- }
22177
- finally {
22178
- span.end();
22179
- }
21604
+ });
22180
21605
  }
22181
21606
  /**
22182
21607
  * Sets a page blob's sequence number.
@@ -22188,10 +21613,9 @@ class PageBlobClient extends BlobClient {
22188
21613
  * @returns Response data for the Page Blob Update Sequence Number operation.
22189
21614
  */
22190
21615
  async updateSequenceNumber(sequenceNumberAction, sequenceNumber, options = {}) {
22191
- var _a;
22192
21616
  options.conditions = options.conditions || {};
22193
- const { span, updatedOptions } = createSpan("PageBlobClient-updateSequenceNumber", options);
22194
- try {
21617
+ return tracingClient.withSpan("PageBlobClient-updateSequenceNumber", options, async (updatedOptions) => {
21618
+ var _a;
22195
21619
  return assertResponse(await this.pageBlobContext.updateSequenceNumber(sequenceNumberAction, {
22196
21620
  abortSignal: options.abortSignal,
22197
21621
  blobSequenceNumber: sequenceNumber,
@@ -22199,17 +21623,7 @@ class PageBlobClient extends BlobClient {
22199
21623
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
22200
21624
  tracingOptions: updatedOptions.tracingOptions,
22201
21625
  }));
22202
- }
22203
- catch (e) {
22204
- span.setStatus({
22205
- code: coreTracing.SpanStatusCode.ERROR,
22206
- message: e.message,
22207
- });
22208
- throw e;
22209
- }
22210
- finally {
22211
- span.end();
22212
- }
21626
+ });
22213
21627
  }
22214
21628
  /**
22215
21629
  * Begins an operation to start an incremental copy from one page blob's snapshot to this page blob.
@@ -22225,25 +21639,14 @@ class PageBlobClient extends BlobClient {
22225
21639
  * @returns Response data for the Page Blob Copy Incremental operation.
22226
21640
  */
22227
21641
  async startCopyIncremental(copySource, options = {}) {
22228
- var _a;
22229
- const { span, updatedOptions } = createSpan("PageBlobClient-startCopyIncremental", options);
22230
- try {
21642
+ return tracingClient.withSpan("PageBlobClient-startCopyIncremental", options, async (updatedOptions) => {
21643
+ var _a;
22231
21644
  return assertResponse(await this.pageBlobContext.copyIncremental(copySource, {
22232
21645
  abortSignal: options.abortSignal,
22233
21646
  modifiedAccessConditions: Object.assign(Object.assign({}, options.conditions), { ifTags: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.tagConditions }),
22234
21647
  tracingOptions: updatedOptions.tracingOptions,
22235
21648
  }));
22236
- }
22237
- catch (e) {
22238
- span.setStatus({
22239
- code: coreTracing.SpanStatusCode.ERROR,
22240
- message: e.message,
22241
- });
22242
- throw e;
22243
- }
22244
- finally {
22245
- span.end();
22246
- }
21649
+ });
22247
21650
  }
22248
21651
  }
22249
21652
 
@@ -22527,8 +21930,7 @@ class BlobBatch {
22527
21930
  if (!options) {
22528
21931
  options = {};
22529
21932
  }
22530
- const { span, updatedOptions } = createSpan("BatchDeleteRequest-addSubRequest", options);
22531
- try {
21933
+ tracingClient.withSpan("BatchDeleteRequest-addSubRequest", options, async (updatedOptions) => {
22532
21934
  this.setBatchType("delete");
22533
21935
  await this.addSubRequestInternal({
22534
21936
  url: url,
@@ -22536,17 +21938,7 @@ class BlobBatch {
22536
21938
  }, async () => {
22537
21939
  await new BlobClient(url, this.batchRequest.createPipeline(credential)).delete(updatedOptions);
22538
21940
  });
22539
- }
22540
- catch (e) {
22541
- span.setStatus({
22542
- code: coreTracing.SpanStatusCode.ERROR,
22543
- message: e.message,
22544
- });
22545
- throw e;
22546
- }
22547
- finally {
22548
- span.end();
22549
- }
21941
+ });
22550
21942
  }
22551
21943
  async setBlobAccessTier(urlOrBlobClient, credentialOrTier, tierOrOptions, options) {
22552
21944
  let url;
@@ -22574,8 +21966,7 @@ class BlobBatch {
22574
21966
  if (!options) {
22575
21967
  options = {};
22576
21968
  }
22577
- const { span, updatedOptions } = createSpan("BatchSetTierRequest-addSubRequest", options);
22578
- try {
21969
+ return tracingClient.withSpan("BatchSetTierRequest-addSubRequest", options, async (updatedOptions) => {
22579
21970
  this.setBatchType("setAccessTier");
22580
21971
  await this.addSubRequestInternal({
22581
21972
  url: url,
@@ -22583,17 +21974,7 @@ class BlobBatch {
22583
21974
  }, async () => {
22584
21975
  await new BlobClient(url, this.batchRequest.createPipeline(credential)).setAccessTier(tier, updatedOptions);
22585
21976
  });
22586
- }
22587
- catch (e) {
22588
- span.setStatus({
22589
- code: coreTracing.SpanStatusCode.ERROR,
22590
- message: e.message,
22591
- });
22592
- throw e;
22593
- }
22594
- finally {
22595
- span.end();
22596
- }
21977
+ });
22597
21978
  }
22598
21979
  }
22599
21980
  /**
@@ -22837,8 +22218,7 @@ class BlobBatchClient {
22837
22218
  if (!batchRequest || batchRequest.getSubRequests().size === 0) {
22838
22219
  throw new RangeError("Batch request should contain one or more sub requests.");
22839
22220
  }
22840
- const { span, updatedOptions } = createSpan("BlobBatchClient-submitBatch", options);
22841
- try {
22221
+ return tracingClient.withSpan("BlobBatchClient-submitBatch", options, async (updatedOptions) => {
22842
22222
  const batchRequestBody = batchRequest.getHttpRequestBody();
22843
22223
  // ServiceSubmitBatchResponseModel and ContainerSubmitBatchResponse are compatible for now.
22844
22224
  const rawBatchResponse = assertResponse(await this.serviceOrContainerContext.submitBatch(utf8ByteLength(batchRequestBody), batchRequest.getMultiPartContentType(), batchRequestBody, Object.assign({}, updatedOptions)));
@@ -22857,17 +22237,7 @@ class BlobBatchClient {
22857
22237
  subResponsesFailedCount: responseSummary.subResponsesFailedCount,
22858
22238
  };
22859
22239
  return res;
22860
- }
22861
- catch (e) {
22862
- span.setStatus({
22863
- code: coreTracing.SpanStatusCode.ERROR,
22864
- message: e.message,
22865
- });
22866
- throw e;
22867
- }
22868
- finally {
22869
- span.end();
22870
- }
22240
+ });
22871
22241
  }
22872
22242
  }
22873
22243
 
@@ -22961,22 +22331,9 @@ class ContainerClient extends StorageClient {
22961
22331
  * ```
22962
22332
  */
22963
22333
  async create(options = {}) {
22964
- const { span, updatedOptions } = createSpan("ContainerClient-create", options);
22965
- try {
22966
- // Spread operator in destructuring assignments,
22967
- // this will filter out unwanted properties from the response object into result object
22968
- return assertResponse(await this.containerContext.create(Object.assign({}, updatedOptions)));
22969
- }
22970
- catch (e) {
22971
- span.setStatus({
22972
- code: coreTracing.SpanStatusCode.ERROR,
22973
- message: e.message,
22974
- });
22975
- throw e;
22976
- }
22977
- finally {
22978
- span.end();
22979
- }
22334
+ return tracingClient.withSpan("ContainerClient-create", options, async (updatedOptions) => {
22335
+ return assertResponse(await this.containerContext.create(updatedOptions));
22336
+ });
22980
22337
  }
22981
22338
  /**
22982
22339
  * Creates a new container under the specified account. If the container with
@@ -22987,29 +22344,21 @@ class ContainerClient extends StorageClient {
22987
22344
  * @param options -
22988
22345
  */
22989
22346
  async createIfNotExists(options = {}) {
22990
- var _a, _b;
22991
- const { span, updatedOptions } = createSpan("ContainerClient-createIfNotExists", options);
22992
- try {
22993
- const res = assertResponse(await this.create(updatedOptions));
22994
- return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
22995
- }
22996
- catch (e) {
22997
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "ContainerAlreadyExists") {
22998
- span.setStatus({
22999
- code: coreTracing.SpanStatusCode.ERROR,
23000
- message: "Expected exception when creating a container only if it does not already exist.",
23001
- });
23002
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
22347
+ return tracingClient.withSpan("ContainerClient-createIfNotExists", options, async (updatedOptions) => {
22348
+ var _a, _b;
22349
+ try {
22350
+ const res = await this.create(updatedOptions);
22351
+ return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
23003
22352
  }
23004
- span.setStatus({
23005
- code: coreTracing.SpanStatusCode.ERROR,
23006
- message: e.message,
23007
- });
23008
- throw e;
23009
- }
23010
- finally {
23011
- span.end();
23012
- }
22353
+ catch (e) {
22354
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "ContainerAlreadyExists") {
22355
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
22356
+ }
22357
+ else {
22358
+ throw e;
22359
+ }
22360
+ }
22361
+ });
23013
22362
  }
23014
22363
  /**
23015
22364
  * Returns true if the Azure container resource represented by this client exists; false otherwise.
@@ -23021,31 +22370,21 @@ class ContainerClient extends StorageClient {
23021
22370
  * @param options -
23022
22371
  */
23023
22372
  async exists(options = {}) {
23024
- const { span, updatedOptions } = createSpan("ContainerClient-exists", options);
23025
- try {
23026
- await this.getProperties({
23027
- abortSignal: options.abortSignal,
23028
- tracingOptions: updatedOptions.tracingOptions,
23029
- });
23030
- return true;
23031
- }
23032
- catch (e) {
23033
- if (e.statusCode === 404) {
23034
- span.setStatus({
23035
- code: coreTracing.SpanStatusCode.ERROR,
23036
- message: "Expected exception when checking container existence",
22373
+ return tracingClient.withSpan("ContainerClient-exists", options, async (updatedOptions) => {
22374
+ try {
22375
+ await this.getProperties({
22376
+ abortSignal: options.abortSignal,
22377
+ tracingOptions: updatedOptions.tracingOptions,
23037
22378
  });
23038
- return false;
22379
+ return true;
23039
22380
  }
23040
- span.setStatus({
23041
- code: coreTracing.SpanStatusCode.ERROR,
23042
- message: e.message,
23043
- });
23044
- throw e;
23045
- }
23046
- finally {
23047
- span.end();
23048
- }
22381
+ catch (e) {
22382
+ if (e.statusCode === 404) {
22383
+ return false;
22384
+ }
22385
+ throw e;
22386
+ }
22387
+ });
23049
22388
  }
23050
22389
  /**
23051
22390
  * Creates a {@link BlobClient}
@@ -23106,20 +22445,9 @@ class ContainerClient extends StorageClient {
23106
22445
  if (!options.conditions) {
23107
22446
  options.conditions = {};
23108
22447
  }
23109
- const { span, updatedOptions } = createSpan("ContainerClient-getProperties", options);
23110
- try {
22448
+ return tracingClient.withSpan("ContainerClient-getProperties", options, async (updatedOptions) => {
23111
22449
  return assertResponse(await this.containerContext.getProperties(Object.assign(Object.assign({ abortSignal: options.abortSignal }, options.conditions), { tracingOptions: updatedOptions.tracingOptions })));
23112
- }
23113
- catch (e) {
23114
- span.setStatus({
23115
- code: coreTracing.SpanStatusCode.ERROR,
23116
- message: e.message,
23117
- });
23118
- throw e;
23119
- }
23120
- finally {
23121
- span.end();
23122
- }
22450
+ });
23123
22451
  }
23124
22452
  /**
23125
22453
  * Marks the specified container for deletion. The container and any blobs
@@ -23132,25 +22460,14 @@ class ContainerClient extends StorageClient {
23132
22460
  if (!options.conditions) {
23133
22461
  options.conditions = {};
23134
22462
  }
23135
- const { span, updatedOptions } = createSpan("ContainerClient-delete", options);
23136
- try {
22463
+ return tracingClient.withSpan("ContainerClient-delete", options, async (updatedOptions) => {
23137
22464
  return assertResponse(await this.containerContext.delete({
23138
22465
  abortSignal: options.abortSignal,
23139
22466
  leaseAccessConditions: options.conditions,
23140
22467
  modifiedAccessConditions: options.conditions,
23141
22468
  tracingOptions: updatedOptions.tracingOptions,
23142
22469
  }));
23143
- }
23144
- catch (e) {
23145
- span.setStatus({
23146
- code: coreTracing.SpanStatusCode.ERROR,
23147
- message: e.message,
23148
- });
23149
- throw e;
23150
- }
23151
- finally {
23152
- span.end();
23153
- }
22470
+ });
23154
22471
  }
23155
22472
  /**
23156
22473
  * Marks the specified container for deletion if it exists. The container and any blobs
@@ -23160,29 +22477,19 @@ class ContainerClient extends StorageClient {
23160
22477
  * @param options - Options to Container Delete operation.
23161
22478
  */
23162
22479
  async deleteIfExists(options = {}) {
23163
- var _a, _b;
23164
- const { span, updatedOptions } = createSpan("ContainerClient-deleteIfExists", options);
23165
- try {
23166
- const res = await this.delete(updatedOptions);
23167
- return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
23168
- }
23169
- catch (e) {
23170
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "ContainerNotFound") {
23171
- span.setStatus({
23172
- code: coreTracing.SpanStatusCode.ERROR,
23173
- message: "Expected exception when deleting a container only if it exists.",
23174
- });
23175
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
22480
+ return tracingClient.withSpan("ContainerClient-deleteIfExists", options, async (updatedOptions) => {
22481
+ var _a, _b;
22482
+ try {
22483
+ const res = await this.delete(updatedOptions);
22484
+ return Object.assign(Object.assign({ succeeded: true }, res), { _response: res._response });
23176
22485
  }
23177
- span.setStatus({
23178
- code: coreTracing.SpanStatusCode.ERROR,
23179
- message: e.message,
23180
- });
23181
- throw e;
23182
- }
23183
- finally {
23184
- span.end();
23185
- }
22486
+ catch (e) {
22487
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "ContainerNotFound") {
22488
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
22489
+ }
22490
+ throw e;
22491
+ }
22492
+ });
23186
22493
  }
23187
22494
  /**
23188
22495
  * Sets one or more user-defined name-value pairs for the specified container.
@@ -23203,8 +22510,7 @@ class ContainerClient extends StorageClient {
23203
22510
  if (options.conditions.ifUnmodifiedSince) {
23204
22511
  throw new RangeError("the IfUnmodifiedSince must have their default values because they are ignored by the blob service");
23205
22512
  }
23206
- const { span, updatedOptions } = createSpan("ContainerClient-setMetadata", options);
23207
- try {
22513
+ return tracingClient.withSpan("ContainerClient-setMetadata", options, async (updatedOptions) => {
23208
22514
  return assertResponse(await this.containerContext.setMetadata({
23209
22515
  abortSignal: options.abortSignal,
23210
22516
  leaseAccessConditions: options.conditions,
@@ -23212,17 +22518,7 @@ class ContainerClient extends StorageClient {
23212
22518
  modifiedAccessConditions: options.conditions,
23213
22519
  tracingOptions: updatedOptions.tracingOptions,
23214
22520
  }));
23215
- }
23216
- catch (e) {
23217
- span.setStatus({
23218
- code: coreTracing.SpanStatusCode.ERROR,
23219
- message: e.message,
23220
- });
23221
- throw e;
23222
- }
23223
- finally {
23224
- span.end();
23225
- }
22521
+ });
23226
22522
  }
23227
22523
  /**
23228
22524
  * Gets the permissions for the specified container. The permissions indicate
@@ -23239,8 +22535,7 @@ class ContainerClient extends StorageClient {
23239
22535
  if (!options.conditions) {
23240
22536
  options.conditions = {};
23241
22537
  }
23242
- const { span, updatedOptions } = createSpan("ContainerClient-getAccessPolicy", options);
23243
- try {
22538
+ return tracingClient.withSpan("ContainerClient-getAccessPolicy", options, async (updatedOptions) => {
23244
22539
  const response = assertResponse(await this.containerContext.getAccessPolicy({
23245
22540
  abortSignal: options.abortSignal,
23246
22541
  leaseAccessConditions: options.conditions,
@@ -23277,17 +22572,7 @@ class ContainerClient extends StorageClient {
23277
22572
  });
23278
22573
  }
23279
22574
  return res;
23280
- }
23281
- catch (e) {
23282
- span.setStatus({
23283
- code: coreTracing.SpanStatusCode.ERROR,
23284
- message: e.message,
23285
- });
23286
- throw e;
23287
- }
23288
- finally {
23289
- span.end();
23290
- }
22575
+ });
23291
22576
  }
23292
22577
  /**
23293
22578
  * Sets the permissions for the specified container. The permissions indicate
@@ -23308,8 +22593,7 @@ class ContainerClient extends StorageClient {
23308
22593
  */
23309
22594
  async setAccessPolicy(access, containerAcl, options = {}) {
23310
22595
  options.conditions = options.conditions || {};
23311
- const { span, updatedOptions } = createSpan("ContainerClient-setAccessPolicy", options);
23312
- try {
22596
+ return tracingClient.withSpan("ContainerClient-setAccessPolicy", options, async (updatedOptions) => {
23313
22597
  const acl = [];
23314
22598
  for (const identifier of containerAcl || []) {
23315
22599
  acl.push({
@@ -23333,17 +22617,7 @@ class ContainerClient extends StorageClient {
23333
22617
  modifiedAccessConditions: options.conditions,
23334
22618
  tracingOptions: updatedOptions.tracingOptions,
23335
22619
  }));
23336
- }
23337
- catch (e) {
23338
- span.setStatus({
23339
- code: coreTracing.SpanStatusCode.ERROR,
23340
- message: e.message,
23341
- });
23342
- throw e;
23343
- }
23344
- finally {
23345
- span.end();
23346
- }
22620
+ });
23347
22621
  }
23348
22622
  /**
23349
22623
  * Get a {@link BlobLeaseClient} that manages leases on the container.
@@ -23377,25 +22651,14 @@ class ContainerClient extends StorageClient {
23377
22651
  * @returns Block Blob upload response data and the corresponding BlockBlobClient instance.
23378
22652
  */
23379
22653
  async uploadBlockBlob(blobName, body, contentLength, options = {}) {
23380
- const { span, updatedOptions } = createSpan("ContainerClient-uploadBlockBlob", options);
23381
- try {
22654
+ return tracingClient.withSpan("ContainerClient-uploadBlockBlob", options, async (updatedOptions) => {
23382
22655
  const blockBlobClient = this.getBlockBlobClient(blobName);
23383
22656
  const response = await blockBlobClient.upload(body, contentLength, updatedOptions);
23384
22657
  return {
23385
22658
  blockBlobClient,
23386
22659
  response,
23387
22660
  };
23388
- }
23389
- catch (e) {
23390
- span.setStatus({
23391
- code: coreTracing.SpanStatusCode.ERROR,
23392
- message: e.message,
23393
- });
23394
- throw e;
23395
- }
23396
- finally {
23397
- span.end();
23398
- }
22661
+ });
23399
22662
  }
23400
22663
  /**
23401
22664
  * Marks the specified blob or snapshot for deletion. The blob is later deleted
@@ -23409,24 +22672,13 @@ class ContainerClient extends StorageClient {
23409
22672
  * @returns Block blob deletion response data.
23410
22673
  */
23411
22674
  async deleteBlob(blobName, options = {}) {
23412
- const { span, updatedOptions } = createSpan("ContainerClient-deleteBlob", options);
23413
- try {
22675
+ return tracingClient.withSpan("ContainerClient-deleteBlob", options, async (updatedOptions) => {
23414
22676
  let blobClient = this.getBlobClient(blobName);
23415
22677
  if (options.versionId) {
23416
22678
  blobClient = blobClient.withVersion(options.versionId);
23417
22679
  }
23418
- return await blobClient.delete(updatedOptions);
23419
- }
23420
- catch (e) {
23421
- span.setStatus({
23422
- code: coreTracing.SpanStatusCode.ERROR,
23423
- message: e.message,
23424
- });
23425
- throw e;
23426
- }
23427
- finally {
23428
- span.end();
23429
- }
22680
+ return blobClient.delete(updatedOptions);
22681
+ });
23430
22682
  }
23431
22683
  /**
23432
22684
  * listBlobFlatSegment returns a single segment of blobs starting from the
@@ -23439,25 +22691,14 @@ class ContainerClient extends StorageClient {
23439
22691
  * @param options - Options to Container List Blob Flat Segment operation.
23440
22692
  */
23441
22693
  async listBlobFlatSegment(marker, options = {}) {
23442
- const { span, updatedOptions } = createSpan("ContainerClient-listBlobFlatSegment", options);
23443
- try {
22694
+ return tracingClient.withSpan("ContainerClient-listBlobFlatSegment", options, async (updatedOptions) => {
23444
22695
  const response = assertResponse(await this.containerContext.listBlobFlatSegment(Object.assign(Object.assign({ marker }, options), { tracingOptions: updatedOptions.tracingOptions })));
23445
22696
  const wrappedResponse = Object.assign(Object.assign({}, response), { _response: Object.assign(Object.assign({}, response._response), { parsedBody: ConvertInternalResponseOfListBlobFlat(response._response.parsedBody) }), segment: Object.assign(Object.assign({}, response.segment), { blobItems: response.segment.blobItems.map((blobItemInternal) => {
23446
22697
  const blobItem = Object.assign(Object.assign({}, blobItemInternal), { name: BlobNameToString(blobItemInternal.name), tags: toTags(blobItemInternal.blobTags), objectReplicationSourceProperties: parseObjectReplicationRecord(blobItemInternal.objectReplicationMetadata) });
23447
22698
  return blobItem;
23448
22699
  }) }) });
23449
22700
  return wrappedResponse;
23450
- }
23451
- catch (e) {
23452
- span.setStatus({
23453
- code: coreTracing.SpanStatusCode.ERROR,
23454
- message: e.message,
23455
- });
23456
- throw e;
23457
- }
23458
- finally {
23459
- span.end();
23460
- }
22701
+ });
23461
22702
  }
23462
22703
  /**
23463
22704
  * listBlobHierarchySegment returns a single segment of blobs starting from
@@ -23471,9 +22712,8 @@ class ContainerClient extends StorageClient {
23471
22712
  * @param options - Options to Container List Blob Hierarchy Segment operation.
23472
22713
  */
23473
22714
  async listBlobHierarchySegment(delimiter, marker, options = {}) {
23474
- var _a;
23475
- const { span, updatedOptions } = createSpan("ContainerClient-listBlobHierarchySegment", options);
23476
- try {
22715
+ return tracingClient.withSpan("ContainerClient-listBlobHierarchySegment", options, async (updatedOptions) => {
22716
+ var _a;
23477
22717
  const response = assertResponse(await this.containerContext.listBlobHierarchySegment(delimiter, Object.assign(Object.assign({ marker }, options), { tracingOptions: updatedOptions.tracingOptions })));
23478
22718
  const wrappedResponse = Object.assign(Object.assign({}, response), { _response: Object.assign(Object.assign({}, response._response), { parsedBody: ConvertInternalResponseOfListBlobHierarchy(response._response.parsedBody) }), segment: Object.assign(Object.assign({}, response.segment), { blobItems: response.segment.blobItems.map((blobItemInternal) => {
23479
22719
  const blobItem = Object.assign(Object.assign({}, blobItemInternal), { name: BlobNameToString(blobItemInternal.name), tags: toTags(blobItemInternal.blobTags), objectReplicationSourceProperties: parseObjectReplicationRecord(blobItemInternal.objectReplicationMetadata) });
@@ -23485,17 +22725,7 @@ class ContainerClient extends StorageClient {
23485
22725
  return blobPrefix;
23486
22726
  }) }) });
23487
22727
  return wrappedResponse;
23488
- }
23489
- catch (e) {
23490
- span.setStatus({
23491
- code: coreTracing.SpanStatusCode.ERROR,
23492
- message: e.message,
23493
- });
23494
- throw e;
23495
- }
23496
- finally {
23497
- span.end();
23498
- }
22728
+ });
23499
22729
  }
23500
22730
  /**
23501
22731
  * Returns an AsyncIterableIterator for ContainerListBlobFlatSegmentResponse
@@ -23890,8 +23120,7 @@ class ContainerClient extends StorageClient {
23890
23120
  * @param options - Options to find blobs by tags.
23891
23121
  */
23892
23122
  async findBlobsByTagsSegment(tagFilterSqlExpression, marker, options = {}) {
23893
- const { span, updatedOptions } = createSpan("ContainerClient-findBlobsByTagsSegment", options);
23894
- try {
23123
+ return tracingClient.withSpan("ContainerClient-findBlobsByTagsSegment", options, async (updatedOptions) => {
23895
23124
  const response = assertResponse(await this.containerContext.filterBlobs({
23896
23125
  abortSignal: options.abortSignal,
23897
23126
  where: tagFilterSqlExpression,
@@ -23908,17 +23137,7 @@ class ContainerClient extends StorageClient {
23908
23137
  return Object.assign(Object.assign({}, blob), { tags: toTags(blob.tags), tagValue });
23909
23138
  }) });
23910
23139
  return wrappedResponse;
23911
- }
23912
- catch (e) {
23913
- span.setStatus({
23914
- code: coreTracing.SpanStatusCode.ERROR,
23915
- message: e.message,
23916
- });
23917
- throw e;
23918
- }
23919
- finally {
23920
- span.end();
23921
- }
23140
+ });
23922
23141
  }
23923
23142
  /**
23924
23143
  * Returns an AsyncIterableIterator for ContainerFindBlobsByTagsSegmentResponse.
@@ -24699,25 +23918,14 @@ class BlobServiceClient extends StorageClient {
24699
23918
  * @returns Container creation response and the corresponding container client.
24700
23919
  */
24701
23920
  async createContainer(containerName, options = {}) {
24702
- const { span, updatedOptions } = createSpan("BlobServiceClient-createContainer", options);
24703
- try {
23921
+ return tracingClient.withSpan("BlobServiceClient-createContainer", options, async (updatedOptions) => {
24704
23922
  const containerClient = this.getContainerClient(containerName);
24705
23923
  const containerCreateResponse = await containerClient.create(updatedOptions);
24706
23924
  return {
24707
23925
  containerClient,
24708
23926
  containerCreateResponse,
24709
23927
  };
24710
- }
24711
- catch (e) {
24712
- span.setStatus({
24713
- code: coreTracing.SpanStatusCode.ERROR,
24714
- message: e.message,
24715
- });
24716
- throw e;
24717
- }
24718
- finally {
24719
- span.end();
24720
- }
23928
+ });
24721
23929
  }
24722
23930
  /**
24723
23931
  * Deletes a Blob container.
@@ -24727,21 +23935,10 @@ class BlobServiceClient extends StorageClient {
24727
23935
  * @returns Container deletion response.
24728
23936
  */
24729
23937
  async deleteContainer(containerName, options = {}) {
24730
- const { span, updatedOptions } = createSpan("BlobServiceClient-deleteContainer", options);
24731
- try {
23938
+ return tracingClient.withSpan("BlobServiceClient-deleteContainer", options, async (updatedOptions) => {
24732
23939
  const containerClient = this.getContainerClient(containerName);
24733
- return await containerClient.delete(updatedOptions);
24734
- }
24735
- catch (e) {
24736
- span.setStatus({
24737
- code: coreTracing.SpanStatusCode.ERROR,
24738
- message: e.message,
24739
- });
24740
- throw e;
24741
- }
24742
- finally {
24743
- span.end();
24744
- }
23940
+ return containerClient.delete(updatedOptions);
23941
+ });
24745
23942
  }
24746
23943
  /**
24747
23944
  * Restore a previously deleted Blob container.
@@ -24753,8 +23950,7 @@ class BlobServiceClient extends StorageClient {
24753
23950
  * @returns Container deletion response.
24754
23951
  */
24755
23952
  async undeleteContainer(deletedContainerName, deletedContainerVersion, options = {}) {
24756
- const { span, updatedOptions } = createSpan("BlobServiceClient-undeleteContainer", options);
24757
- try {
23953
+ return tracingClient.withSpan("BlobServiceClient-undeleteContainer", options, async (updatedOptions) => {
24758
23954
  const containerClient = this.getContainerClient(options.destinationContainerName || deletedContainerName);
24759
23955
  // Hack to access a protected member.
24760
23956
  const containerContext = containerClient["storageClientContext"].container;
@@ -24764,17 +23960,7 @@ class BlobServiceClient extends StorageClient {
24764
23960
  tracingOptions: updatedOptions.tracingOptions,
24765
23961
  }));
24766
23962
  return { containerClient, containerUndeleteResponse };
24767
- }
24768
- catch (e) {
24769
- span.setStatus({
24770
- code: coreTracing.SpanStatusCode.ERROR,
24771
- message: e.message,
24772
- });
24773
- throw e;
24774
- }
24775
- finally {
24776
- span.end();
24777
- }
23963
+ });
24778
23964
  }
24779
23965
  /**
24780
23966
  * Rename an existing Blob Container.
@@ -24786,25 +23972,14 @@ class BlobServiceClient extends StorageClient {
24786
23972
  /* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
24787
23973
  // @ts-ignore Need to hide this interface for now. Make it public and turn on the live tests for it when the service is ready.
24788
23974
  async renameContainer(sourceContainerName, destinationContainerName, options = {}) {
24789
- var _a;
24790
- const { span, updatedOptions } = createSpan("BlobServiceClient-renameContainer", options);
24791
- try {
23975
+ return tracingClient.withSpan("BlobServiceClient-renameContainer", options, async (updatedOptions) => {
23976
+ var _a;
24792
23977
  const containerClient = this.getContainerClient(destinationContainerName);
24793
23978
  // Hack to access a protected member.
24794
23979
  const containerContext = containerClient["storageClientContext"].container;
24795
23980
  const containerRenameResponse = assertResponse(await containerContext.rename(sourceContainerName, Object.assign(Object.assign({}, updatedOptions), { sourceLeaseId: (_a = options.sourceCondition) === null || _a === void 0 ? void 0 : _a.leaseId })));
24796
23981
  return { containerClient, containerRenameResponse };
24797
- }
24798
- catch (e) {
24799
- span.setStatus({
24800
- code: coreTracing.SpanStatusCode.ERROR,
24801
- message: e.message,
24802
- });
24803
- throw e;
24804
- }
24805
- finally {
24806
- span.end();
24807
- }
23982
+ });
24808
23983
  }
24809
23984
  /**
24810
23985
  * Gets the properties of a storage account’s Blob service, including properties
@@ -24815,23 +23990,12 @@ class BlobServiceClient extends StorageClient {
24815
23990
  * @returns Response data for the Service Get Properties operation.
24816
23991
  */
24817
23992
  async getProperties(options = {}) {
24818
- const { span, updatedOptions } = createSpan("BlobServiceClient-getProperties", options);
24819
- try {
23993
+ return tracingClient.withSpan("BlobServiceClient-getProperties", options, async (updatedOptions) => {
24820
23994
  return assertResponse(await this.serviceContext.getProperties({
24821
23995
  abortSignal: options.abortSignal,
24822
23996
  tracingOptions: updatedOptions.tracingOptions,
24823
23997
  }));
24824
- }
24825
- catch (e) {
24826
- span.setStatus({
24827
- code: coreTracing.SpanStatusCode.ERROR,
24828
- message: e.message,
24829
- });
24830
- throw e;
24831
- }
24832
- finally {
24833
- span.end();
24834
- }
23998
+ });
24835
23999
  }
24836
24000
  /**
24837
24001
  * Sets properties for a storage account’s Blob service endpoint, including properties
@@ -24843,23 +24007,12 @@ class BlobServiceClient extends StorageClient {
24843
24007
  * @returns Response data for the Service Set Properties operation.
24844
24008
  */
24845
24009
  async setProperties(properties, options = {}) {
24846
- const { span, updatedOptions } = createSpan("BlobServiceClient-setProperties", options);
24847
- try {
24010
+ return tracingClient.withSpan("BlobServiceClient-setProperties", options, async (updatedOptions) => {
24848
24011
  return assertResponse(await this.serviceContext.setProperties(properties, {
24849
24012
  abortSignal: options.abortSignal,
24850
24013
  tracingOptions: updatedOptions.tracingOptions,
24851
24014
  }));
24852
- }
24853
- catch (e) {
24854
- span.setStatus({
24855
- code: coreTracing.SpanStatusCode.ERROR,
24856
- message: e.message,
24857
- });
24858
- throw e;
24859
- }
24860
- finally {
24861
- span.end();
24862
- }
24015
+ });
24863
24016
  }
24864
24017
  /**
24865
24018
  * Retrieves statistics related to replication for the Blob service. It is only
@@ -24871,23 +24024,12 @@ class BlobServiceClient extends StorageClient {
24871
24024
  * @returns Response data for the Service Get Statistics operation.
24872
24025
  */
24873
24026
  async getStatistics(options = {}) {
24874
- const { span, updatedOptions } = createSpan("BlobServiceClient-getStatistics", options);
24875
- try {
24027
+ return tracingClient.withSpan("BlobServiceClient-getStatistics", options, async (updatedOptions) => {
24876
24028
  return assertResponse(await this.serviceContext.getStatistics({
24877
24029
  abortSignal: options.abortSignal,
24878
24030
  tracingOptions: updatedOptions.tracingOptions,
24879
24031
  }));
24880
- }
24881
- catch (e) {
24882
- span.setStatus({
24883
- code: coreTracing.SpanStatusCode.ERROR,
24884
- message: e.message,
24885
- });
24886
- throw e;
24887
- }
24888
- finally {
24889
- span.end();
24890
- }
24032
+ });
24891
24033
  }
24892
24034
  /**
24893
24035
  * The Get Account Information operation returns the sku name and account kind
@@ -24900,23 +24042,12 @@ class BlobServiceClient extends StorageClient {
24900
24042
  * @returns Response data for the Service Get Account Info operation.
24901
24043
  */
24902
24044
  async getAccountInfo(options = {}) {
24903
- const { span, updatedOptions } = createSpan("BlobServiceClient-getAccountInfo", options);
24904
- try {
24045
+ return tracingClient.withSpan("BlobServiceClient-getAccountInfo", options, async (updatedOptions) => {
24905
24046
  return assertResponse(await this.serviceContext.getAccountInfo({
24906
24047
  abortSignal: options.abortSignal,
24907
24048
  tracingOptions: updatedOptions.tracingOptions,
24908
24049
  }));
24909
- }
24910
- catch (e) {
24911
- span.setStatus({
24912
- code: coreTracing.SpanStatusCode.ERROR,
24913
- message: e.message,
24914
- });
24915
- throw e;
24916
- }
24917
- finally {
24918
- span.end();
24919
- }
24050
+ });
24920
24051
  }
24921
24052
  /**
24922
24053
  * Returns a list of the containers under the specified account.
@@ -24933,20 +24064,9 @@ class BlobServiceClient extends StorageClient {
24933
24064
  * @returns Response data for the Service List Container Segment operation.
24934
24065
  */
24935
24066
  async listContainersSegment(marker, options = {}) {
24936
- const { span, updatedOptions } = createSpan("BlobServiceClient-listContainersSegment", options);
24937
- try {
24067
+ return tracingClient.withSpan("BlobServiceClient-listContainersSegment", options, async (updatedOptions) => {
24938
24068
  return assertResponse(await this.serviceContext.listContainersSegment(Object.assign(Object.assign({ abortSignal: options.abortSignal, marker }, options), { include: typeof options.include === "string" ? [options.include] : options.include, tracingOptions: updatedOptions.tracingOptions })));
24939
- }
24940
- catch (e) {
24941
- span.setStatus({
24942
- code: coreTracing.SpanStatusCode.ERROR,
24943
- message: e.message,
24944
- });
24945
- throw e;
24946
- }
24947
- finally {
24948
- span.end();
24949
- }
24069
+ });
24950
24070
  }
24951
24071
  /**
24952
24072
  * The Filter Blobs operation enables callers to list blobs across all containers whose tags
@@ -24967,8 +24087,7 @@ class BlobServiceClient extends StorageClient {
24967
24087
  * @param options - Options to find blobs by tags.
24968
24088
  */
24969
24089
  async findBlobsByTagsSegment(tagFilterSqlExpression, marker, options = {}) {
24970
- const { span, updatedOptions } = createSpan("BlobServiceClient-findBlobsByTagsSegment", options);
24971
- try {
24090
+ return tracingClient.withSpan("BlobServiceClient-findBlobsByTagsSegment", options, async (updatedOptions) => {
24972
24091
  const response = assertResponse(await this.serviceContext.filterBlobs({
24973
24092
  abortSignal: options.abortSignal,
24974
24093
  where: tagFilterSqlExpression,
@@ -24985,17 +24104,7 @@ class BlobServiceClient extends StorageClient {
24985
24104
  return Object.assign(Object.assign({}, blob), { tags: toTags(blob.tags), tagValue });
24986
24105
  }) });
24987
24106
  return wrappedResponse;
24988
- }
24989
- catch (e) {
24990
- span.setStatus({
24991
- code: coreTracing.SpanStatusCode.ERROR,
24992
- message: e.message,
24993
- });
24994
- throw e;
24995
- }
24996
- finally {
24997
- span.end();
24998
- }
24107
+ });
24999
24108
  }
25000
24109
  /**
25001
24110
  * Returns an AsyncIterableIterator for ServiceFindBlobsByTagsSegmentResponse.
@@ -25332,8 +24441,7 @@ class BlobServiceClient extends StorageClient {
25332
24441
  * @param expiresOn - The end time for the user delegation SAS. Must be within 7 days of the current time
25333
24442
  */
25334
24443
  async getUserDelegationKey(startsOn, expiresOn, options = {}) {
25335
- const { span, updatedOptions } = createSpan("BlobServiceClient-getUserDelegationKey", options);
25336
- try {
24444
+ return tracingClient.withSpan("BlobServiceClient-getUserDelegationKey", options, async (updatedOptions) => {
25337
24445
  const response = assertResponse(await this.serviceContext.getUserDelegationKey({
25338
24446
  startsOn: truncatedISO8061Date(startsOn, false),
25339
24447
  expiresOn: truncatedISO8061Date(expiresOn, false),
@@ -25352,17 +24460,7 @@ class BlobServiceClient extends StorageClient {
25352
24460
  };
25353
24461
  const res = Object.assign({ _response: response._response, requestId: response.requestId, clientRequestId: response.clientRequestId, version: response.version, date: response.date, errorCode: response.errorCode }, userDelegationKey);
25354
24462
  return res;
25355
- }
25356
- catch (e) {
25357
- span.setStatus({
25358
- code: coreTracing.SpanStatusCode.ERROR,
25359
- message: e.message,
25360
- });
25361
- throw e;
25362
- }
25363
- finally {
25364
- span.end();
25365
- }
24463
+ });
25366
24464
  }
25367
24465
  /**
25368
24466
  * Creates a BlobBatchClient object to conduct batch operations.