BlobServiceClient class
BlobServiceClient は、Blob コンテナーを操作できる Azure Storage Blob Service へのクライアントを表します。
- Extends
-
StorageClient
コンストラクター
Blob |
BlobServiceClient のインスタンスを作成します。 |
Blob |
BlobServiceClient のインスタンスを作成します。 |
継承されたプロパティ
account |
|
credential | AnonymousCredential、StorageSharedKeyCredential、サービスへの要求を認証するための |
url | エンコードされた URL 文字列値。 |
メソッド
create |
BLOB コンテナーを作成します。 https://learn.microsoft.com/en-us/rest/api/storageservices/create-container を参照してください |
delete |
BLOB コンテナーを削除します。 |
find |
指定したアカウントの下で、指定したタグを持つすべての BLOB を検索する非同期反復可能な反復子を返します。 .byPage() は、ページ内の BLOB を一覧表示する非同期反復可能な反復子を返します。 https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties を参照してください
マーカーでのページングの使用例:
|
from |
接続文字列から BlobServiceClient のインスタンスを作成します。 |
generate |
共有キー資格情報を使用して構築された BlobServiceClient でのみ使用できます。 渡されたクライアントのプロパティとパラメーターに基づいて、BLOB アカウント Shared Access Signature (SAS) URI を生成します。 SAS は、クライアントの共有キー資格情報によって署名されます。 https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas を参照してください |
generate |
共有キー資格情報を使用して構築された BlobServiceClient でのみ使用できます。 渡されたクライアントプロパティとパラメーターに基づいて、BLOB アカウント Shared Access Signature (SAS) URI に署名する文字列を生成します。 SAS は、クライアントの共有キー資格情報によって署名されます。 https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas を参照してください |
get |
アカウント情報の取得操作は、指定されたアカウントの SKU 名とアカウントの種類を返します。 アカウント情報の取得操作は、バージョン 2018-03-28 以降のサービス バージョンで使用できます。 https://learn.microsoft.com/en-us/rest/api/storageservices/get-account-information を参照してください |
get |
バッチ操作を実行する BlobBatchClient オブジェクトを作成します。 https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch を参照してください |
get |
ContainerClient オブジェクトを作成します。 |
get |
ストレージ アカウントの BLOB サービスのプロパティ (Storage Analytics および CORS (クロスオリジン リソース共有) ルールのプロパティを含む) を取得します。 https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties を参照してください |
get |
BLOB サービスのレプリケーションに関連する統計を取得します。 これは、ストレージ アカウントに対して読み取りアクセス geo 冗長レプリケーションが有効になっている場合にのみ、セカンダリ ロケーション エンドポイントで使用できます。 https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-service-stats を参照してください |
get |
ベアラー トークン認証 (TokenCredential) を使用している場合にのみ使用できます。 BLOB サービスのユーザー委任キーを取得します。 これは、ベアラー トークン認証を使用する場合にのみ有効な操作です。 https://learn.microsoft.com/en-us/rest/api/storageservices/get-user-delegation-key を参照してください |
list |
指定したアカウントのすべてのコンテナーを一覧表示する非同期反復可能な反復子を返します。 .byPage() は、ページ内のコンテナーを一覧表示する非同期反復可能な反復子を返します。
マーカーでのページングの使用例:
|
set |
Storage Analytics のプロパティ、CORS (クロスオリジン リソース共有) ルール、論理的な削除設定など、ストレージ アカウントの BLOB サービス エンドポイントのプロパティを設定します。 https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-service-properties を参照してください |
undelete |
以前に削除した BLOB コンテナーを復元します。 この API は、コンテナーに関連付けられているストレージ アカウントに対してコンテナーの論理的な削除が有効になっている場合にのみ機能します。 |
コンストラクターの詳細
BlobServiceClient(string, PipelineLike)
BlobServiceClient のインスタンスを作成します。
new BlobServiceClient(url: string, pipeline: PipelineLike)
パラメーター
- url
-
string
"https://myaccount.blob.core.windows.net" など、Azure Storage BLOB サービスを指すクライアント文字列。 "https://myaccount.blob.core.windows.net?sasString" など、AnonymousCredential を使用している場合は SAS を追加できます。
- pipeline
- PipelineLike
newPipeline() を呼び出して既定のパイプラインを作成するか、カスタマイズされたパイプラインを提供します。
BlobServiceClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions)
BlobServiceClient のインスタンスを作成します。
new BlobServiceClient(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)
パラメーター
- url
-
string
"https://myaccount.blob.core.windows.net" など、Azure Storage BLOB サービスを指すクライアント文字列。 "https://myaccount.blob.core.windows.net?sasString" など、AnonymousCredential を使用している場合は SAS を追加できます。
- credential
-
StorageSharedKeyCredential | AnonymousCredential | TokenCredential
AnonymousCredential、StorageSharedKeyCredential、サービスへの要求を認証するための @azure/identity
パッケージの資格情報など。 TokenCredential インターフェイスを実装するオブジェクトを指定することもできます。 指定しない場合は、AnonymousCredential が使用されます。
- options
- StoragePipelineOptions
随意。 HTTP パイプラインを構成するためのオプション。
@azure/identity
からの DefaultAzureCredential の使用例:
const account = "<storage account name>";
const defaultAzureCredential = new DefaultAzureCredential();
const blobServiceClient = new BlobServiceClient(
`https://${account}.blob.core.windows.net`,
defaultAzureCredential
);
アカウント名/キーの使用例:
const account = "<storage account name>"
const sharedKeyCredential = new StorageSharedKeyCredential(account, "<account key>");
const blobServiceClient = new BlobServiceClient(
`https://${account}.blob.core.windows.net`,
sharedKeyCredential
);
継承されたプロパティの詳細
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 から継承された
メソッドの詳細
createContainer(string, ContainerCreateOptions)
BLOB コンテナーを作成します。
https://learn.microsoft.com/en-us/rest/api/storageservices/create-container を参照してください
function createContainer(containerName: string, options?: ContainerCreateOptions): Promise<{ containerClient: ContainerClient, containerCreateResponse: ContainerCreateResponse }>
パラメーター
- containerName
-
string
作成するコンテナーの名前。
- options
- ContainerCreateOptions
コンテナーの作成操作を構成するためのオプション。
戻り値
Promise<{ containerClient: ContainerClient, containerCreateResponse: ContainerCreateResponse }>
コンテナー作成応答と、対応するコンテナー クライアント。
deleteContainer(string, ContainerDeleteMethodOptions)
BLOB コンテナーを削除します。
function deleteContainer(containerName: string, options?: ContainerDeleteMethodOptions): Promise<ContainerDeleteResponse>
パラメーター
- containerName
-
string
削除するコンテナーの名前。
- options
- ContainerDeleteMethodOptions
コンテナーの削除操作を構成するためのオプション。
戻り値
Promise<ContainerDeleteResponse>
コンテナーの削除応答。
findBlobsByTags(string, ServiceFindBlobByTagsOptions)
指定したアカウントの下で、指定したタグを持つすべての BLOB を検索する非同期反復可能な反復子を返します。
.byPage() は、ページ内の BLOB を一覧表示する非同期反復可能な反復子を返します。
https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties を参照してください
for await
構文の使用例:
let i = 1;
for await (const blob of blobServiceClient.findBlobsByTags("tagkey='tagvalue'")) {
console.log(`Blob ${i++}: ${container.name}`);
}
iter.next()
の使用例:
let i = 1;
const iter = blobServiceClient.findBlobsByTags("tagkey='tagvalue'");
let blobItem = await iter.next();
while (!blobItem.done) {
console.log(`Blob ${i++}: ${blobItem.value.name}`);
blobItem = await iter.next();
}
byPage()
の使用例:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of blobServiceClient.findBlobsByTags("tagkey='tagvalue'").byPage({ maxPageSize: 20 })) {
if (response.blobs) {
for (const blob of response.blobs) {
console.log(`Blob ${i++}: ${blob.name}`);
}
}
}
マーカーでのページングの使用例:
let i = 1;
let iterator = blobServiceClient.findBlobsByTags("tagkey='tagvalue'").byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 blob names
if (response.blobs) {
for (const blob of response.blobs) {
console.log(`Blob ${i++}: ${blob.name}`);
}
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = blobServiceClient
.findBlobsByTags("tagkey='tagvalue'")
.byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints blob names
if (response.blobs) {
for (const blob of response.blobs) {
console.log(`Blob ${i++}: ${blob.name}`);
}
}
function findBlobsByTags(tagFilterSqlExpression: string, options?: ServiceFindBlobByTagsOptions): PagedAsyncIterableIterator<FilterBlobItem, ServiceFindBlobsByTagsSegmentResponse, PageSettings>
パラメーター
- tagFilterSqlExpression
-
string
where パラメーターを使用すると、呼び出し元は、特定の式に一致するタグを持つ BLOB に対してクエリを実行できます。 結果で BLOB を返すには、指定された式が true と評価される必要があります。 [OData - ABNF] フィルター構文規則は、where クエリ パラメーターの値の正式な文法を定義します。ただし、BLOB サービスでは OData フィルター構文のサブセットのみがサポートされます。
- options
- ServiceFindBlobByTagsOptions
タグで BLOB を検索するオプション。
戻り値
fromConnectionString(string, StoragePipelineOptions)
接続文字列から BlobServiceClient のインスタンスを作成します。
static function fromConnectionString(connectionString: string, options?: StoragePipelineOptions): BlobServiceClient
パラメーター
- 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)
共有キー資格情報を使用して構築された BlobServiceClient でのみ使用できます。
渡されたクライアントのプロパティとパラメーターに基づいて、BLOB アカウント Shared Access Signature (SAS) URI を生成します。 SAS は、クライアントの共有キー資格情報によって署名されます。
https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas を参照してください
function generateAccountSasUrl(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string
パラメーター
- expiresOn
-
Date
随意。 Shared Access Signature が無効になる時刻。 指定しない場合、既定値は 1 時間後です。
- permissions
- AccountSASPermissions
SAS に関連付けるアクセス許可の一覧を指定します。
- resourceTypes
-
string
Shared Access Signature に関連付けられているリソースの種類を指定します。
省略可能なパラメーター。
戻り値
string
このクライアントによって表されるリソースへの URI と、生成された SAS トークンで構成されるアカウント SAS URI。
generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)
共有キー資格情報を使用して構築された BlobServiceClient でのみ使用できます。
渡されたクライアントプロパティとパラメーターに基づいて、BLOB アカウント Shared Access Signature (SAS) URI に署名する文字列を生成します。 SAS は、クライアントの共有キー資格情報によって署名されます。
https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas を参照してください
function generateSasStringToSign(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string
パラメーター
- expiresOn
-
Date
随意。 Shared Access Signature が無効になる時刻。 指定しない場合、既定値は 1 時間後です。
- permissions
- AccountSASPermissions
SAS に関連付けるアクセス許可の一覧を指定します。
- resourceTypes
-
string
Shared Access Signature に関連付けられているリソースの種類を指定します。
省略可能なパラメーター。
戻り値
string
このクライアントによって表されるリソースへの URI と、生成された SAS トークンで構成されるアカウント SAS URI。
getAccountInfo(ServiceGetAccountInfoOptions)
アカウント情報の取得操作は、指定されたアカウントの SKU 名とアカウントの種類を返します。 アカウント情報の取得操作は、バージョン 2018-03-28 以降のサービス バージョンで使用できます。
https://learn.microsoft.com/en-us/rest/api/storageservices/get-account-information を参照してください
function getAccountInfo(options?: ServiceGetAccountInfoOptions): Promise<ServiceGetAccountInfoResponse>
パラメーター
- options
- ServiceGetAccountInfoOptions
サービスのアカウント情報の取得操作のオプション。
戻り値
Promise<ServiceGetAccountInfoResponse>
サービスアカウント情報の取得操作の応答データ。
getBlobBatchClient()
バッチ操作を実行する BlobBatchClient オブジェクトを作成します。
https://learn.microsoft.com/en-us/rest/api/storageservices/blob-batch を参照してください
function getBlobBatchClient(): BlobBatchClient
戻り値
このサービスの新しい BlobBatchClient オブジェクト。
getContainerClient(string)
ContainerClient オブジェクトを作成します。
function getContainerClient(containerName: string): ContainerClient
パラメーター
- containerName
-
string
コンテナー名
戻り値
指定されたコンテナー名の新しい ContainerClient オブジェクト。
使用例:
const containerClient = blobServiceClient.getContainerClient("<container name>");
getProperties(ServiceGetPropertiesOptions)
ストレージ アカウントの BLOB サービスのプロパティ (Storage Analytics および CORS (クロスオリジン リソース共有) ルールのプロパティを含む) を取得します。
https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-service-properties を参照してください
function getProperties(options?: ServiceGetPropertiesOptions): Promise<ServiceGetPropertiesResponse>
パラメーター
- options
- ServiceGetPropertiesOptions
サービスのプロパティの取得操作のオプション。
戻り値
Promise<ServiceGetPropertiesResponse>
サービスのプロパティの取得操作の応答データ。
getStatistics(ServiceGetStatisticsOptions)
BLOB サービスのレプリケーションに関連する統計を取得します。 これは、ストレージ アカウントに対して読み取りアクセス geo 冗長レプリケーションが有効になっている場合にのみ、セカンダリ ロケーション エンドポイントで使用できます。
https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-service-stats を参照してください
function getStatistics(options?: ServiceGetStatisticsOptions): Promise<ServiceGetStatisticsResponse>
パラメーター
- options
- ServiceGetStatisticsOptions
Service Get Statistics 操作のオプション。
戻り値
Promise<ServiceGetStatisticsResponse>
Service Get Statistics 操作の応答データ。
getUserDelegationKey(Date, Date, ServiceGetUserDelegationKeyOptions)
ベアラー トークン認証 (TokenCredential) を使用している場合にのみ使用できます。
BLOB サービスのユーザー委任キーを取得します。 これは、ベアラー トークン認証を使用する場合にのみ有効な操作です。
https://learn.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 日以内である必要があります
戻り値
Promise<ServiceGetUserDelegationKeyResponse>
listContainers(ServiceListContainersOptions)
指定したアカウントのすべてのコンテナーを一覧表示する非同期反復可能な反復子を返します。
.byPage() は、ページ内のコンテナーを一覧表示する非同期反復可能な反復子を返します。
for await
構文の使用例:
let i = 1;
for await (const container of blobServiceClient.listContainers()) {
console.log(`Container ${i++}: ${container.name}`);
}
iter.next()
の使用例:
let i = 1;
const iter = blobServiceClient.listContainers();
let containerItem = await iter.next();
while (!containerItem.done) {
console.log(`Container ${i++}: ${containerItem.value.name}`);
containerItem = await iter.next();
}
byPage()
の使用例:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of blobServiceClient.listContainers().byPage({ maxPageSize: 20 })) {
if (response.containerItems) {
for (const container of response.containerItems) {
console.log(`Container ${i++}: ${container.name}`);
}
}
}
マーカーでのページングの使用例:
let i = 1;
let iterator = blobServiceClient.listContainers().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 container names
if (response.containerItems) {
for (const container of response.containerItems) {
console.log(`Container ${i++}: ${container.name}`);
}
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = blobServiceClient
.listContainers()
.byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints 10 container names
if (response.containerItems) {
for (const container of response.containerItems) {
console.log(`Container ${i++}: ${container.name}`);
}
}
function listContainers(options?: ServiceListContainersOptions): PagedAsyncIterableIterator<ContainerItem, ServiceListContainersSegmentResponse, PageSettings>
パラメーター
- options
- ServiceListContainersOptions
コンテナーを一覧表示するオプション。
戻り値
ページングをサポートする asyncIterableIterator。
setProperties(BlobServiceProperties, ServiceSetPropertiesOptions)
Storage Analytics のプロパティ、CORS (クロスオリジン リソース共有) ルール、論理的な削除設定など、ストレージ アカウントの BLOB サービス エンドポイントのプロパティを設定します。
https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-service-properties を参照してください
function setProperties(properties: BlobServiceProperties, options?: ServiceSetPropertiesOptions): Promise<ServiceSetPropertiesResponse>
パラメーター
- properties
- BlobServiceProperties
- options
- ServiceSetPropertiesOptions
サービス セットのプロパティ操作のオプション。
戻り値
Promise<ServiceSetPropertiesResponse>
サービス セットのプロパティ操作の応答データ。
undeleteContainer(string, string, ServiceUndeleteContainerOptions)
以前に削除した BLOB コンテナーを復元します。 この API は、コンテナーに関連付けられているストレージ アカウントに対してコンテナーの論理的な削除が有効になっている場合にのみ機能します。
function undeleteContainer(deletedContainerName: string, deletedContainerVersion: string, options?: ServiceUndeleteContainerOptions): Promise<{ containerClient: ContainerClient, containerUndeleteResponse: ContainerUndeleteResponse }>
パラメーター
- deletedContainerName
-
string
以前に削除されたコンテナーの名前。
- deletedContainerVersion
-
string
以前に削除されたコンテナーのバージョン。削除されたコンテナーを一意に識別するために使用されます。
- options
- ServiceUndeleteContainerOptions
コンテナーの復元操作を構成するためのオプション。
戻り値
Promise<{ containerClient: ContainerClient, containerUndeleteResponse: ContainerUndeleteResponse }>
コンテナーの削除応答。