Class ShareServiceClientBuilder

java.lang.Object
com.azure.storage.file.share.ShareServiceClientBuilder
All Implemented Interfaces:
AzureNamedKeyCredentialTrait<ShareServiceClientBuilder>, AzureSasCredentialTrait<ShareServiceClientBuilder>, ConfigurationTrait<ShareServiceClientBuilder>, ConnectionStringTrait<ShareServiceClientBuilder>, EndpointTrait<ShareServiceClientBuilder>, HttpTrait<ShareServiceClientBuilder>

This class provides a fluent builder API to help aid the configuration and instantiation of the FileServiceClients and FileServiceAsyncClients, calling buildClient constructs an instance of ShareServiceClient and calling buildFileAsyncClient constructs an instance of ShareServiceAsyncClient.

The client needs the endpoint of the Azure Storage File service and authorization credential. endpoint gives the builder the endpoint and may give the builder a SAS token that authorizes the client.

Instantiating a synchronous FileService Client with SAS token

 ShareServiceClient fileServiceClient = new ShareServiceClientBuilder()
     .endpoint("https://${accountName}.file.core.windows.net?${SASToken}")
     .buildClient();
 

Instantiating an Asynchronous FileService Client with SAS token

 ShareServiceAsyncClient fileServiceAsyncClient = new ShareServiceClientBuilder()
     .endpoint("https://{accountName}.file.core.windows.net?{SASToken}")
     .buildAsyncClient();
 

If the endpoint doesn't contain the query parameters to construct a SAS token they may be set using sasToken .

 ShareServiceClient fileServiceClient = new ShareServiceClientBuilder()
     .endpoint("https://{accountName}.file.core.windows.net")
     .sasToken("${SASTokenQueryParams}")
     .buildClient();
 
 ShareServiceAsyncClient fileServiceAsyncClient = new ShareServiceClientBuilder()
     .endpoint("https://{accountName}.file.core.windows.net")
     .sasToken("${SASTokenQueryParams}")
     .buildAsyncClient();
 

Another way to authenticate the client is using a StorageSharedKeyCredential. To create a StorageSharedKeyCredential a connection string from the Storage File service must be used. Set the StorageSharedKeyCredential with connectionString. If the builder has both a SAS token and StorageSharedKeyCredential the StorageSharedKeyCredential will be preferred when authorizing requests sent to the service.

Instantiating a synchronous FileService Client with connection string.

 String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};AccountKey={key};"
     + "EndpointSuffix={core.windows.net}";
 ShareServiceClient fileServiceClient = new ShareServiceClientBuilder()
     .connectionString(connectionString)
     .buildClient();
 

Instantiating an Asynchronous FileService Client with connection string.

 String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};AccountKey={key};"
     + "EndpointSuffix={core.windows.net}";
 ShareServiceAsyncClient fileServiceAsyncClient = new ShareServiceClientBuilder()
     .connectionString(connectionString)
     .buildAsyncClient();
 
See Also: