Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShareServiceClient

Package version

A ShareServiceClient represents a URL to the Azure Storage File service allowing you to manipulate file shares.

Hierarchy

Index

Constructors

constructor

Properties

accountName

accountName: string

Protected credential

credential: Credential

Credential in the pipleline to authenticate requests to the service, such as AnonymousCredential, StorageSharedKeyCredential. Initialized to an AnonymousCredential if not able to retrieve it from the pipeline.

internal

Protected pipeline

pipeline: Pipeline

Request policy pipeline.

internal

Protected storageClientContext

storageClientContext: StorageClientContext

StorageClient is a reference to protocol layer operations entry, which is generated by AutoRest generator.

url

url: string

URL string value.

Methods

createShare

deleteShare

generateAccountSasUrl

  • Only available for ShareServiceClient constructed with a shared key credential.

    Generates an account Shared Access Signature (SAS) URI based on the client properties and parameters passed in. The SAS is signed by the shared key credential of the client.

    see

    https://docs.microsoft.com/en-us/rest/api/storageservices/create-account-sas

    Parameters

    • Optional expiresOn: Date

      Optional. The time at which the shared access signature becomes invalid. Default to an hour later if not specified.

    • Default value permissions: AccountSASPermissions = AccountSASPermissions.parse("r")

      Specifies the list of permissions to be associated with the SAS.

    • Default value resourceTypes: string = "sco"

      Specifies the resource types associated with the shared access signature.

    • Default value options: ServiceGenerateAccountSasUrlOptions = {}

      Optional parameters.

    Returns string

    An account SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.

getProperties

getShareClient

  • Creates a ShareClient object.

    Parameters

    • shareName: string

      Name of a share.

    Returns ShareClient

    The ShareClient object for the given share name.

    Example usage:

    const shareClient = serviceClient.getShareClient("<share name>");
    await shareClient.create();
    console.log("Created share successfully!");

listShares

  • Returns an async iterable iterator to list all the shares under the specified account.

    .byPage() returns an async iterable iterator to list the shares in pages.

    Example using for await syntax:

    let i = 1;
    for await (const share of serviceClient.listShares()) {
      console.log(`Share ${i++}: ${share.name}`);
    }

    Example using iter.next():

    let i = 1;
    let iter = serviceClient.listShares();
    let shareItem = await iter.next();
    while (!shareItem.done) {
      console.log(`Share ${i++}: ${shareItem.value.name}`);
      shareItem = await iter.next();
    }

    Example using byPage():

    // passing optional maxPageSize in the page settings
    let i = 1;
    for await (const response of serviceClient.listShares().byPage({ maxPageSize: 20 })) {
      if (response.shareItems) {
       for (const share of response.shareItems) {
           console.log(`Share ${i++}: ${share.name}`);
        }
      }
    }

    Example using paging with a marker:

    let i = 1;
    let iterator = serviceClient.listShares().byPage({ maxPageSize: 2 });
    let response = (await iterator.next()).value;
    
    // Prints 2 share names
    if (response.shareItems) {
      for (const share of response.shareItems) {
        console.log(`Share ${i++}: ${share.name}`);
      }
    }
    
    // Gets next marker
    let marker = response.continuationToken;
    
    // Passing next marker as continuationToken
    iterator = serviceClient.listShares().byPage({ continuationToken: marker, maxPageSize: 10 });
    response = (await iterator.next()).value;
    
    // Prints 10 share names
    if (response.shareItems) {
      for (const share of response.shareItems) {
        console.log(`Share ${i++}: ${share.name}`);
      }
    }

    Parameters

    • Default value options: ServiceListSharesOptions = {}

      Options to list shares operation.

      An asyncIterableIterator that supports paging.

    Returns PagedAsyncIterableIterator<ShareItem, ServiceListSharesSegmentResponse>

setProperties

undeleteShare

  • Restores a previously deleted share. This API is only functional if Share Soft Delete is enabled for the storage account associated with the share.

    Parameters

    • deletedShareName: string

      The name of the previously deleted share.

    • deletedShareVersion: string

      The version of the previously deleted share.

    • Default value options: ServiceUndeleteShareOptions = {}

      Options to Share undelete operation.

    Returns Promise<ShareClient>

    Restored share.

Static fromConnectionString

  • Creates an instance of ShareServiceClient from connection string.

    Parameters

    • connectionString: string

      Account connection string or a SAS connection string of an Azure storage account. [ Note - Account connection string can only be used in NODE.JS runtime. ] Account connection string example - DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net SAS connection string example - BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString

    • Optional options: StoragePipelineOptions

      Options to configure the HTTP pipeline.

    Returns ShareServiceClient

    A new ShareServiceClient from the given connection string.

Generated using TypeDoc