Sdílet prostřednictvím


DataLakeServiceClient class

DataLakeServiceClient umožňuje manipulovat s prostředky a systémy souborů služby Azure Data Lake. Účet úložiště poskytuje obor názvů nejvyšší úrovně pro službu Data Lake.

Extends

StorageClient

Konstruktory

DataLakeServiceClient(string, Pipeline)

Vytvoří instanci DataLakeServiceClient z adresy URL a kanálu.

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

Vytvoří instanci DataLakeServiceClient z adresy URL.

Zděděné vlastnosti

accountName
credential

Například AnonymousCredential, StorageSharedKeyCredential nebo jakékoli přihlašovací údaje z balíčku @azure/identity k ověření požadavků na službu. Můžete také poskytnout objekt, který implementuje TokenCredential rozhraní. Pokud není zadáno, použije se anonymnícredential.

url

Zakódovaná hodnota řetězce adresy URL.

Metody

fromConnectionString(string, StoragePipelineOptions)

Vytvoří instanci DataLakeServiceClient z připojovacího řetězce.

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

K dispozici pouze pro DataLakeServiceClient vytvořený s přihlašovacími údaji sdíleného klíče.

Vygeneruje identifikátor URI sdíleného přístupového podpisu účtu na základě vlastností klienta a parametrů předaných. Sas je podepsán přihlašovacími údaji sdíleného klíče klienta.

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/create-account-sas

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

K dispozici pouze pro DataLakeServiceClient vytvořený s přihlašovacími údaji sdíleného klíče.

Vygeneruje řetězec pro podepsání účtu sdílený přístupový podpis (SAS) na základě vlastností klienta a parametrů předaných. Sas je podepsán přihlašovacími údaji sdíleného klíče klienta.

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/create-account-sas

getFileSystemClient(string)

Vytvoří objekt DataLakeFileSystemClient.

getProperties(ServiceGetPropertiesOptions)

Získá vlastnosti koncového bodu služby Blob service účtu úložiště, včetně vlastností pravidel analýzy úložiště a CORS (sdílení prostředků mezi zdroji).

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/get-blob-service-properties

getUserDelegationKey(Date, Date, ServiceGetUserDelegationKeyOptions)

K DISPOZICI POUZE PŘI POUŽITÍ OVĚŘOVÁNÍ NOSNÝ TOKEN (TokenCredential).

Načte klíč delegování uživatele pro službu Data Lake. Jedná se pouze o platnou operaci při použití ověřování nosné tokeny.

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();

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/get-user-delegation-key

listFileSystems(ServiceListFileSystemsOptions)

Vrátí asynchronní iterátor pro výpis všech systémů souborů v rámci zadaného účtu.

.byPage() vrátí asynchronní iterátor pro výpis systémů souborů na stránkách.

Příklad použití syntaxe for await:

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}`);
}

Příklad použití 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());
}

Příklad použití 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}`);
    }
  }
}

Příklad použití stránkování se značkou:

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}`);
  }
}

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/list-containers2

setProperties(BlobServiceProperties, ServiceSetPropertiesOptions)

Nastaví vlastnosti pro koncový bod služby Blob service účtu úložiště, včetně vlastností pro analýzy úložiště, pravidel CORS (sdílení prostředků mezi zdroji) a nastavení obnovitelného odstranění.

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/set-blob-service-properties

undeleteFileSystem(string, string, ServiceUndeleteFileSystemOptions)

Obnovení dříve odstraněného systému souborů Toto rozhraní API je funkční pouze v případě, že je pro účet úložiště povolené obnovitelné odstranění kontejneru.

Podrobnosti konstruktoru

DataLakeServiceClient(string, Pipeline)

Vytvoří instanci DataLakeServiceClient z adresy URL a kanálu.

new DataLakeServiceClient(url: string, pipeline: Pipeline)

Parametry

url

string

Řetězec klienta odkazující na službu Azure Storage Data Lake, například "https://myaccount.dfs.core.windows.net". Sas můžete připojit, pokud používáte AnonymousCredential, například "https://myaccount.dfs.core.windows.net?sasString".

pipeline
Pipeline

Voláním metody newPipeline() vytvořte výchozí kanál nebo zadejte přizpůsobený kanál.

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

Vytvoří instanci DataLakeServiceClient z adresy URL.

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

Parametry

url

string

Řetězec klienta odkazující na službu Azure Storage Data Lake, například "https://myaccount.dfs.core.windows.net". Sas můžete připojit, pokud používáte AnonymousCredential, například "https://myaccount.dfs.core.windows.net?sasString".

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Například AnonymousCredential, StorageSharedKeyCredential nebo jakékoli přihlašovací údaje z balíčku @azure/identity k ověření požadavků na službu. Můžete také poskytnout objekt, který implementuje TokenCredential rozhraní. Pokud není zadáno, použije se anonymnícredential.

options
StoragePipelineOptions

Optional. Možnosti konfigurace kanálu HTTP

Podrobnosti zděděných vlastností

accountName

accountName: string

Hodnota vlastnosti

string

zděděno ze StorageClient.accountName

credential

Například AnonymousCredential, StorageSharedKeyCredential nebo jakékoli přihlašovací údaje z balíčku @azure/identity k ověření požadavků na službu. Můžete také poskytnout objekt, který implementuje TokenCredential rozhraní. Pokud není zadáno, použije se anonymnícredential.

credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Hodnota vlastnosti

zděděné z StorageClient.credential

url

Zakódovaná hodnota řetězce adresy URL.

url: string

Hodnota vlastnosti

string

zděděno ze StorageClient.url

Podrobnosti metody

fromConnectionString(string, StoragePipelineOptions)

Vytvoří instanci DataLakeServiceClient z připojovacího řetězce.

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

Parametry

connectionString

string

Připojovací řetězec účtu nebo připojovací řetězec SAS účtu úložiště Azure. [ Poznámka: Připojovací řetězec účtu lze použít pouze v NODE.JS modulu runtime. ] Příklad připojovacího řetězce účtu – Příklad připojovacího řetězce SAS DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.netBlobEndpoint=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. Možnosti konfigurace kanálu HTTP

Návraty

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

K dispozici pouze pro DataLakeServiceClient vytvořený s přihlašovacími údaji sdíleného klíče.

Vygeneruje identifikátor URI sdíleného přístupového podpisu účtu na základě vlastností klienta a parametrů předaných. Sas je podepsán přihlašovacími údaji sdíleného klíče klienta.

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/create-account-sas

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

Parametry

expiresOn

Date

Optional. Čas, kdy se sdílený přístupový podpis stane neplatným. Výchozí hodnota je hodina později, pokud není zadána.

permissions
AccountSASPermissions

Určuje seznamoprávněních

resourceTypes

string

Určuje typy prostředků přidružené ke sdílenému přístupovém podpisu.

options
ServiceGenerateAccountSasUrlOptions

Volitelné parametry.

Návraty

string

Identifikátor URI SAS účtu, který se skládá z identifikátoru URI pro prostředek reprezentovaný tímto klientem, následovaný vygenerovaným tokenem SAS.

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

K dispozici pouze pro DataLakeServiceClient vytvořený s přihlašovacími údaji sdíleného klíče.

Vygeneruje řetězec pro podepsání účtu sdílený přístupový podpis (SAS) na základě vlastností klienta a parametrů předaných. Sas je podepsán přihlašovacími údaji sdíleného klíče klienta.

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/create-account-sas

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

Parametry

expiresOn

Date

Optional. Čas, kdy se sdílený přístupový podpis stane neplatným. Výchozí hodnota je hodina později, pokud není zadána.

permissions
AccountSASPermissions

Určuje seznamoprávněních

resourceTypes

string

Určuje typy prostředků přidružené ke sdílenému přístupovém podpisu.

options
ServiceGenerateAccountSasUrlOptions

Volitelné parametry.

Návraty

string

Identifikátor URI SAS účtu, který se skládá z identifikátoru URI pro prostředek reprezentovaný tímto klientem, následovaný vygenerovaným tokenem SAS.

getFileSystemClient(string)

Vytvoří objekt DataLakeFileSystemClient.

function getFileSystemClient(fileSystemName: string): DataLakeFileSystemClient

Parametry

fileSystemName

string

Název systému souborů

Návraty

getProperties(ServiceGetPropertiesOptions)

Získá vlastnosti koncového bodu služby Blob service účtu úložiště, včetně vlastností pravidel analýzy úložiště a CORS (sdílení prostředků mezi zdroji).

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/get-blob-service-properties

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

Parametry

options
ServiceGetPropertiesOptions

Možnosti operace Získání vlastností služby

Návraty

Data odpovědí pro operaci Získání vlastností služby

getUserDelegationKey(Date, Date, ServiceGetUserDelegationKeyOptions)

K DISPOZICI POUZE PŘI POUŽITÍ OVĚŘOVÁNÍ NOSNÝ TOKEN (TokenCredential).

Načte klíč delegování uživatele pro službu Data Lake. Jedná se pouze o platnou operaci při použití ověřování nosné tokeny.

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();

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/get-user-delegation-key

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

Parametry

startsOn

Date

Čas zahájení sdíleného přístupového podpisu delegování uživatele Musí být do 7 dnů od aktuálního času.

expiresOn

Date

Koncový čas sdíleného přístupového podpisu delegování uživatele. Musí být do 7 dnů od aktuálního času.

Návraty

listFileSystems(ServiceListFileSystemsOptions)

Vrátí asynchronní iterátor pro výpis všech systémů souborů v rámci zadaného účtu.

.byPage() vrátí asynchronní iterátor pro výpis systémů souborů na stránkách.

Příklad použití syntaxe for await:

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}`);
}

Příklad použití 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());
}

Příklad použití 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}`);
    }
  }
}

Příklad použití stránkování se značkou:

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}`);
  }
}

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/list-containers2

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

Parametry

Návraty

setProperties(BlobServiceProperties, ServiceSetPropertiesOptions)

Nastaví vlastnosti pro koncový bod služby Blob service účtu úložiště, včetně vlastností pro analýzy úložiště, pravidel CORS (sdílení prostředků mezi zdroji) a nastavení obnovitelného odstranění.

Podívejte se na https://learn.microsoft.com/rest/api/storageservices/set-blob-service-properties

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

Parametry

options
ServiceSetPropertiesOptions

Možnosti operace Vlastnosti sady služeb

Návraty

Data odpovědí pro operaci vlastností sady služeb.

undeleteFileSystem(string, string, ServiceUndeleteFileSystemOptions)

Obnovení dříve odstraněného systému souborů Toto rozhraní API je funkční pouze v případě, že je pro účet úložiště povolené obnovitelné odstranění kontejneru.

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

Parametry

deletedFileSystemName

string

Název zdrojového systému souborů.

deleteFileSystemVersion

string

Nový název systému souborů.

options
ServiceUndeleteFileSystemOptions

Možnosti konfigurace operace obnovení systému souborů

Návraty

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