BlobURL class

A BlobURL represents a URL to an Azure Storage blob; the blob may be a block blob, append blob, or page blob.

Extends

Constructors

BlobURL(string, Pipeline)

Creates an instance of BlobURL. This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

Inherited Properties

credential

Credential used for authentication and authorization.

url

Encoded URL string value.

Methods

abortCopyFromURL(Aborter, string, IBlobAbortCopyFromURLOptions)

Aborts a pending asynchronous Copy Blob operation, and leaves a destination blob with zero length and full metadata. Version 2012-02-12 and newer.

See https://docs.microsoft.com/en-us/rest/api/storageservices/abort-copy-blob

acquireLease(Aborter, string, number, IBlobAcquireLeaseOptions)

Establishes and manages a lock on a blob for write and delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. In versions prior to 2012-02-12, the lock duration is 60 seconds.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

breakLease(Aborter, number, IBlobBreakLeaseOptions)

To end the lease but ensure that another client cannot acquire a new lease until the current lease period has expired.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

changeLease(Aborter, string, string, IBlobChangeLeaseOptions)

To change the ID of an existing lease.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

createSnapshot(Aborter, IBlobCreateSnapshotOptions)

Creates a read-only snapshot of a blob.

See https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-blob

delete(Aborter, IBlobDeleteOptions)

Marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the Delete Blob operation.

See https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob

download(Aborter, number, number, IBlobDownloadOptions)

Reads or downloads a blob from the system, including its metadata and properties. You can also call Get Blob to read a snapshot.

  • In Node.js, data returns in a Readable stream readableStreamBody
  • In browsers, data returns in a promise blobBody

See https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob

fromContainerURL(ContainerURL, string)

Creates a BlobURL object from an ContainerURL object.

getProperties(Aborter, IBlobGetPropertiesOptions)

Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does not return the content of the blob.

See https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-properties

releaseLease(Aborter, string, IBlobReleaseLeaseOptions)

To free the lease if it is no longer needed so that another client may immediately acquire a lease against the blob.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

renewLease(Aborter, string, IBlobRenewLeaseOptions)

To renew an existing lease.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

setHTTPHeaders(Aborter, BlobHTTPHeaders, IBlobSetHTTPHeadersOptions)

Sets system properties on the blob.

If no value provided, or no value provided for the specificed blob HTTP headers, these blob HTTP headers without a value will be cleared.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-properties

setMetadata(Aborter, IMetadata, IBlobSetMetadataOptions)

Sets user-defined metadata for the specified blob as one or more name-value pairs.

If no option provided, or no metadata defined in the parameter, the blob metadata will be removed.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-metadata

setTier(Aborter, string, IBlobSetTierOptions)

Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier

startCopyFromURL(Aborter, string, IBlobStartCopyFromURLOptions)

Asynchronously copies a blob to a destination within the storage account. In version 2012-02-12 and later, the source for a Copy Blob operation can be a committed blob in any Azure storage account. Beginning with version 2015-02-21, the source for a Copy Blob operation can be an Azure file in any Azure storage account. Only storage accounts created on or after June 7th, 2012 allow the Copy Blob operation to copy from another storage account.

See https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob

syncCopyFromURL(Aborter, string, IBlobSyncCopyFromURLOptions)

The synchronous Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response until the copy is complete.

See https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob-from-url

undelete(Aborter)

Restores the contents and metadata of soft deleted blob and any associated soft deleted snapshots. Undelete Blob is supported only on version 2017-07-29 or later.

See https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob

withPipeline(Pipeline)

Creates a new BlobURL object identical to the source but with the specified request policy pipeline.

withSnapshot(string)

Creates a new BlobURL object identical to the source but with the specified snapshot timestamp. Provide "" will remove the snapshot and return a URL to the base blob.

Inherited Methods

newPipeline(Credential, INewPipelineOptions)

A static method used to create a new Pipeline object with Credential provided.

Constructor Details

BlobURL(string, Pipeline)

Creates an instance of BlobURL. This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. If a blob name includes ? or %, blob name must be encoded in the URL.

new BlobURL(url: string, pipeline: Pipeline)

Parameters

url

string

A URL string pointing to Azure Storage blob, such as "https://myaccount.blob.core.windows.net/mycontainer/blob". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net/mycontainer/blob?sasString". This method accepts an encoded URL or non-encoded URL pointing to a blob. Encoded URL string will NOT be escaped twice, only special characters in URL path will be escaped. However, if a blob name includes ? or %, blob name must be encoded in the URL. Such as a blob named "my?blob%", the URL should be "https://myaccount.blob.core.windows.net/mycontainer/my%3Fblob%25".

pipeline
Pipeline

Call StorageURL.newPipeline() to create a default pipeline, or provide a customized pipeline.

Inherited Property Details

credential

Credential used for authentication and authorization.

credential: Credential

Property Value

Inherited From StorageURL.credential

url

Encoded URL string value.

url: string

Property Value

string

Inherited From StorageURL.url

Method Details

abortCopyFromURL(Aborter, string, IBlobAbortCopyFromURLOptions)

Aborts a pending asynchronous Copy Blob operation, and leaves a destination blob with zero length and full metadata. Version 2012-02-12 and newer.

See https://docs.microsoft.com/en-us/rest/api/storageservices/abort-copy-blob

function abortCopyFromURL(aborter: Aborter, copyId: string, options?: IBlobAbortCopyFromURLOptions): Promise<BlobAbortCopyFromURLResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

copyId

string

Returns

acquireLease(Aborter, string, number, IBlobAcquireLeaseOptions)

Establishes and manages a lock on a blob for write and delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. In versions prior to 2012-02-12, the lock duration is 60 seconds.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

function acquireLease(aborter: Aborter, proposedLeaseId: string, duration: number, options?: IBlobAcquireLeaseOptions): Promise<BlobAcquireLeaseResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

proposedLeaseId

string

Can be specified in any valid GUID string format

duration

number

The lock duration can be 15 to 60 seconds, or can be infinite

Returns

breakLease(Aborter, number, IBlobBreakLeaseOptions)

To end the lease but ensure that another client cannot acquire a new lease until the current lease period has expired.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

function breakLease(aborter: Aborter, breakPeriod?: number, options?: IBlobBreakLeaseOptions): Promise<BlobBreakLeaseResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

breakPeriod

number

Returns

changeLease(Aborter, string, string, IBlobChangeLeaseOptions)

To change the ID of an existing lease.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

function changeLease(aborter: Aborter, leaseId: string, proposedLeaseId: string, options?: IBlobChangeLeaseOptions): Promise<BlobChangeLeaseResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

leaseId

string

proposedLeaseId

string

Returns

createSnapshot(Aborter, IBlobCreateSnapshotOptions)

Creates a read-only snapshot of a blob.

See https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-blob

function createSnapshot(aborter: Aborter, options?: IBlobCreateSnapshotOptions): Promise<BlobCreateSnapshotResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

Returns

delete(Aborter, IBlobDeleteOptions)

Marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the Delete Blob operation.

See https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob

function delete(aborter: Aborter, options?: IBlobDeleteOptions): Promise<BlobDeleteResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

Returns

download(Aborter, number, number, IBlobDownloadOptions)

Reads or downloads a blob from the system, including its metadata and properties. You can also call Get Blob to read a snapshot.

  • In Node.js, data returns in a Readable stream readableStreamBody
  • In browsers, data returns in a promise blobBody

See https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob

function download(aborter: Aborter, offset: number, count?: number, options?: IBlobDownloadOptions): Promise<BlobDownloadResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

offset

number

From which position of the blob to download, >= 0

count

number

How much data to be downloaded, > 0. Will download to the end when undefined

Returns

fromContainerURL(ContainerURL, string)

Creates a BlobURL object from an ContainerURL object.

static function fromContainerURL(containerURL: ContainerURL, blobName: string): BlobURL

Parameters

containerURL
ContainerURL

A ContainerURL object

blobName

string

A blob name

Returns

getProperties(Aborter, IBlobGetPropertiesOptions)

Returns all user-defined metadata, standard HTTP properties, and system properties for the blob. It does not return the content of the blob.

See https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-properties

function getProperties(aborter: Aborter, options?: IBlobGetPropertiesOptions): Promise<BlobGetPropertiesResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

Returns

releaseLease(Aborter, string, IBlobReleaseLeaseOptions)

To free the lease if it is no longer needed so that another client may immediately acquire a lease against the blob.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

function releaseLease(aborter: Aborter, leaseId: string, options?: IBlobReleaseLeaseOptions): Promise<BlobReleaseLeaseResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

leaseId

string

Returns

renewLease(Aborter, string, IBlobRenewLeaseOptions)

To renew an existing lease.

See https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob

function renewLease(aborter: Aborter, leaseId: string, options?: IBlobRenewLeaseOptions): Promise<BlobRenewLeaseResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

leaseId

string

Returns

setHTTPHeaders(Aborter, BlobHTTPHeaders, IBlobSetHTTPHeadersOptions)

Sets system properties on the blob.

If no value provided, or no value provided for the specificed blob HTTP headers, these blob HTTP headers without a value will be cleared.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-properties

function setHTTPHeaders(aborter: Aborter, blobHTTPHeaders?: BlobHTTPHeaders, options?: IBlobSetHTTPHeadersOptions): Promise<BlobSetHTTPHeadersResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

blobHTTPHeaders
BlobHTTPHeaders

If no value provided, or no value provided for the specificed blob HTTP headers, these blob HTTP headers without a value will be cleared.

Returns

setMetadata(Aborter, IMetadata, IBlobSetMetadataOptions)

Sets user-defined metadata for the specified blob as one or more name-value pairs.

If no option provided, or no metadata defined in the parameter, the blob metadata will be removed.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-metadata

function setMetadata(aborter: Aborter, metadata?: IMetadata, options?: IBlobSetMetadataOptions): Promise<BlobSetMetadataResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

metadata

IMetadata

Replace existing metadata with this value. If no value provided the existing metadata will be removed.

Returns

setTier(Aborter, string, IBlobSetTierOptions)

Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag.

See https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier

function setTier(aborter: Aborter, tier: string, options?: IBlobSetTierOptions): Promise<BlobSetTierResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

tier

string

Returns

startCopyFromURL(Aborter, string, IBlobStartCopyFromURLOptions)

Asynchronously copies a blob to a destination within the storage account. In version 2012-02-12 and later, the source for a Copy Blob operation can be a committed blob in any Azure storage account. Beginning with version 2015-02-21, the source for a Copy Blob operation can be an Azure file in any Azure storage account. Only storage accounts created on or after June 7th, 2012 allow the Copy Blob operation to copy from another storage account.

See https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob

function startCopyFromURL(aborter: Aborter, copySource: string, options?: IBlobStartCopyFromURLOptions): Promise<BlobStartCopyFromURLResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

copySource

string

Returns

syncCopyFromURL(Aborter, string, IBlobSyncCopyFromURLOptions)

The synchronous Copy From URL operation copies a blob or an internet resource to a new blob. It will not return a response until the copy is complete.

See https://docs.microsoft.com/en-us/rest/api/storageservices/copy-blob-from-url

function syncCopyFromURL(aborter: Aborter, copySource: string, options?: IBlobSyncCopyFromURLOptions): Promise<BlobCopyFromURLResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

copySource

string

The source URL to copy from, Shared Access Signature(SAS) maybe needed for authentication

Returns

undelete(Aborter)

Restores the contents and metadata of soft deleted blob and any associated soft deleted snapshots. Undelete Blob is supported only on version 2017-07-29 or later.

See https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob

function undelete(aborter: Aborter): Promise<BlobUndeleteResponse>

Parameters

aborter
Aborter

Create a new Aborter instance with Aborter.none or Aborter.timeout(), goto documents of Aborter for more examples about request cancellation

Returns

withPipeline(Pipeline)

Creates a new BlobURL object identical to the source but with the specified request policy pipeline.

function withPipeline(pipeline: Pipeline): BlobURL

Parameters

pipeline
Pipeline

Returns

withSnapshot(string)

Creates a new BlobURL object identical to the source but with the specified snapshot timestamp. Provide "" will remove the snapshot and return a URL to the base blob.

function withSnapshot(snapshot: string): BlobURL

Parameters

snapshot

string

Returns

A new BlobURL object identical to the source but with the specified snapshot timestamp

Inherited Method Details

newPipeline(Credential, INewPipelineOptions)

A static method used to create a new Pipeline object with Credential provided.

static function newPipeline(credential: Credential, pipelineOptions?: INewPipelineOptions): Pipeline

Parameters

credential
Credential

Such as AnonymousCredential, SharedKeyCredential or TokenCredential.

pipelineOptions
INewPipelineOptions

Optional. Options.

Returns

A new Pipeline object.

Inherited From StorageURL.newPipeline