ShareServiceClient class
ShareServiceClient は、ファイル共有を操作できる Azure Storage ファイル サービスへの URL を表します。
- Extends
-
StorageClient
コンストラクター
Share |
ShareServiceClient のインスタンスを作成します。 |
Share |
ShareServiceClient のインスタンスを作成します。 |
継承されたプロパティ
account |
|
url | URL 文字列値。 |
メソッド
create |
共有を作成します。 |
delete |
共有を削除します。 |
from |
接続文字列から ShareServiceClient のインスタンスを作成します。 |
generate |
共有キー資格情報を使用して構築された ShareServiceClient でのみ使用できます。 渡されたクライアントのプロパティとパラメーターに基づいて、アカウント Shared Access Signature (SAS) URI を生成します。 SAS は、クライアントの共有キー資格情報によって署名されます。 https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas を参照してください |
generate |
共有キー資格情報を使用して構築された ShareServiceClient でのみ使用できます。 渡されたクライアントのプロパティとパラメーターに基づいて、アカウント Shared Access Signature (SAS) URI に署名する文字列を生成します。 SAS は、クライアントの共有キー資格情報によって署名されます。 https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas を参照してください |
get |
Storage Analytics および CORS (クロスオリジン リソース共有) ルールのプロパティを含む、ストレージ アカウントのファイル サービスのプロパティを取得します。 https://learn.microsoft.com/en-us/rest/api/storageservices/get-file-service-properties を参照してください |
get |
ShareClient オブジェクトを作成します。 |
list |
指定したアカウントのすべての共有を一覧表示する非同期反復可能反復子を返します。 .byPage() は、ページ内の共有を一覧表示する非同期反復可能な反復子を返します。
マーカーでのページングの使用例:
|
set |
ストレージ アカウントのファイル サービス エンドポイントのプロパティ (Storage Analytics のプロパティ、CORS (クロスオリジン リソース共有) ルール、論理的な削除設定など) を設定します。 https://learn.microsoft.com/en-us/rest/api/storageservices/set-file-service-properties を参照してください |
undelete |
以前に削除した共有を復元します。 この API は、共有に関連付けられているストレージ アカウントに対して共有論理的な削除が有効になっている場合にのみ機能します。 |
コンストラクターの詳細
ShareServiceClient(string, Credential_2 | TokenCredential, ShareClientOptions)
ShareServiceClient のインスタンスを作成します。
new ShareServiceClient(url: string, credential?: Credential_2 | TokenCredential, options?: ShareClientOptions)
パラメーター
- url
-
string
"https://myaccount.file.core.windows.net" など、Azure Storage ファイル サービスを指す URL 文字列。 "https://myaccount.file.core.windows.net?sasString" など、AnonymousCredential を使用している場合は SAS を追加できます。
- credential
AnonymousCredential、StorageSharedKeyCredential、TokenCredential など、指定されていない場合は AnonymousCredential が使用されます。
- options
- ShareClientOptions
随意。 HTTP パイプラインを構成するためのオプション。
ShareServiceClient(string, Pipeline, ShareClientConfig)
ShareServiceClient のインスタンスを作成します。
new ShareServiceClient(url: string, pipeline: Pipeline, options?: ShareClientConfig)
パラメーター
- url
-
string
"https://myaccount.file.core.windows.net" など、Azure Storage ファイル サービスを指す URL 文字列。 "https://myaccount.file.core.windows.net?sasString" など、AnonymousCredential を使用している場合は SAS を追加できます。
- pipeline
- Pipeline
newPipeline() を呼び出して既定のパイプラインを作成するか、カスタマイズされたパイプラインを提供します。
- options
- ShareClientConfig
随意。 HTTP パイプラインを構成するためのオプション。
継承されたプロパティの詳細
accountName
accountName: string
プロパティ値
string
StorageClient.accountName から継承された
url
URL 文字列値。
url: string
プロパティ値
string
StorageClient.url から継承された
メソッドの詳細
createShare(string, ShareCreateOptions)
共有を作成します。
function createShare(shareName: string, options?: ShareCreateOptions): Promise<{ shareClient: ShareClient, shareCreateResponse: ShareCreateResponse }>
パラメーター
- shareName
-
string
- options
- ShareCreateOptions
戻り値
Promise<{ shareClient: ShareClient, shareCreateResponse: ShareCreateResponse }>
共有作成応答と、対応する共有クライアント。
deleteShare(string, ShareDeleteMethodOptions)
共有を削除します。
function deleteShare(shareName: string, options?: ShareDeleteMethodOptions): Promise<ShareDeleteResponse>
パラメーター
- shareName
-
string
- options
- ShareDeleteMethodOptions
戻り値
Promise<ShareDeleteResponse>
共有削除応答と、対応する共有クライアント。
fromConnectionString(string, ShareClientOptions)
接続文字列から ShareServiceClient のインスタンスを作成します。
static function fromConnectionString(connectionString: string, options?: ShareClientOptions): ShareServiceClient
パラメーター
- 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
- ShareClientOptions
HTTP パイプラインを構成するためのオプション。
戻り値
指定された接続文字列からの新しい ShareServiceClient。
generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)
共有キー資格情報を使用して構築された ShareServiceClient でのみ使用できます。
渡されたクライアントのプロパティとパラメーターに基づいて、アカウント 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)
共有キー資格情報を使用して構築された ShareServiceClient でのみ使用できます。
渡されたクライアントのプロパティとパラメーターに基づいて、アカウント 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。
getProperties(ServiceGetPropertiesOptions)
Storage Analytics および CORS (クロスオリジン リソース共有) ルールのプロパティを含む、ストレージ アカウントのファイル サービスのプロパティを取得します。
https://learn.microsoft.com/en-us/rest/api/storageservices/get-file-service-properties を参照してください
function getProperties(options?: ServiceGetPropertiesOptions): Promise<ServiceGetPropertiesResponse>
パラメーター
- options
- ServiceGetPropertiesOptions
プロパティを取得する操作のオプション。
戻り値
Promise<ServiceGetPropertiesResponse>
プロパティの取得操作の応答データ。
getShareClient(string)
ShareClient オブジェクトを作成します。
function getShareClient(shareName: string): ShareClient
パラメーター
- shareName
-
string
共有の名前。
戻り値
指定された共有名の ShareClient オブジェクト。
使用例:
const shareClient = serviceClient.getShareClient("<share name>");
await shareClient.create();
console.log("Created share successfully!");
listShares(ServiceListSharesOptions)
指定したアカウントのすべての共有を一覧表示する非同期反復可能反復子を返します。
.byPage() は、ページ内の共有を一覧表示する非同期反復可能な反復子を返します。
for await
構文の使用例:
let i = 1;
for await (const share of serviceClient.listShares()) {
console.log(`Share ${i++}: ${share.name}`);
}
iter.next()
の使用例:
let i = 1;
let iter = serviceClient.listShares();
let shareItem = await iter.next();
while (!shareItem.done) {
console.log(`Share ${i++}: ${shareItem.value.name}`);
shareItem = await iter.next();
}
byPage()
の使用例:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const response of serviceClient.listShares().byPage({ maxPageSize: 20 })) {
if (response.shareItems) {
for (const share of response.shareItems) {
console.log(`Share ${i++}: ${share.name}`);
}
}
}
マーカーでのページングの使用例:
let i = 1;
let iterator = serviceClient.listShares().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 share names
if (response.shareItems) {
for (const share of response.shareItems) {
console.log(`Share ${i++}: ${share.name}`);
}
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = serviceClient.listShares().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints 10 share names
if (response.shareItems) {
for (const share of response.shareItems) {
console.log(`Share ${i++}: ${share.name}`);
}
}
function listShares(options?: ServiceListSharesOptions): PagedAsyncIterableIterator<ShareItem, ServiceListSharesSegmentResponse, PageSettings>
パラメーター
戻り値
setProperties(FileServiceProperties, ServiceSetPropertiesOptions)
ストレージ アカウントのファイル サービス エンドポイントのプロパティ (Storage Analytics のプロパティ、CORS (クロスオリジン リソース共有) ルール、論理的な削除設定など) を設定します。
https://learn.microsoft.com/en-us/rest/api/storageservices/set-file-service-properties を参照してください
function setProperties(properties: FileServiceProperties, options?: ServiceSetPropertiesOptions): Promise<ServiceSetPropertiesResponse>
パラメーター
- properties
- FileServiceProperties
- options
- ServiceSetPropertiesOptions
プロパティを設定する操作のオプション。
戻り値
Promise<ServiceSetPropertiesResponse>
プロパティの設定操作の応答データ。
undeleteShare(string, string, ServiceUndeleteShareOptions)
以前に削除した共有を復元します。 この API は、共有に関連付けられているストレージ アカウントに対して共有論理的な削除が有効になっている場合にのみ機能します。
function undeleteShare(deletedShareName: string, deletedShareVersion: string, options?: ServiceUndeleteShareOptions): Promise<ShareClient>
パラメーター
- deletedShareName
-
string
以前に削除された共有の名前。
- deletedShareVersion
-
string
以前に削除された共有のバージョン。
- options
- ServiceUndeleteShareOptions
削除取り消し操作を共有するオプション。
戻り値
Promise<ShareClient>
復元された共有。