共用方式為


DataLakeServiceClient class

DataLakeServiceClient 可讓您操作 Azure Data Lake 服務資源和文件系統。 記憶體帳戶會提供 Data Lake 服務的最上層命名空間。

Extends

StorageClient

建構函式

DataLakeServiceClient(string, Pipeline)

從 URL 和管線建立 DataLakeServiceClient 的實例。

DataLakeServiceClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions)

從 URL 建立 DataLakeServiceClient 的實例。

繼承的屬性

accountName
credential

例如 AnonymousCredential、StorageSharedKeyCredential 或任何來自 @azure/identity 套件的認證,以驗證對服務的要求。 您也可以提供實作 TokenCredential 介面的物件。 如果未指定,則會使用 AnonymousCredential。

url

編碼的 URL 字串值。

方法

fromConnectionString(string, StoragePipelineOptions)

從連接字串建立 DataLakeServiceClient 的實例。

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

僅適用於以共用密鑰認證建構的 DataLakeServiceClient。

根據傳入的用戶端屬性和參數,產生帳戶共用存取簽章 (SAS) URI。 SAS 是由客戶端的共用金鑰認證所簽署。

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

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

僅適用於以共用密鑰認證建構的 DataLakeServiceClient。

根據傳入的用戶端屬性和參數,產生要簽署帳戶共用存取簽章的字串。 SAS 是由客戶端的共用金鑰認證所簽署。

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

getFileSystemClient(string)

建立 DataLakeFileSystemClient 物件。

getProperties(ServiceGetPropertiesOptions)

取得記憶體帳戶 Blob 服務端點的屬性,包括記憶體分析和 CORS(跨原始來源資源分享)規則的屬性。

請參閱 https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties

getUserDelegationKey(Date, Date, ServiceGetUserDelegationKeyOptions)

僅適用於使用 BEARER 令牌驗證 (TokenCredential) 時。

擷取 Data Lake 服務的使用者委派密鑰。 使用持有人令牌驗證時,這隻是有效的作業。

範例

// Generate user delegation SAS for a file system
const userDelegationKey = await dataLakeServiceClient.getUserDelegationKey(startsOn, expiresOn);
const fileSystemSAS = generateDataLakeSASQueryParameters({
    fileSystemName, // Required
    permissions: FileSystemSASPermissions.parse("racwdl"), // Required
    startsOn, // Required. Date type
    expiresOn, // Optional. Date type
    ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
    protocol: SASProtocol.HttpsAndHttp, // Optional
    version: "2018-11-09" // Must greater than or equal to 2018-11-09 to generate user delegation SAS
  },
  userDelegationKey, // UserDelegationKey
  accountName
).toString();

請參閱 https://docs.microsoft.com/en-us/rest/api/storageservices/get-user-delegation-key

listFileSystems(ServiceListFileSystemsOptions)

傳回異步反覆運算器,以列出指定帳戶下的所有文件系統。

.byPage() 會傳回異步反覆運算器,以在頁面中列出文件系統。

使用 for await 語法的範例:

let i = 1;
for await (const fileSystem of serviceClient.listFileSystems()) {
  console.log(`FileSystem ${i++}: ${fileSystem.name}`);
}

使用 iter.next()的範例:

let i = 1;
const iter = serviceClient.listFileSystems();
let fileSystemItem = await iter.next();
while (!fileSystemItem.done) {
  console.log(`FileSystem ${i++}: ${fileSystemItem.value.name}`);
  fileSystemItem = await iter.next();
}

使用 byPage()的範例:

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

使用分頁搭配標記的範例:

let i = 1;
let iterator = serviceClient.listFileSystems().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;

// Prints 2 file system names
if (response.fileSystemItems) {
  for (const fileSystem of response.fileSystemItems) {
    console.log(`FileSystem ${i++}: ${fileSystem.name}`);
  }
}

// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = serviceClient
  .listContainers()
  .byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;

// Prints 10 file system names
if (response.fileSystemItems) {
  for (const fileSystem of response.fileSystemItems) {
     console.log(`FileSystem ${i++}: ${fileSystem.name}`);
  }
}

請參閱 https://docs.microsoft.com/en-us/rest/api/storageservices/list-containers2

setProperties(BlobServiceProperties, ServiceSetPropertiesOptions)

設定記憶體帳戶 Blob 服務端點的屬性,包括記憶體分析、CORS(跨原始來源資源分享)規則和虛刪除設定的屬性。

請參閱 https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-service-properties

undeleteFileSystem(string, string, ServiceUndeleteFileSystemOptions)

還原先前刪除的檔案系統。 只有在記憶體帳戶啟用容器虛刪除時,此 API 才會運作。

建構函式詳細資料

DataLakeServiceClient(string, Pipeline)

從 URL 和管線建立 DataLakeServiceClient 的實例。

new DataLakeServiceClient(url: string, pipeline: Pipeline)

參數

url

string

指向 Azure 記憶體數據湖服務的用戶端字串,例如 「https://myaccount.dfs.core.windows.net"。 如果使用 AnonymousCredential,則可以附加 SAS,例如 “https://myaccount.dfs.core.windows.net?sasString"。

pipeline
Pipeline

呼叫 newPipeline() 以建立預設管線,或提供自定義管線。

DataLakeServiceClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions)

從 URL 建立 DataLakeServiceClient 的實例。

new DataLakeServiceClient(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)

參數

url

string

指向 Azure 記憶體數據湖服務的用戶端字串,例如 「https://myaccount.dfs.core.windows.net"。 如果使用 AnonymousCredential,則可以附加 SAS,例如 “https://myaccount.dfs.core.windows.net?sasString"。

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

例如 AnonymousCredential、StorageSharedKeyCredential 或任何來自 @azure/identity 套件的認證,以驗證對服務的要求。 您也可以提供實作 TokenCredential 介面的物件。 如果未指定,則會使用 AnonymousCredential。

options
StoragePipelineOptions

自選。 設定 HTTP 管線的選項。

繼承的屬性詳細資料

accountName

accountName: string

屬性值

string

繼承自 StorageClient.accountName

credential

例如 AnonymousCredential、StorageSharedKeyCredential 或任何來自 @azure/identity 套件的認證,以驗證對服務的要求。 您也可以提供實作 TokenCredential 介面的物件。 如果未指定,則會使用 AnonymousCredential。

credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential

屬性值

繼承自 StorageClient.credential

url

編碼的 URL 字串值。

url: string

屬性值

string

繼承自 StorageClient.url

方法詳細資料

fromConnectionString(string, StoragePipelineOptions)

從連接字串建立 DataLakeServiceClient 的實例。

static function fromConnectionString(connectionString: string, options?: StoragePipelineOptions): DataLakeServiceClient

參數

connectionString

string

帳戶連接字串或 Azure 記憶體帳戶的 SAS 連接字串。 [ 注意 - 帳戶連接字串只能在NODE.JS運行時間使用。 ] 帳戶連接字串範例 - DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net SAS 連接字串範例 - 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

options
StoragePipelineOptions

自選。 設定 HTTP 管線的選項。

傳回

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

僅適用於以共用密鑰認證建構的 DataLakeServiceClient。

根據傳入的用戶端屬性和參數,產生帳戶共用存取簽章 (SAS) URI。 SAS 是由客戶端的共用金鑰認證所簽署。

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

function generateAccountSasUrl(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string

參數

expiresOn

Date

自選。 共用存取簽章失效的時間。 如果未指定,則預設為一小時后。

permissions
AccountSASPermissions

指定要與 SAS 相關聯的許可權清單。

resourceTypes

string

指定與共用存取簽章相關聯的資源類型。

options
ServiceGenerateAccountSasUrlOptions

選擇性參數。

傳回

string

帳戶 SAS URI,其中包含此用戶端所代表資源的 URI,後面接著產生的 SAS 令牌。

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

僅適用於以共用密鑰認證建構的 DataLakeServiceClient。

根據傳入的用戶端屬性和參數,產生要簽署帳戶共用存取簽章的字串。 SAS 是由客戶端的共用金鑰認證所簽署。

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

function generateSasStringToSign(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string

參數

expiresOn

Date

自選。 共用存取簽章失效的時間。 如果未指定,則預設為一小時后。

permissions
AccountSASPermissions

指定要與 SAS 相關聯的許可權清單。

resourceTypes

string

指定與共用存取簽章相關聯的資源類型。

options
ServiceGenerateAccountSasUrlOptions

選擇性參數。

傳回

string

帳戶 SAS URI,其中包含此用戶端所代表資源的 URI,後面接著產生的 SAS 令牌。

getFileSystemClient(string)

建立 DataLakeFileSystemClient 物件。

function getFileSystemClient(fileSystemName: string): DataLakeFileSystemClient

參數

fileSystemName

string

檔案系統名稱。

傳回

getProperties(ServiceGetPropertiesOptions)

取得記憶體帳戶 Blob 服務端點的屬性,包括記憶體分析和 CORS(跨原始來源資源分享)規則的屬性。

請參閱 https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties

function getProperties(options?: ServiceGetPropertiesOptions): Promise<ServiceGetPropertiesResponse>

參數

options
ServiceGetPropertiesOptions

服務取得屬性作業的選項。

傳回

服務取得屬性作業的響應數據。

getUserDelegationKey(Date, Date, ServiceGetUserDelegationKeyOptions)

僅適用於使用 BEARER 令牌驗證 (TokenCredential) 時。

擷取 Data Lake 服務的使用者委派密鑰。 使用持有人令牌驗證時,這隻是有效的作業。

範例

// Generate user delegation SAS for a file system
const userDelegationKey = await dataLakeServiceClient.getUserDelegationKey(startsOn, expiresOn);
const fileSystemSAS = generateDataLakeSASQueryParameters({
    fileSystemName, // Required
    permissions: FileSystemSASPermissions.parse("racwdl"), // Required
    startsOn, // Required. Date type
    expiresOn, // Optional. Date type
    ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
    protocol: SASProtocol.HttpsAndHttp, // Optional
    version: "2018-11-09" // Must greater than or equal to 2018-11-09 to generate user delegation SAS
  },
  userDelegationKey, // UserDelegationKey
  accountName
).toString();

請參閱 https://docs.microsoft.com/en-us/rest/api/storageservices/get-user-delegation-key

function getUserDelegationKey(startsOn: Date, expiresOn: Date, options?: ServiceGetUserDelegationKeyOptions): Promise<ServiceGetUserDelegationKeyResponse>

參數

startsOn

Date

使用者委派 SAS 的開始時間。 必須在目前時間的 7 天內。

expiresOn

Date

使用者委派 SAS 的結束時間。 必須在目前時間的 7 天內。

傳回

listFileSystems(ServiceListFileSystemsOptions)

傳回異步反覆運算器,以列出指定帳戶下的所有文件系統。

.byPage() 會傳回異步反覆運算器,以在頁面中列出文件系統。

使用 for await 語法的範例:

let i = 1;
for await (const fileSystem of serviceClient.listFileSystems()) {
  console.log(`FileSystem ${i++}: ${fileSystem.name}`);
}

使用 iter.next()的範例:

let i = 1;
const iter = serviceClient.listFileSystems();
let fileSystemItem = await iter.next();
while (!fileSystemItem.done) {
  console.log(`FileSystem ${i++}: ${fileSystemItem.value.name}`);
  fileSystemItem = await iter.next();
}

使用 byPage()的範例:

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

使用分頁搭配標記的範例:

let i = 1;
let iterator = serviceClient.listFileSystems().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;

// Prints 2 file system names
if (response.fileSystemItems) {
  for (const fileSystem of response.fileSystemItems) {
    console.log(`FileSystem ${i++}: ${fileSystem.name}`);
  }
}

// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = serviceClient
  .listContainers()
  .byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;

// Prints 10 file system names
if (response.fileSystemItems) {
  for (const fileSystem of response.fileSystemItems) {
     console.log(`FileSystem ${i++}: ${fileSystem.name}`);
  }
}

請參閱 https://docs.microsoft.com/en-us/rest/api/storageservices/list-containers2

function listFileSystems(options?: ServiceListFileSystemsOptions): PagedAsyncIterableIterator<FileSystemItem, ServiceListFileSystemsSegmentResponse, PageSettings>

參數

傳回

setProperties(BlobServiceProperties, ServiceSetPropertiesOptions)

設定記憶體帳戶 Blob 服務端點的屬性,包括記憶體分析、CORS(跨原始來源資源分享)規則和虛刪除設定的屬性。

請參閱 https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-service-properties

function setProperties(properties: BlobServiceProperties, options?: ServiceSetPropertiesOptions): Promise<ServiceSetPropertiesResponse>

參數

options
ServiceSetPropertiesOptions

服務集屬性作業的選項。

傳回

服務集屬性作業的響應數據。

undeleteFileSystem(string, string, ServiceUndeleteFileSystemOptions)

還原先前刪除的檔案系統。 只有在記憶體帳戶啟用容器虛刪除時,此 API 才會運作。

function undeleteFileSystem(deletedFileSystemName: string, deleteFileSystemVersion: string, options?: ServiceUndeleteFileSystemOptions): Promise<{ fileSystemClient: DataLakeFileSystemClient, fileSystemUndeleteResponse: ContainerUndeleteResponse }>

參數

deletedFileSystemName

string

來源檔案系統的名稱。

deleteFileSystemVersion

string

檔案系統的新名稱。

options
ServiceUndeleteFileSystemOptions

設定檔案系統還原作業的選項。

傳回

Promise<{ fileSystemClient: DataLakeFileSystemClient, fileSystemUndeleteResponse: ContainerUndeleteResponse }>