مشاركة عبر


QueueServiceClient class

يمثل QueueServiceClient عنوان URL لخدمة Azure Storage Queue مما يسمح لك بمعالجة قوائم الانتظار.

يمتد

StorageClient

المنشئون

QueueServiceClient(string, Pipeline)

إنشاء مثيل QueueServiceClient.

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

إنشاء مثيل QueueServiceClient.

الخصائص الموروثة

accountName
url

قيمة سلسلة عنوان URL.

الأساليب

createQueue(string, QueueCreateOptions)

إنشاء قائمة انتظار جديدة ضمن الحساب المحدد.

راجع https://learn.microsoft.com/rest/api/storageservices/create-queue4

deleteQueue(string, QueueDeleteOptions)

حذف قائمة الانتظار المحددة بشكل دائم.

راجع https://learn.microsoft.com/rest/api/storageservices/delete-queue3

fromConnectionString(string, StoragePipelineOptions)

إنشاء مثيل QueueServiceClient.

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

متوفر فقط ل QueueServiceClient الذي تم إنشاؤه باستخدام بيانات اعتماد مفتاح مشترك.

إنشاء حساب توقيع الوصول المشترك (SAS) URI استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل.

راجع https://learn.microsoft.com/rest/api/storageservices/create-account-sas

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

متوفر فقط ل QueueServiceClient الذي تم إنشاؤه باستخدام بيانات اعتماد مفتاح مشترك.

إنشاء سلسلة لتوقيع حساب توقيع الوصول المشترك (SAS) URI استنادا إلى خصائص العميل والمعلمات التي تم تمريرها. يتم توقيع SAS بواسطة بيانات اعتماد المفتاح المشترك للعميل.

راجع https://learn.microsoft.com/rest/api/storageservices/create-account-sas

getProperties(ServiceGetPropertiesOptions)

يحصل على خصائص خدمة قائمة الانتظار لحساب التخزين، بما في ذلك خصائص قواعد Storage Analytics وCORS (مشاركة الموارد عبر المنشأ).

راجع https://learn.microsoft.com/rest/api/storageservices/get-queue-service-properties

getQueueClient(string)

إنشاء كائن QueueClient.

getStatistics(ServiceGetStatisticsOptions)

استرداد الإحصائيات المتعلقة بالنسخ المتماثل لخدمة قائمة الانتظار. لا يتوفر إلا على نقطة نهاية الموقع الثانوي عند تمكين النسخ المتماثل المتكرر جغرافيا للوصول للقراءة لحساب التخزين.

راجع https://learn.microsoft.com/rest/api/storageservices/get-queue-service-stats

listQueues(ServiceListQueuesOptions)

ترجع هذه الدالة مكرر غير متزامن لسرد جميع قوائم الانتظار ضمن الحساب المحدد.

يقوم .byPage() بإرجاع مكرر غير متزامن قابل للتكريب لسرد قوائم الانتظار في الصفحات.

مثال على استخدام بناء جملة for await:

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
for await (const item of queueServiceClient.listQueues()) {
  console.log(`Queue${i++}: ${item.name}`);
}

مثال على استخدام iter.next():

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
const iterator = queueServiceClient.listQueues();
let { done, value } = await iterator.next();
while (!done) {
  console.log(`Queue${i++}: ${value.name}`);
  ({ done, value } = await iterator.next());
}

مثال على استخدام byPage():

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
for await (const page of queueServiceClient.listQueues().byPage({ maxPageSize: 20 })) {
  for (const item of page.queueItems || []) {
    console.log(`Queue${i++}: ${item.name}`);
  }
}

مثال على استخدام الترحيل مع علامة:

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
let iterator = queueServiceClient.listQueues().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 queues
if (response.queueItems) {
  for (const item of response.queueItems) {
    console.log(`Queue${i++}: ${item.name}`);
  }
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = queueServiceClient.listQueues().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints 10 queues
if (response.queueItems) {
  for (const item of response.queueItems) {
    console.log(`Queue${i++}: ${item.name}`);
  }
}
setProperties(QueueServiceProperties, ServiceGetPropertiesOptions)

تعيين خصائص نقطة نهاية خدمة قائمة الانتظار لحساب التخزين، بما في ذلك خصائص Storage Analytics وقواعد CORS (مشاركة الموارد عبر المنشأ) وإعدادات الحذف المبدئي.

راجع https://learn.microsoft.com/rest/api/storageservices/set-queue-service-properties

تفاصيل المنشئ

QueueServiceClient(string, Pipeline)

إنشاء مثيل QueueServiceClient.

new QueueServiceClient(url: string, pipeline: Pipeline)

المعلمات

url

string

سلسلة URL تشير إلى خدمة قائمة انتظار Azure Storage، مثل "https://myaccount.queue.core.windows.net". يمكنك إلحاق SAS إذا كنت تستخدم AnonymousCredential، مثل "https://myaccount.queue.core.windows.net?sasString".

pipeline
Pipeline

استدعاء newPipeline() لإنشاء مسار افتراضي، أو توفير مسار مخصص.

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

إنشاء مثيل QueueServiceClient.

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

المعلمات

url

string

سلسلة URL تشير إلى خدمة قائمة انتظار Azure Storage، مثل "https://myaccount.queue.core.windows.net". يمكنك إلحاق SAS إذا كنت تستخدم AnonymousCredential، مثل "https://myaccount.queue.core.windows.net?sasString".

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

مثل AnonymousCredential أو StorageSharedKeyCredential أو أي بيانات اعتماد من حزمة @azure/identity لمصادقة الطلبات إلى الخدمة. يمكنك أيضا توفير كائن ينفذ واجهة TokenCredential. إذا لم يتم تحديده، يتم استخدام AnonymousCredential.

options
StoragePipelineOptions

خيارات لتكوين البنية الأساسية لبرنامج ربط العمليات التجارية HTTP.

مثال على استخدام DefaultAzureCredential من @azure/identity:

import { DefaultAzureCredential } from "@azure/identity";
import { QueueServiceClient } from "@azure/storage-queue";

const account = "<account>";
const credential = new DefaultAzureCredential();

const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  credential,
);

مثال على استخدام اسم/مفتاح حساب:

import { StorageSharedKeyCredential, QueueServiceClient } from "@azure/storage-queue";

// Enter your storage account name and shared key
const account = "<account>";
const accountKey = "<accountkey>";

// Use StorageSharedKeyCredential with storage account and account key
// StorageSharedKeyCredential is only available in Node.js runtime, not in browsers
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);

const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  sharedKeyCredential,
  {
    retryOptions: { maxTries: 4 }, // Retry options
    userAgentOptions: {
      userAgentPrefix: "BasicSample V10.0.0",
    }, // Customized telemetry string
  },
);

تفاصيل الخاصية الموروثة

accountName

accountName: string

قيمة الخاصية

string

موروث من StorageClient.accountName

url

قيمة سلسلة عنوان URL.

url: string

قيمة الخاصية

string

موروث من StorageClient.url

تفاصيل الأسلوب

createQueue(string, QueueCreateOptions)

إنشاء قائمة انتظار جديدة ضمن الحساب المحدد.

راجع https://learn.microsoft.com/rest/api/storageservices/create-queue4

function createQueue(queueName: string, options?: QueueCreateOptions): Promise<QueueCreateResponse>

المعلمات

queueName

string

اسم قائمة الانتظار المراد إنشاؤها

options
QueueCreateOptions

خيارات لعملية إنشاء قائمة الانتظار.

المرتجعات

بيانات الاستجابة لعملية إنشاء قائمة الانتظار.

deleteQueue(string, QueueDeleteOptions)

حذف قائمة الانتظار المحددة بشكل دائم.

راجع https://learn.microsoft.com/rest/api/storageservices/delete-queue3

function deleteQueue(queueName: string, options?: QueueDeleteOptions): Promise<QueueDeleteResponse>

المعلمات

queueName

string

اسم قائمة الانتظار المراد حذفها.

options
QueueDeleteOptions

خيارات لعملية حذف قائمة الانتظار.

المرتجعات

بيانات الاستجابة لعملية حذف قائمة الانتظار.

fromConnectionString(string, StoragePipelineOptions)

إنشاء مثيل QueueServiceClient.

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

المعلمات

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
StoragePipelineOptions

خيارات لتكوين البنية الأساسية لبرنامج ربط العمليات التجارية HTTP.

المرتجعات

كائن QueueServiceClient جديد من سلسلة الاتصال المحددة.

generateAccountSasUrl(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

متوفر فقط ل QueueServiceClient الذي تم إنشاؤه باستخدام بيانات اعتماد مفتاح مشترك.

إنشاء حساب توقيع الوصول المشترك (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

تحديد أنواع الموارد المقترنة بتوقيع الوصول المشترك.

options
ServiceGenerateAccountSasUrlOptions

المعلمات الاختيارية.

المرتجعات

string

حساب SAS URI يتكون من URI للمورد الذي يمثله هذا العميل، متبوعا بالرمز المميز SAS الذي تم إنشاؤه.

generateSasStringToSign(Date, AccountSASPermissions, string, ServiceGenerateAccountSasUrlOptions)

متوفر فقط ل QueueServiceClient الذي تم إنشاؤه باستخدام بيانات اعتماد مفتاح مشترك.

إنشاء سلسلة لتوقيع حساب توقيع الوصول المشترك (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

تحديد أنواع الموارد المقترنة بتوقيع الوصول المشترك.

options
ServiceGenerateAccountSasUrlOptions

المعلمات الاختيارية.

المرتجعات

string

حساب SAS URI يتكون من URI للمورد الذي يمثله هذا العميل، متبوعا بالرمز المميز SAS الذي تم إنشاؤه.

getProperties(ServiceGetPropertiesOptions)

يحصل على خصائص خدمة قائمة الانتظار لحساب التخزين، بما في ذلك خصائص قواعد Storage Analytics وCORS (مشاركة الموارد عبر المنشأ).

راجع https://learn.microsoft.com/rest/api/storageservices/get-queue-service-properties

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

المعلمات

options
ServiceGetPropertiesOptions

خيارات للحصول على عملية الخصائص.

المرتجعات

بيانات الاستجابة بما في ذلك خصائص خدمة قائمة الانتظار.

getQueueClient(string)

إنشاء كائن QueueClient.

function getQueueClient(queueName: string): QueueClient

المعلمات

queueName

string

المرتجعات

QueueClient جديد

مثال على الاستخدام:

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

const queueName = "<valid queue name>";
const queueClient = queueServiceClient.getQueueClient(queueName);
const createQueueResponse = await queueClient.create();
console.log(
  `Created queue ${queueName} successfully, service assigned request Id: ${createQueueResponse.requestId}`,
);

getStatistics(ServiceGetStatisticsOptions)

استرداد الإحصائيات المتعلقة بالنسخ المتماثل لخدمة قائمة الانتظار. لا يتوفر إلا على نقطة نهاية الموقع الثانوي عند تمكين النسخ المتماثل المتكرر جغرافيا للوصول للقراءة لحساب التخزين.

راجع https://learn.microsoft.com/rest/api/storageservices/get-queue-service-stats

function getStatistics(options?: ServiceGetStatisticsOptions): Promise<ServiceGetStatisticsResponse>

المعلمات

options
ServiceGetStatisticsOptions

خيارات للحصول على عملية الإحصائيات.

المرتجعات

بيانات الاستجابة للحصول على إحصائيات العملية.

listQueues(ServiceListQueuesOptions)

ترجع هذه الدالة مكرر غير متزامن لسرد جميع قوائم الانتظار ضمن الحساب المحدد.

يقوم .byPage() بإرجاع مكرر غير متزامن قابل للتكريب لسرد قوائم الانتظار في الصفحات.

مثال على استخدام بناء جملة for await:

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
for await (const item of queueServiceClient.listQueues()) {
  console.log(`Queue${i++}: ${item.name}`);
}

مثال على استخدام iter.next():

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
const iterator = queueServiceClient.listQueues();
let { done, value } = await iterator.next();
while (!done) {
  console.log(`Queue${i++}: ${value.name}`);
  ({ done, value } = await iterator.next());
}

مثال على استخدام byPage():

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
for await (const page of queueServiceClient.listQueues().byPage({ maxPageSize: 20 })) {
  for (const item of page.queueItems || []) {
    console.log(`Queue${i++}: ${item.name}`);
  }
}

مثال على استخدام الترحيل مع علامة:

import { QueueServiceClient } from "@azure/storage-queue";
import { DefaultAzureCredential } from "@azure/identity";

const account = "<account>";
const queueServiceClient = new QueueServiceClient(
  `https://${account}.queue.core.windows.net`,
  new DefaultAzureCredential(),
);

let i = 1;
let iterator = queueServiceClient.listQueues().byPage({ maxPageSize: 2 });
let response = (await iterator.next()).value;
// Prints 2 queues
if (response.queueItems) {
  for (const item of response.queueItems) {
    console.log(`Queue${i++}: ${item.name}`);
  }
}
// Gets next marker
let marker = response.continuationToken;
// Passing next marker as continuationToken
iterator = queueServiceClient.listQueues().byPage({ continuationToken: marker, maxPageSize: 10 });
response = (await iterator.next()).value;
// Prints 10 queues
if (response.queueItems) {
  for (const item of response.queueItems) {
    console.log(`Queue${i++}: ${item.name}`);
  }
}
function listQueues(options?: ServiceListQueuesOptions): PagedAsyncIterableIterator<QueueItem, ServiceListQueuesSegmentResponse, PageSettings>

المعلمات

options
ServiceListQueuesOptions

خيارات لسرد عملية قوائم الانتظار.

المرتجعات

asyncIterableIterator يدعم الترحيل.

setProperties(QueueServiceProperties, ServiceGetPropertiesOptions)

تعيين خصائص نقطة نهاية خدمة قائمة الانتظار لحساب التخزين، بما في ذلك خصائص Storage Analytics وقواعد CORS (مشاركة الموارد عبر المنشأ) وإعدادات الحذف المبدئي.

راجع https://learn.microsoft.com/rest/api/storageservices/set-queue-service-properties

function setProperties(properties: QueueServiceProperties, options?: ServiceGetPropertiesOptions): Promise<ServiceSetPropertiesResponse>

المعلمات

options
ServiceGetPropertiesOptions

خيارات لتعيين عملية الخصائص.

المرتجعات

بيانات الاستجابة لعملية تعيين الخصائص.