Freigeben über


DataLakeServiceClient class

Mit DataLakeServiceClient können Sie Azure Data Lake-Dienstressourcen und Dateisysteme bearbeiten. Das Speicherkonto stellt den Namespace der obersten Ebene für den Data Lake-Dienst bereit.

Extends

StorageClient

Konstruktoren

DataLakeServiceClient(string, Pipeline)

Erstellt eine Instanz von DataLakeServiceClient aus url und Pipeline.

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

Erstellt eine Instanz von DataLakeServiceClient von url.

Geerbte Eigenschaften

accountName
credential

Wie anonyme Anmeldeinformationen, StorageSharedKeyCredential oder anmeldeinformationen aus dem @azure/identity-Paket zum Authentifizieren von Anforderungen an den Dienst. Sie können auch ein Objekt bereitstellen, das die TokenCredential-Schnittstelle implementiert. Wenn nicht angegeben, wird AnonymousCredential verwendet.

url

Codierter URL-Zeichenfolgenwert.

Methoden

fromConnectionString(string, StoragePipelineOptions)

Erstellt eine Instanz von DataLakeServiceClient aus verbindungszeichenfolge.

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

Nur für DataLakeServiceClient verfügbar, der mit freigegebenen Schlüsselanmeldeinformationen erstellt wurde.

Generiert einen SAS-URI (Shared Access Signature) basierend auf den Clienteigenschaften und Parametern, die übergeben werden. Die SAS wird von den freigegebenen Schlüsselanmeldeinformationen des Clients signiert.

Siehe https://learn.microsoft.com/rest/api/storageservices/create-account-sas.

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

Nur für DataLakeServiceClient verfügbar, der mit freigegebenen Schlüsselanmeldeinformationen erstellt wurde.

Generiert eine Zeichenfolge, die für ein Konto freigegebene Zugriffssignatur (Shared Access Signature, SAS) basierend auf den übergebenen Clienteigenschaften und Parametern signiert wird. Die SAS wird von den freigegebenen Schlüsselanmeldeinformationen des Clients signiert.

Siehe https://learn.microsoft.com/rest/api/storageservices/create-account-sas.

getFileSystemClient(string)

Erstellt ein DataLakeFileSystemClient- -Objekt.

getProperties(ServiceGetPropertiesOptions)

Ruft die Eigenschaften des Blob-Dienstendpunkts eines Speicherkontos ab, einschließlich Eigenschaften für Speicheranalyse- und CORS-Regeln (Cross-Origin Resource Sharing).

Siehe https://learn.microsoft.com/rest/api/storageservices/get-blob-service-properties.

getUserDelegationKey(Date, Date, ServiceGetUserDelegationKeyOptions)

NUR VERFÜGBAR BEI VERWENDUNG DER BEARERTOKENAUTHENTIFIZIERUNG (TokenCredential).

Ruft einen Benutzerdelegierungsschlüssel für den Data Lake-Dienst ab. Dies ist nur ein gültiger Vorgang, wenn die Bearertokenauthentifizierung verwendet wird.

Example

import {
  DataLakeServiceClient,
  generateDataLakeSASQueryParameters,
  FileSystemSASPermissions,
  SASProtocol,
} from "@azure/storage-file-datalake";

const account = "<account>";
const sas = "<sas token>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net${sas}`,
);

const fileSystemName = "<file system name>";
const accountName = "<account name>";
const startsOn = new Date();
const expiresOn = new Date(+new Date() + 86400 * 1000);
// 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();

Siehe https://learn.microsoft.com/rest/api/storageservices/get-user-delegation-key.

listFileSystems(ServiceListFileSystemsOptions)

Gibt einen asynchronen iterierbaren Iterator zurück, um alle Dateisysteme unter dem angegebenen Konto auflisten zu können.

.byPage() gibt einen asynchronen iterablen Iterator zurück, um die Dateisysteme auf Seiten auflisten zu können.

Beispiel mit for await Syntax:

import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
const fileSystems = datalakeServiceClient.listFileSystems();
for await (const fileSystem of fileSystems) {
  console.log(`File system ${i++}: ${fileSystem.name}`);
}

Beispiel für die Verwendung von iter.next():

import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
const fileSystems = datalakeServiceClient.listFileSystems();
let { value, done } = await fileSystems.next();
while (!done) {
  console.log(`File system ${i++}: ${value.name}`);
  ({ value, done } = await fileSystems.next());
}

Beispiel für die Verwendung von byPage():

import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
for await (const response of datalakeServiceClient.listFileSystems().byPage({ maxPageSize: 20 })) {
  if (response.fileSystemItems) {
    for (const fileSystem of response.fileSystemItems) {
      console.log(`File System ${i++}: ${fileSystem.name}`);
    }
  }
}

Beispiel für das Paging mit einer Markierung:

import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
let fileSystems = datalakeServiceClient.listFileSystems().byPage({ maxPageSize: 2 });
let response = (await fileSystems.next()).value;
// Prints 2 file systems
if (response.fileSystemItems) {
  for (const fileSystem of response.fileSystemItems) {
    console.log(`File system ${i++}: ${fileSystem.name}`);
  }
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
fileSystems = datalakeServiceClient
  .listFileSystems()
  .byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await fileSystems.next()).value;
// Prints 10 file systems
if (response.fileSystemItems) {
  for (const fileSystem of response.fileSystemItems) {
    console.log(`File system ${i++}: ${fileSystem.name}`);
  }
}

Siehe https://learn.microsoft.com/rest/api/storageservices/list-containers2.

setProperties(BlobServiceProperties, ServiceSetPropertiesOptions)

Legt Eigenschaften für den Blob-Dienstendpunkt eines Speicherkontos fest, einschließlich Eigenschaften für Storage Analytics, CORS -Regeln (Cross-Origin Resource Sharing) und Einstellungen für vorläufiges Löschen.

Siehe https://learn.microsoft.com/rest/api/storageservices/set-blob-service-properties.

undeleteFileSystem(string, string, ServiceUndeleteFileSystemOptions)

Stellen Sie ein zuvor gelöschtes Dateisystem wieder her. Diese API ist nur funktionsfähig, wenn container soft delete für das Speicherkonto aktiviert ist.

Details zum Konstruktor

DataLakeServiceClient(string, Pipeline)

Erstellt eine Instanz von DataLakeServiceClient aus url und Pipeline.

new DataLakeServiceClient(url: string, pipeline: Pipeline)

Parameter

url

string

Eine Clientzeichenfolge, die auf den Azure Storage Data Lake-Dienst verweist, z. B. "https://myaccount.dfs.core.windows.net". Sie können eine SAS anfügen, wenn Anonyme Anmeldeinformationen verwendet werden, z. B. "https://myaccount.dfs.core.windows.net?sasString".

pipeline
Pipeline

Rufen Sie newPipeline() auf, um eine Standardpipeline zu erstellen oder eine angepasste Pipeline bereitzustellen.

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

Erstellt eine Instanz von DataLakeServiceClient von url.

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

Parameter

url

string

Eine Clientzeichenfolge, die auf den Azure Storage Data Lake-Dienst verweist, z. B. "https://myaccount.dfs.core.windows.net". Sie können eine SAS anfügen, wenn Anonyme Anmeldeinformationen verwendet werden, z. B. "https://myaccount.dfs.core.windows.net?sasString".

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Wie anonyme Anmeldeinformationen, StorageSharedKeyCredential oder anmeldeinformationen aus dem @azure/identity-Paket zum Authentifizieren von Anforderungen an den Dienst. Sie können auch ein Objekt bereitstellen, das die TokenCredential-Schnittstelle implementiert. Wenn nicht angegeben, wird AnonymousCredential verwendet.

options
StoragePipelineOptions

Optional. Optionen zum Konfigurieren der HTTP-Pipeline.

Geerbte Eigenschaftsdetails

accountName

accountName: string

Eigenschaftswert

string

geerbt von StorageClient.accountName

credential

Wie anonyme Anmeldeinformationen, StorageSharedKeyCredential oder anmeldeinformationen aus dem @azure/identity-Paket zum Authentifizieren von Anforderungen an den Dienst. Sie können auch ein Objekt bereitstellen, das die TokenCredential-Schnittstelle implementiert. Wenn nicht angegeben, wird AnonymousCredential verwendet.

credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Eigenschaftswert

von StorageClient.credential geerbt

url

Codierter URL-Zeichenfolgenwert.

url: string

Eigenschaftswert

string

geerbt von StorageClient.url

Details zur Methode

fromConnectionString(string, StoragePipelineOptions)

Erstellt eine Instanz von DataLakeServiceClient aus verbindungszeichenfolge.

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

Parameter

connectionString

string

Kontoverbindungszeichenfolge oder SAS-Verbindungszeichenfolge eines Azure-Speicherkontos. [ Hinweis : Kontoverbindungszeichenfolge kann nur in NODE.JS Laufzeit verwendet werden. ] Beispiel für kontoverbindungszeichenfolge - beispiel für DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net SAS-Verbindungszeichenfolge - 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

Optional. Optionen zum Konfigurieren der HTTP-Pipeline.

Gibt zurück

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

Nur für DataLakeServiceClient verfügbar, der mit freigegebenen Schlüsselanmeldeinformationen erstellt wurde.

Generiert einen SAS-URI (Shared Access Signature) basierend auf den Clienteigenschaften und Parametern, die übergeben werden. Die SAS wird von den freigegebenen Schlüsselanmeldeinformationen des Clients signiert.

Siehe https://learn.microsoft.com/rest/api/storageservices/create-account-sas.

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

Parameter

expiresOn

Date

Optional. Der Zeitpunkt, zu dem die Signatur des freigegebenen Zugriffs ungültig wird. Wenn nicht angegeben, wird die Standardeinstellung auf eine Stunde später festgelegt.

permissions
AccountSASPermissions

Gibt die Liste der Berechtigungen an, die der SAS zugeordnet werden sollen.

resourceTypes

string

Gibt die Ressourcentypen an, die der Gemeinsamen Zugriffssignatur zugeordnet sind.

options
ServiceGenerateAccountSasUrlOptions

Optionale Parameter.

Gibt zurück

string

Ein SAS-Konto-URI, der aus dem URI für die Ressource besteht, die von diesem Client dargestellt wird, gefolgt von dem generierten SAS-Token.

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

Nur für DataLakeServiceClient verfügbar, der mit freigegebenen Schlüsselanmeldeinformationen erstellt wurde.

Generiert eine Zeichenfolge, die für ein Konto freigegebene Zugriffssignatur (Shared Access Signature, SAS) basierend auf den übergebenen Clienteigenschaften und Parametern signiert wird. Die SAS wird von den freigegebenen Schlüsselanmeldeinformationen des Clients signiert.

Siehe https://learn.microsoft.com/rest/api/storageservices/create-account-sas.

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

Parameter

expiresOn

Date

Optional. Der Zeitpunkt, zu dem die Signatur des freigegebenen Zugriffs ungültig wird. Wenn nicht angegeben, wird die Standardeinstellung auf eine Stunde später festgelegt.

permissions
AccountSASPermissions

Gibt die Liste der Berechtigungen an, die der SAS zugeordnet werden sollen.

resourceTypes

string

Gibt die Ressourcentypen an, die der Gemeinsamen Zugriffssignatur zugeordnet sind.

options
ServiceGenerateAccountSasUrlOptions

Optionale Parameter.

Gibt zurück

string

Ein SAS-Konto-URI, der aus dem URI für die Ressource besteht, die von diesem Client dargestellt wird, gefolgt von dem generierten SAS-Token.

getFileSystemClient(string)

Erstellt ein DataLakeFileSystemClient- -Objekt.

function getFileSystemClient(fileSystemName: string): DataLakeFileSystemClient

Parameter

fileSystemName

string

Dateisystemname.

Gibt zurück

getProperties(ServiceGetPropertiesOptions)

Ruft die Eigenschaften des Blob-Dienstendpunkts eines Speicherkontos ab, einschließlich Eigenschaften für Speicheranalyse- und CORS-Regeln (Cross-Origin Resource Sharing).

Siehe https://learn.microsoft.com/rest/api/storageservices/get-blob-service-properties.

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

Parameter

options
ServiceGetPropertiesOptions

Optionen für den Service Get Properties-Vorgang.

Gibt zurück

Antwortdaten für den Service Get Properties-Vorgang.

getUserDelegationKey(Date, Date, ServiceGetUserDelegationKeyOptions)

NUR VERFÜGBAR BEI VERWENDUNG DER BEARERTOKENAUTHENTIFIZIERUNG (TokenCredential).

Ruft einen Benutzerdelegierungsschlüssel für den Data Lake-Dienst ab. Dies ist nur ein gültiger Vorgang, wenn die Bearertokenauthentifizierung verwendet wird.

Example

import {
  DataLakeServiceClient,
  generateDataLakeSASQueryParameters,
  FileSystemSASPermissions,
  SASProtocol,
} from "@azure/storage-file-datalake";

const account = "<account>";
const sas = "<sas token>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net${sas}`,
);

const fileSystemName = "<file system name>";
const accountName = "<account name>";
const startsOn = new Date();
const expiresOn = new Date(+new Date() + 86400 * 1000);
// 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();

Siehe https://learn.microsoft.com/rest/api/storageservices/get-user-delegation-key.

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

Parameter

startsOn

Date

Die Startzeit für die Benutzerdelegierung SAS. Muss innerhalb von 7 Tagen nach der aktuellen Uhrzeit sein.

expiresOn

Date

Die Endzeit für die Sas der Benutzerdelegierung. Muss innerhalb von 7 Tagen nach der aktuellen Uhrzeit sein.

Gibt zurück

listFileSystems(ServiceListFileSystemsOptions)

Gibt einen asynchronen iterierbaren Iterator zurück, um alle Dateisysteme unter dem angegebenen Konto auflisten zu können.

.byPage() gibt einen asynchronen iterablen Iterator zurück, um die Dateisysteme auf Seiten auflisten zu können.

Beispiel mit for await Syntax:

import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
const fileSystems = datalakeServiceClient.listFileSystems();
for await (const fileSystem of fileSystems) {
  console.log(`File system ${i++}: ${fileSystem.name}`);
}

Beispiel für die Verwendung von iter.next():

import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
const fileSystems = datalakeServiceClient.listFileSystems();
let { value, done } = await fileSystems.next();
while (!done) {
  console.log(`File system ${i++}: ${value.name}`);
  ({ value, done } = await fileSystems.next());
}

Beispiel für die Verwendung von byPage():

import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
for await (const response of datalakeServiceClient.listFileSystems().byPage({ maxPageSize: 20 })) {
  if (response.fileSystemItems) {
    for (const fileSystem of response.fileSystemItems) {
      console.log(`File System ${i++}: ${fileSystem.name}`);
    }
  }
}

Beispiel für das Paging mit einer Markierung:

import { DataLakeServiceClient } from "@azure/storage-file-datalake";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const datalakeServiceClient = new DataLakeServiceClient(
  `https://${account}.dfs.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
let fileSystems = datalakeServiceClient.listFileSystems().byPage({ maxPageSize: 2 });
let response = (await fileSystems.next()).value;
// Prints 2 file systems
if (response.fileSystemItems) {
  for (const fileSystem of response.fileSystemItems) {
    console.log(`File system ${i++}: ${fileSystem.name}`);
  }
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
fileSystems = datalakeServiceClient
  .listFileSystems()
  .byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await fileSystems.next()).value;
// Prints 10 file systems
if (response.fileSystemItems) {
  for (const fileSystem of response.fileSystemItems) {
    console.log(`File system ${i++}: ${fileSystem.name}`);
  }
}

Siehe https://learn.microsoft.com/rest/api/storageservices/list-containers2.

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

Parameter

Gibt zurück

setProperties(BlobServiceProperties, ServiceSetPropertiesOptions)

Legt Eigenschaften für den Blob-Dienstendpunkt eines Speicherkontos fest, einschließlich Eigenschaften für Storage Analytics, CORS -Regeln (Cross-Origin Resource Sharing) und Einstellungen für vorläufiges Löschen.

Siehe https://learn.microsoft.com/rest/api/storageservices/set-blob-service-properties.

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

Parameter

options
ServiceSetPropertiesOptions

Optionen für den Dienstsatz-Eigenschaftenvorgang.

Gibt zurück

Antwortdaten für den Dienstsatz-Eigenschaftenvorgang.

undeleteFileSystem(string, string, ServiceUndeleteFileSystemOptions)

Stellen Sie ein zuvor gelöschtes Dateisystem wieder her. Diese API ist nur funktionsfähig, wenn container soft delete für das Speicherkonto aktiviert ist.

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

Parameter

deletedFileSystemName

string

Der Name des Quelldateisystems.

deleteFileSystemVersion

string

Der neue Name des Dateisystems.

options
ServiceUndeleteFileSystemOptions

Optionen zum Konfigurieren des Dateisystemwiederherstellungsvorgangs.

Gibt zurück

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