@azure/storage-queue package

Classes

Aborter

An aborter instance implements AbortSignal interface, can abort HTTP requests.

  • Call Aborter.none to create a new Aborter instance without timeout.
  • Call Aborter.timeout() to create a new Aborter instance with timeout.

For an existing instance aborter:

  • Call aborter.withTimeout() to create and return a child Aborter instance with timeout.
  • Call aborter.withValue(key, value) to create and return a child Aborter instance with key/value pair.
  • Call aborter.abort() to abort current instance and all children instances.
  • Call aborter.getValue(key) to search and get value with corresponding key from current aborter to all parents.
AccountSASPermissions

ONLY AVAILABLE IN NODE.JS RUNTIME. This is a helper class to construct a string representing the permissions granted by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the values are set, this should be serialized with toString and set as the permissions field on an IAccountSASSignatureValues object. It is possible to construct the permissions string without this class, but the order of the permissions is particular and this class guarantees correctness.

AccountSASResourceTypes

ONLY AVAILABLE IN NODE.JS RUNTIME. This is a helper class to construct a string representing the resources accessible by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant access to that resource type. Once all the values are set, this should be serialized with toString and set as the resources field on an IAccountSASSignatureValues object. It is possible to construct the resources string without this class, but the order of the resources is particular and this class guarantees correctness.

AccountSASServices

ONLY AVAILABLE IN NODE.JS RUNTIME. This is a helper class to construct a string representing the services accessible by an AccountSAS. Setting a value to true means that any SAS which uses these permissions will grant access to that service. Once all the values are set, this should be serialized with toString and set as the services field on an IAccountSASSignatureValues object. It is possible to construct the services string without this class, but the order of the services is particular and this class guarantees correctness.

BrowserPolicyFactory

BrowserPolicyFactory is a factory class helping generating BrowserPolicy objects.

KeepAlivePolicyFactory

KeepAlivePolicyFactory is a factory class helping generating KeepAlivePolicy objects.

LoggingPolicyFactory

LoggingPolicyFactory is a factory class helping generating LoggingPolicy objects.

MessageIdURL

A MessageIdURL represents a URL to a specific Azure Storage Queue message allowing you to manipulate the message.

MessagesURL

A MessagesURL represents a URL to an Azure Storage Queue's messages allowing you to manipulate its messages.

Pipeline

A Pipeline class containing HTTP request policies. You can create a default Pipeline by calling StorageURL.newPipeline(). Or you can create a Pipeline with your own policies by the constructor of Pipeline. Refer to StorageURL.newPipeline() and provided policies as reference before implementing your customized Pipeline.

QueueSASPermissions

ONLY AVAILABLE IN NODE.JS RUNTIME. This is a helper class to construct a string representing the permissions granted by a ServiceSAS to a Queue. Setting a value to true means that any SAS which uses these permissions will grant permissions for that operation. Once all the values are set, this should be serialized with toString and set as the permissions field on a IQueueSASSignatureValues object. It is possible to construct the permissions string without this class, but the order of the permissions is particular and this class guarantees correctness.

QueueURL

A QueueURL represents a URL to the Azure Storage queue.

RetryPolicyFactory

RetryPolicyFactory is a factory class helping generating RetryPolicy objects.

SASQueryParameters

Represents the components that make up an Azure Storage SAS' query parameters. This type is not constructed directly by the user; it is only generated by the IAccountSASSignatureValues and IQueueSASSignatureValues types. Once generated, it can be encoded into a {@code String} and appended to a URL directly (though caution should be taken here in case there are existing query parameters, which might affect the appropriate means of appending these query parameters). NOTE: Instances of this class are immutable.

ServiceURL

A ServiceURL represents a URL to the Azure Storage Queue service allowing you to manipulate queues.

StorageURL

A ServiceURL represents a based URL class for ServiceURL, QueueURL and etc.

TelemetryPolicyFactory

TelemetryPolicyFactory is a factory class helping generating TelemetryPolicy objects.

UniqueRequestIDPolicyFactory

UniqueRequestIDPolicyFactory is a factory class helping generating UniqueRequestIDPolicy objects.

AnonymousCredential

AnonymousCredential provides a credentialPolicyCreator member used to create AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources or for use with Shared Access Signatures (SAS).

Credential

Credential is an abstract class for Azure Storage HTTP requests signing. This class will host an credentialPolicyCreator factory which generates CredentialPolicy.

SharedKeyCredential

ONLY AVAILABLE IN NODE.JS RUNTIME. SharedKeyCredential for account key authorization of Azure Storage service.

TokenCredential

TokenCredential is a Credential used to generate a TokenCredentialPolicy. Renew token by setting a new token string value to token property.

Example

const tokenCredential = new TokenCredential("token"); const pipeline = StorageURL.newPipeline(tokenCredential);

const serviceURL = new ServiceURL("https://mystorageaccount.queue.core.windows.net", pipeline);

// Set up a timer to refresh the token const timerID = setInterval(() => { // Update token by accessing to public tokenCredential.token tokenCredential.token = "updatedToken"; // WARNING: Timer must be manually stopped! It will forbid GC of tokenCredential if (shouldStop()) { clearInterval(timerID); } }, 60 * 60 * 1000); // Set an interval time before your token expired

MessageId

Class representing a MessageId.

Messages

Class representing a Messages.

Queue

Class representing a Queue.

Service

Class representing a Service.

StorageClient
StorageClientContext
AnonymousCredentialPolicy

AnonymousCredentialPolicy is used with HTTP(S) requests that read public resources or for use with Shared Access Signatures (SAS).

BrowserPolicy

BrowserPolicy will handle differences between Node.js and browser runtime, including:

  1. Browsers cache GET/HEAD requests by adding conditional headers such as 'IF_MODIFIED_SINCE'. BrowserPolicy is a policy used to add a timestamp query to GET/HEAD request URL thus avoid the browser cache.

  2. Remove cookie header for security

  3. Remove content-length header to avoid browsers warning

CredentialPolicy

Credential policy used to sign HTTP(S) requests before sending. This is an abstract class.

KeepAlivePolicy

KeepAlivePolicy is a policy used to control keep alive settings for every request.

LoggingPolicy

LoggingPolicy is a policy used to log requests.

RetryPolicy

Retry policy with exponential retry and linear retry implemented.

SharedKeyCredentialPolicy

SharedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key.

TelemetryPolicy

TelemetryPolicy is a policy used to tag user-agent header for every requests.

TokenCredentialPolicy

TokenCredentialPolicy is a policy used to sign HTTP request with a token. Such as an OAuth bearer token.

UniqueRequestIDPolicy

UniqueRequestIDPolicy generates an UUID as x-ms-request-id header value.

Interfaces

IAccountSASSignatureValues

ONLY AVAILABLE IN NODE.JS RUNTIME. IAccountSASSignatureValues is used to generate a Shared Access Signature (SAS) for an Azure Storage account. Once all the values here are set appropriately, call generateSASQueryParameters() to obtain a representation of the SAS which can actually be applied to queue urls. Note: that both this class and SASQueryParameters exist because the former is mutable and a logical representation while the latter is immutable and used to generate actual REST requests.

See https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 for more conceptual information on SAS

See https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas for descriptions of the parameters, including which are required

IIPRange

Allowed IP range for a SAS.

IQueueSASSignatureValues

ONLY AVAILABLE IN NODE.JS RUNTIME. IQueueSASSignatureValues is used to help generating Queue service SAS tokens for queues.

IKeepAliveOptions

Interface of KeepAlivePolicy options.

IRequestLogOptions

RequestLogOptions configures the retry policy's behavior.

IPipelineOptions

Option interface for Pipeline constructor.

IQueueCreateOptions
ISignedIdentifier
IRetryOptions

Retry options interface.

IServiceListQueuesSegmentOptions
INewPipelineOptions

Option interface for Pipeline.newPipeline method.

ITelemetryOptions

Interface of TelemetryPolicy options.

AccessPolicy

An Access policy

CorsRule

CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs in another domain

DequeuedMessageItem

The object returned in the QueueMessageList array when calling Get Messages on a Queue.

EnqueuedMessage

The object returned in the QueueMessageList array when calling Put Message on a Queue

GeoReplication

An interface representing GeoReplication.

ListQueuesSegmentResponse

The object returned when calling List Queues on a Queue Service.

Logging

Azure Analytics Logging settings.

MessageIdDeleteHeaders

Defines headers for Delete operation.

MessageIdDeleteMethodOptionalParams

Optional Parameters.

MessageIdUpdateHeaders

Defines headers for Update operation.

MessageIdUpdateOptionalParams

Optional Parameters.

MessagesClearHeaders

Defines headers for Clear operation.

MessagesClearOptionalParams

Optional Parameters.

MessagesDequeueHeaders

Defines headers for Dequeue operation.

MessagesDequeueOptionalParams

Optional Parameters.

MessagesEnqueueHeaders

Defines headers for Enqueue operation.

MessagesEnqueueOptionalParams

Optional Parameters.

MessagesPeekHeaders

Defines headers for Peek operation.

MessagesPeekOptionalParams

Optional Parameters.

Metrics

An interface representing Metrics.

PeekedMessageItem

The object returned in the QueueMessageList array when calling Peek Messages on a Queue

QueueCreateHeaders

Defines headers for Create operation.

QueueCreateOptionalParams

Optional Parameters.

QueueDeleteHeaders

Defines headers for Delete operation.

QueueDeleteMethodOptionalParams

Optional Parameters.

QueueGetAccessPolicyHeaders

Defines headers for GetAccessPolicy operation.

QueueGetAccessPolicyOptionalParams

Optional Parameters.

QueueGetPropertiesHeaders

Defines headers for GetProperties operation.

QueueGetPropertiesOptionalParams

Optional Parameters.

QueueItem

An Azure Storage Queue.

QueueMessage

A Message object which can be stored in a Queue

QueueSetAccessPolicyHeaders

Defines headers for SetAccessPolicy operation.

QueueSetAccessPolicyOptionalParams

Optional Parameters.

QueueSetMetadataHeaders

Defines headers for SetMetadata operation.

QueueSetMetadataOptionalParams

Optional Parameters.

RetentionPolicy

the retention policy

ServiceGetPropertiesHeaders

Defines headers for GetProperties operation.

ServiceGetPropertiesOptionalParams

Optional Parameters.

ServiceGetStatisticsHeaders

Defines headers for GetStatistics operation.

ServiceGetStatisticsOptionalParams

Optional Parameters.

ServiceListQueuesSegmentHeaders

Defines headers for ListQueuesSegment operation.

ServiceListQueuesSegmentOptionalParams

Optional Parameters.

ServiceSetPropertiesHeaders

Defines headers for SetProperties operation.

ServiceSetPropertiesOptionalParams

Optional Parameters.

SignedIdentifier

signed identifier

StorageError

An interface representing StorageError.

StorageServiceProperties

Storage Service Properties.

StorageServiceStats

Stats for the storage service.

IMetadata

Type Aliases

MessagesDequeueResponse

Contains response data for the dequeue operation.

MessagesEnqueueResponse

Contains response data for the enqueue operation.

MessagesPeekResponse

Contains response data for the peek operation.

QueueGetAccessPolicyResponse

Contains response data for the getAccessPolicy operation.

CredentialPolicyCreator

A factory function that creates a new CredentialPolicy that uses the provided nextPolicy.

GeoReplicationStatusType

Defines values for GeoReplicationStatusType. Possible values include: 'live', 'bootstrap', 'unavailable'

ListQueuesIncludeType

Defines values for ListQueuesIncludeType. Possible values include: 'metadata'

MessageIdDeleteResponse

Contains response data for the deleteMethod operation.

MessageIdUpdateResponse

Contains response data for the update operation.

MessagesClearResponse

Contains response data for the clear operation.

QueueCreateResponse

Contains response data for the create operation.

QueueDeleteResponse

Contains response data for the deleteMethod operation.

QueueGetPropertiesResponse

Contains response data for the getProperties operation.

QueueSetAccessPolicyResponse

Contains response data for the setAccessPolicy operation.

QueueSetMetadataResponse

Contains response data for the setMetadata operation.

ServiceGetPropertiesResponse

Contains response data for the getProperties operation.

ServiceGetStatisticsResponse

Contains response data for the getStatistics operation.

ServiceListQueuesSegmentResponse

Contains response data for the listQueuesSegment operation.

ServiceSetPropertiesResponse

Contains response data for the setProperties operation.

StorageErrorCode

Defines values for StorageErrorCode. Possible values include: 'AccountAlreadyExists', 'AccountBeingCreated', 'AccountIsDisabled', 'AuthenticationFailed', 'AuthorizationFailure', 'ConditionHeadersNotSupported', 'ConditionNotMet', 'EmptyMetadataKey', 'InsufficientAccountPermissions', 'InternalError', 'InvalidAuthenticationInfo', 'InvalidHeaderValue', 'InvalidHttpVerb', 'InvalidInput', 'InvalidMd5', 'InvalidMetadata', 'InvalidQueryParameterValue', 'InvalidRange', 'InvalidResourceName', 'InvalidUri', 'InvalidXmlDocument', 'InvalidXmlNodeValue', 'Md5Mismatch', 'MetadataTooLarge', 'MissingContentLengthHeader', 'MissingRequiredQueryParameter', 'MissingRequiredHeader', 'MissingRequiredXmlNode', 'MultipleConditionHeadersNotSupported', 'OperationTimedOut', 'OutOfRangeInput', 'OutOfRangeQueryParameterValue', 'RequestBodyTooLarge', 'ResourceTypeMismatch', 'RequestUrlFailedToParse', 'ResourceAlreadyExists', 'ResourceNotFound', 'ServerBusy', 'UnsupportedHeader', 'UnsupportedXmlNode', 'UnsupportedQueryParameter', 'UnsupportedHttpVerb', 'InvalidMarker', 'MessageNotFound', 'MessageTooLarge', 'PopReceiptMismatch', 'QueueAlreadyExists', 'QueueBeingDeleted', 'QueueDisabled', 'QueueNotEmpty', 'QueueNotFound'

Enums

SASProtocol

Protocols for generated SAS.

RetryPolicyType

RetryPolicy types.

Functions

generateAccountSASQueryParameters(IAccountSASSignatureValues, SharedKeyCredential)

ONLY AVAILABLE IN NODE.JS RUNTIME. Generates a SASQueryParameters object which contains all SAS query parameters needed to make an actual REST request.

See https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas

ipRangeToString(IIPRange)

Generate IPRange format string. For example: "8.8.8.8" or "1.1.1.1-255.255.255.255"

generateQueueSASQueryParameters(IQueueSASSignatureValues, SharedKeyCredential)

ONLY AVAILABLE IN NODE.JS RUNTIME. Creates an instance of SASQueryParameters.

Only accepts required settings needed to create a SAS. For optional settings please set corresponding properties directly, such as permissions, startTime and identifier.

WARNING: When identifier is not provided, permissions and expiryTime are required. You MUST assign value to identifier or expiryTime & permissions manually if you initial with this constructor.

NewRetryPolicyFactory(IRetryOptions)

A factory method used to generated a RetryPolicy factory.

appendToURLPath(string, string)

Append a string to URL path. Will remove duplicated "/" in front of the string when URL path ends with a "/".

delay(number, AbortSignalLike, Error)

Delay specified time interval.

getURLParameter(string, string)

Get URL parameter by name.

getURLPath(string)

Get URL path from an URL string.

getURLQueries(string)

Get URL query key value pairs from an URL string.

padStart(string, number, undefined | string)

String.prototype.padStart()

setURLHost(string, string)

Set URL host.

setURLParameter(string, string, undefined | string)

Set URL parameter name and value. If name exists in URL parameters, old value will be replaced by name key. If not provide value, the parameter will be deleted.

truncatedISO8061Date(Date, undefined | false | true)

Rounds a date off to seconds.

Function Details

generateAccountSASQueryParameters(IAccountSASSignatureValues, SharedKeyCredential)

ONLY AVAILABLE IN NODE.JS RUNTIME. Generates a SASQueryParameters object which contains all SAS query parameters needed to make an actual REST request.

See https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas

function generateAccountSASQueryParameters(accountSASSignatureValues: IAccountSASSignatureValues, sharedKeyCredential: SharedKeyCredential): SASQueryParameters

Parameters

accountSASSignatureValues
IAccountSASSignatureValues
sharedKeyCredential
SharedKeyCredential

Returns

ipRangeToString(IIPRange)

Generate IPRange format string. For example: "8.8.8.8" or "1.1.1.1-255.255.255.255"

function ipRangeToString(ipRange: IIPRange): string

Parameters

ipRange
IIPRange

Returns

string

generateQueueSASQueryParameters(IQueueSASSignatureValues, SharedKeyCredential)

ONLY AVAILABLE IN NODE.JS RUNTIME. Creates an instance of SASQueryParameters.

Only accepts required settings needed to create a SAS. For optional settings please set corresponding properties directly, such as permissions, startTime and identifier.

WARNING: When identifier is not provided, permissions and expiryTime are required. You MUST assign value to identifier or expiryTime & permissions manually if you initial with this constructor.

function generateQueueSASQueryParameters(queueSASSignatureValues: IQueueSASSignatureValues, sharedKeyCredential: SharedKeyCredential): SASQueryParameters

Parameters

queueSASSignatureValues
IQueueSASSignatureValues
sharedKeyCredential
SharedKeyCredential

Returns

NewRetryPolicyFactory(IRetryOptions)

A factory method used to generated a RetryPolicy factory.

function NewRetryPolicyFactory(retryOptions?: IRetryOptions): RequestPolicyFactory

Parameters

retryOptions
IRetryOptions

Returns

RequestPolicyFactory

appendToURLPath(string, string)

Append a string to URL path. Will remove duplicated "/" in front of the string when URL path ends with a "/".

function appendToURLPath(url: string, name: string): string

Parameters

url

string

Source URL string

name

string

String to be appended to URL

Returns

string

An updated URL string

delay(number, AbortSignalLike, Error)

Delay specified time interval.

function delay(timeInMs: number, aborter?: AbortSignalLike, abortError?: Error): Promise<unknown>

Parameters

timeInMs

number

aborter

AbortSignalLike

abortError

Error

Returns

Promise<unknown>

getURLParameter(string, string)

Get URL parameter by name.

function getURLParameter(url: string, name: string): string | string[] | undefined

Parameters

url

string

name

string

Returns

string | string[] | undefined

getURLPath(string)

Get URL path from an URL string.

function getURLPath(url: string): string | undefined

Parameters

url

string

Source URL string

Returns

string | undefined

getURLQueries(string)

Get URL query key value pairs from an URL string.

function getURLQueries(url: string): [key: string]: string

Parameters

url

string

Returns

[key: string]: string

padStart(string, number, undefined | string)

String.prototype.padStart()

function padStart(currentString: string, targetLength: number, padString?: undefined | string): string

Parameters

currentString

string

targetLength

number

padString

undefined | string

Returns

string

setURLHost(string, string)

Set URL host.

function setURLHost(url: string, host: string): string

Parameters

url

string

Source URL string

host

string

New host string

Returns

string

An updated URL string

setURLParameter(string, string, undefined | string)

Set URL parameter name and value. If name exists in URL parameters, old value will be replaced by name key. If not provide value, the parameter will be deleted.

function setURLParameter(url: string, name: string, value?: undefined | string): string

Parameters

url

string

Source URL string

name

string

Parameter name

value

undefined | string

Returns

string

An updated URL string

truncatedISO8061Date(Date, undefined | false | true)

Rounds a date off to seconds.

function truncatedISO8061Date(date: Date, withMilliseconds?: undefined | false | true): string

Parameters

date

Date

withMilliseconds

undefined | false | true

Returns

string

Date string in ISO8061 format, with or without 7 milliseconds component