ShareServiceClient class
يمثل ShareServiceClient عنوان URL لخدمة Azure Storage File مما يسمح لك بمعالجة مشاركات الملفات.
- يمتد
-
StorageClient
المنشئون
| Share |
إنشاء مثيل ShareServiceClient. |
| Share |
إنشاء مثيل ShareServiceClient. |
الخصائص الموروثة
| account |
|
| url | قيمة سلسلة عنوان URL. |
الأساليب
| create |
إنشاء مشاركة. |
| delete |
حذف مشاركة. |
| from |
إنشاء مثيل ShareServiceClient من سلسلة الاتصال. |
| generate |
متوفر فقط ل ShareServiceClient الذي تم إنشاؤه باستخدام بيانات اعتماد مفتاح مشترك. إنشاء حساب توقيع الوصول المشترك (SAS) URI استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل. راجع https://learn.microsoft.com/rest/api/storageservices/create-account-sas |
| generate |
متوفر فقط ل ShareServiceClient الذي تم إنشاؤه باستخدام بيانات اعتماد مفتاح مشترك. إنشاء سلسلة لتوقيع حساب توقيع الوصول المشترك (SAS) URI استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل. راجع https://learn.microsoft.com/rest/api/storageservices/create-account-sas |
| get |
يحصل على خصائص خدمة ملفات حساب التخزين، بما في ذلك خصائص قواعد Storage Analytics وCORS (مشاركة الموارد عبر المنشأ). راجع https://learn.microsoft.com/rest/api/storageservices/get-file-service-properties |
| get |
إنشاء كائن ShareClient. |
| get |
متاح فقط عند استخدام مصادقة رمز حامل (TokenCredential). يسترجع مفتاح تفويض المستخدم لخدمة الملفات. هذه عملية صالحة فقط عند استخدام مصادقة الرمز الحامل. راجع https://learn.microsoft.com/rest/api/storageservices/get-user-delegation-key |
| list |
ترجع هذه الدالة مكرر غير متزامن لسرد كافة المشاركات ضمن الحساب المحدد. يقوم .byPage() بإرجاع تكرار غير متزامن لسرد المشاركات في الصفحات. مثال على استخدام بناء جملة
مثال على استخدام
مثال على استخدام
مثال على استخدام الترحيل مع علامة:
|
| set |
تعيين خصائص لنقطة نهاية خدمة ملف حساب التخزين، بما في ذلك خصائص Storage Analytics وقواعد CORS (مشاركة الموارد عبر المنشأ) وإعدادات الحذف المبدئي. راجع https://learn.microsoft.com/rest/api/storageservices/set-file-service-properties |
| undelete |
استعادة مشاركة محذوفة مسبقا. تعمل واجهة برمجة التطبيقات هذه فقط إذا تم تمكين مشاركة الحذف المبدئي لحساب التخزين المقترن بالمشاركة. |
تفاصيل المنشئ
ShareServiceClient(string, Credential | TokenCredential, ShareClientOptions)
إنشاء مثيل ShareServiceClient.
new ShareServiceClient(url: string, credential?: Credential | TokenCredential, options?: ShareClientOptions)
المعلمات
- url
-
string
سلسلة URL تشير إلى خدمة ملفات Azure Storage، مثل "https://myaccount.file.core.windows.net". يمكنك إلحاق SAS إذا كنت تستخدم AnonymousCredential، مثل "https://myaccount.file.core.windows.net?sasString".
- credential
مثل AnonymousCredential أو StorageSharedKeyCredential أو TokenCredential، إذا لم يتم تحديده، يتم استخدام AnonymousCredential.
- options
- ShareClientOptions
Optional. خيارات لتكوين البنية الأساسية لبرنامج ربط العمليات التجارية HTTP.
ShareServiceClient(string, Pipeline, ShareClientConfig)
إنشاء مثيل ShareServiceClient.
new ShareServiceClient(url: string, pipeline: Pipeline, options?: ShareClientConfig)
المعلمات
- url
-
string
سلسلة URL تشير إلى خدمة ملفات Azure Storage، مثل "https://myaccount.file.core.windows.net". يمكنك إلحاق SAS إذا كنت تستخدم AnonymousCredential، مثل "https://myaccount.file.core.windows.net?sasString".
- pipeline
- Pipeline
استدعاء newPipeline() لإنشاء مسار افتراضي، أو توفير مسار مخصص.
- options
- ShareClientConfig
Optional. خيارات لتكوين البنية الأساسية لبرنامج ربط العمليات التجارية 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
سلسلة اتصال الحساب أو سلسلة اتصال SAS لحساب تخزين Azure.
[ ملاحظة - يمكن استخدام سلسلة اتصال الحساب فقط في وقت تشغيل 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 الذي تم إنشاؤه باستخدام بيانات اعتماد مفتاح مشترك.
إنشاء حساب توقيع الوصول المشترك (SAS) URI استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل.
راجع https://learn.microsoft.com/rest/api/storageservices/create-account-sas
function generateAccountSasUrl(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string
المعلمات
- expiresOn
-
Date
Optional. الوقت الذي يصبح فيه توقيع الوصول المشترك غير صالح. افتراضي إلى ساعة لاحقة إذا لم يتم تحديده.
- permissions
- AccountSASPermissions
تحديد قائمة الأذونات التي سيتم اقترانها ب SAS.
- resourceTypes
-
string
تحديد أنواع الموارد المقترنة بتوقيع الوصول المشترك.
المعلمات الاختيارية.
المرتجعات
string
حساب SAS URI يتكون من URI للمورد الذي يمثله هذا العميل، متبوعا بالرمز المميز SAS الذي تم إنشاؤه.
generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)
متوفر فقط ل ShareServiceClient الذي تم إنشاؤه باستخدام بيانات اعتماد مفتاح مشترك.
إنشاء سلسلة لتوقيع حساب توقيع الوصول المشترك (SAS) URI استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل.
راجع https://learn.microsoft.com/rest/api/storageservices/create-account-sas
function generateSasStringToSign(expiresOn?: Date, permissions?: AccountSASPermissions, resourceTypes?: string, options?: ServiceGenerateAccountSasUrlOptions): string
المعلمات
- expiresOn
-
Date
Optional. الوقت الذي يصبح فيه توقيع الوصول المشترك غير صالح. افتراضي إلى ساعة لاحقة إذا لم يتم تحديده.
- permissions
- AccountSASPermissions
تحديد قائمة الأذونات التي سيتم اقترانها ب SAS.
- resourceTypes
-
string
تحديد أنواع الموارد المقترنة بتوقيع الوصول المشترك.
المعلمات الاختيارية.
المرتجعات
string
حساب SAS URI يتكون من URI للمورد الذي يمثله هذا العميل، متبوعا بالرمز المميز SAS الذي تم إنشاؤه.
getProperties(ServiceGetPropertiesOptions)
يحصل على خصائص خدمة ملفات حساب التخزين، بما في ذلك خصائص قواعد Storage Analytics وCORS (مشاركة الموارد عبر المنشأ).
راجع https://learn.microsoft.com/rest/api/storageservices/get-file-service-properties
function getProperties(options?: ServiceGetPropertiesOptions): Promise<ServiceGetPropertiesResponse>
المعلمات
- options
- ServiceGetPropertiesOptions
خيارات للحصول على عملية الخصائص.
المرتجعات
Promise<ServiceGetPropertiesResponse>
بيانات الاستجابة لعملية Get Properties.
getShareClient(string)
إنشاء كائن ShareClient.
function getShareClient(shareName: string): ShareClient
المعلمات
- shareName
-
string
اسم المشاركة.
المرتجعات
كائن ShareClient لاسم المشاركة المحدد.
مثال على الاستخدام:
import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";
const account = "<account>";
const accountKey = "<accountkey>";
const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
`https://${account}.file.core.windows.net`,
credential,
);
const shareName = "<share name>";
const shareClient = serviceClient.getShareClient(shareName);
await shareClient.create();
getUserDelegationKey(Date, Date, ServiceGetUserDelegationKeyOptions)
متاح فقط عند استخدام مصادقة رمز حامل (TokenCredential).
يسترجع مفتاح تفويض المستخدم لخدمة الملفات. هذه عملية صالحة فقط عند استخدام مصادقة الرمز الحامل.
راجع https://learn.microsoft.com/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>
listShares(ServiceListSharesOptions)
ترجع هذه الدالة مكرر غير متزامن لسرد كافة المشاركات ضمن الحساب المحدد.
يقوم .byPage() بإرجاع تكرار غير متزامن لسرد المشاركات في الصفحات.
مثال على استخدام بناء جملة for await:
import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";
const account = "<account>";
const accountKey = "<accountkey>";
const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
`https://${account}.file.core.windows.net`,
credential,
);
let i = 1;
for await (const share of serviceClient.listShares()) {
console.log(`Share${i++}: ${share.name}`);
}
مثال على استخدام iter.next():
import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";
const account = "<account>";
const accountKey = "<accountkey>";
const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
`https://${account}.file.core.windows.net`,
credential,
);
const shareIter = serviceClient.listShares();
let i = 1;
let { value, done } = await shareIter.next();
while (!done) {
console.log(`Share ${i++}: ${value.name}`);
({ value, done } = await shareIter.next());
}
مثال على استخدام byPage():
import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";
const account = "<account>";
const accountKey = "<accountkey>";
const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
`https://${account}.file.core.windows.net`,
credential,
);
let i = 1;
for await (const response of serviceClient.listShares().byPage({ maxPageSize: 20 })) {
console.log(`Page ${i++}:`);
for (const share of response.shareItems || []) {
console.log(`\tShare: ${share.name}`);
}
}
مثال على استخدام الترحيل مع علامة:
import { StorageSharedKeyCredential, ShareServiceClient } from "@azure/storage-file-share";
const account = "<account>";
const accountKey = "<accountkey>";
const credential = new StorageSharedKeyCredential(account, accountKey);
const serviceClient = new ShareServiceClient(
`https://${account}.file.core.windows.net`,
credential,
);
let iterator = serviceClient.listShares().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
for await (const share of response.shareItems || []) {
console.log(`\tShare: ${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;
for await (const share of response.shareItems || []) {
console.log(`\tShare: ${share.name}`);
}
function listShares(options?: ServiceListSharesOptions): PagedAsyncIterableIterator<ShareItem, ServiceListSharesSegmentResponse, PageSettings>
المعلمات
المرتجعات
setProperties(FileServiceProperties, ServiceSetPropertiesOptions)
تعيين خصائص لنقطة نهاية خدمة ملف حساب التخزين، بما في ذلك خصائص Storage Analytics وقواعد CORS (مشاركة الموارد عبر المنشأ) وإعدادات الحذف المبدئي.
راجع https://learn.microsoft.com/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)
استعادة مشاركة محذوفة مسبقا. تعمل واجهة برمجة التطبيقات هذه فقط إذا تم تمكين مشاركة الحذف المبدئي لحساب التخزين المقترن بالمشاركة.
function undeleteShare(deletedShareName: string, deletedShareVersion: string, options?: ServiceUndeleteShareOptions): Promise<ShareClient>
المعلمات
- deletedShareName
-
string
اسم المشاركة المحذوفة مسبقا.
- deletedShareVersion
-
string
إصدار المشاركة المحذوفة مسبقا.
- options
- ServiceUndeleteShareOptions
خيارات لمشاركة عملية إلغاء الحذف.
المرتجعات
Promise<ShareClient>
تمت استعادة المشاركة.