你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Job Router Operations - Upsert Worker

创建或更新辅助角色。

PATCH {endpoint}/routing/workers/{workerId}?api-version=2023-11-01

URI 参数

名称 必需 类型 说明
endpoint
path True

string

通信资源的 URI

workerId
path True

string

辅助角色的 ID。

api-version
query True

string

minLength: 1

用于此操作的 API 版本。

请求头

Media Types: "application/merge-patch+json"

名称 必需 类型 说明
If-Match

string

仅当实体与此字符串匹配时,请求才应继续。

If-Unmodified-Since

string (date-time-rfc7231)

仅当此时间之后未修改实体时,请求才应继续。

请求正文

Media Types: "application/merge-patch+json"

名称 类型 说明
availableForOffers

boolean

一个标志,指示此辅助角色已打开以接收产品/服务。

capacity

integer (int32)

此辅助角色必须管理多个并发作业的总容量分数。

channels

RouterChannel[]

此辅助角色可以处理的通道集合及其对辅助角色容量的影响。

labels

一组键/值对,用于标识规则引擎用于做出决策的属性。 值必须是基元值 - number、string、boolean 类型的值。

queues

string[]

此工作线程可从中接收工作的队列集合。

tags

附加到此辅助角色的一组非标识属性。 值必须是基元值 - number、string、boolean 类型的值。

响应

名称 类型 说明
200 OK

RouterWorker

请求已成功。

标头

  • ETag: string
  • Last-Modified: string
201 Created

RouterWorker

请求已成功,因此创建了一个新资源。

标头

  • ETag: string
  • Last-Modified: string
Other Status Codes

Azure.Core.Foundations.ErrorResponse

意外的错误响应。

标头

x-ms-error-code: string

安全性

AadOauth2Auth

Azure Active Directory OAuth2 流

类型: oauth2
流向: accessCode
授权 URL: https://login.microsoftonline.com/common/oauth2/authorize
令牌 URL: https://login.microsoftonline.com/common/oauth2/token

作用域

名称 说明
https://communication.azure.com/.default

示例

Creates a worker
De-register an active worker
De-register an inactive worker
Register a worker
Updates a worker

Creates a worker

示例请求

PATCH https://contoso.westus.communications.azure.com/routing/workers/WorkerId?api-version=2023-11-01

{
  "capacity": 10,
  "queues": [
    "MainQueue"
  ],
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "availableForOffers": false
}

示例响应

{
  "id": "WorkerId",
  "state": "inactive",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": false,
  "etag": "etag"
}
{
  "id": "WorkerId",
  "state": "inactive",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": false,
  "etag": "etag"
}

De-register an active worker

示例请求

PATCH https://contoso.westus.communications.azure.com/routing/workers/WorkerId?api-version=2023-11-01

{
  "availableForOffers": false,
  "capacity": 10
}

示例响应

{
  "id": "WorkerId",
  "state": "draining",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": false,
  "etag": "etag"
}
{
  "id": "WorkerId",
  "state": "draining",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": false,
  "etag": "etag"
}

De-register an inactive worker

示例请求

PATCH https://contoso.westus.communications.azure.com/routing/workers/WorkerId?api-version=2023-11-01

{
  "availableForOffers": false,
  "capacity": 10
}

示例响应

{
  "id": "WorkerId",
  "state": "inactive",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": false,
  "etag": "etag"
}
{
  "id": "WorkerId",
  "state": "inactive",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": false,
  "etag": "etag"
}

Register a worker

示例请求

PATCH https://contoso.westus.communications.azure.com/routing/workers/WorkerId?api-version=2023-11-01

{
  "availableForOffers": true,
  "capacity": 10
}

示例响应

{
  "id": "WorkerId",
  "state": "active",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": true,
  "etag": "etag"
}
{
  "id": "WorkerId",
  "state": "active",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": true,
  "etag": "etag"
}

Updates a worker

示例请求

PATCH https://contoso.westus.communications.azure.com/routing/workers/WorkerId?api-version=2023-11-01

{
  "capacity": 10,
  "queues": [
    "MainQueue",
    "SecondaryQueue"
  ],
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "availableForOffers": false
}

示例响应

{
  "id": "WorkerId",
  "state": "inactive",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": false,
  "etag": "etag"
}
{
  "id": "WorkerId",
  "state": "inactive",
  "queues": [
    "MainQueue"
  ],
  "capacity": 10,
  "labels": {},
  "tags": {},
  "channels": [
    {
      "channelId": "CustomChatChannel",
      "capacityCostPerJob": 11,
      "maxNumberOfJobs": 4
    },
    {
      "channelId": "CustomVoiceChannel",
      "capacityCostPerJob": 10,
      "maxNumberOfJobs": 1
    }
  ],
  "offers": [],
  "assignedJobs": [],
  "loadRatio": 0,
  "availableForOffers": false,
  "etag": "etag"
}

定义

名称 说明
Azure.Core.Foundations.Error

错误对象。

Azure.Core.Foundations.ErrorResponse

包含错误详细信息的响应。

Azure.Core.Foundations.InnerError

包含有关错误的更具体信息的对象。 根据Microsoft一个 API 指南 - https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#handling-errors

RouterChannel

表示此通道中作业将从辅助角色消耗的容量。

RouterJobOffer

向辅助角色提供工作。

RouterWorker

要路由到的作业的实体。

RouterWorkerAssignment

工作线程的工作分配。

RouterWorkerCreateOrUpdate

要路由到的作业的实体。

RouterWorkerState

辅助角色状态的枚举。

Azure.Core.Foundations.Error

错误对象。

名称 类型 说明
code

string

服务器定义的错误代码集之一。

details

Azure.Core.Foundations.Error[]

导致此报告错误的特定错误的详细信息数组。

innererror

Azure.Core.Foundations.InnerError

包含与当前对象有关错误的更具体信息的对象。

message

string

错误的人工可读表示形式。

target

string

错误的目标。

Azure.Core.Foundations.ErrorResponse

包含错误详细信息的响应。

名称 类型 说明
error

Azure.Core.Foundations.Error

错误对象。

Azure.Core.Foundations.InnerError

包含有关错误的更具体信息的对象。 根据Microsoft一个 API 指南 - https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#handling-errors

名称 类型 说明
code

string

服务器定义的错误代码集之一。

innererror

Azure.Core.Foundations.InnerError

内部错误。

RouterChannel

表示此通道中作业将从辅助角色消耗的容量。

名称 类型 说明
capacityCostPerJob

integer (int32)

此通道的作业实例消耗的总辅助角色容量的容量量。

channelId

string

通道的 ID。

maxNumberOfJobs

integer (int32)

此通道可同时支持的最大作业数。 值必须大于零。

RouterJobOffer

向辅助角色提供工作。

名称 类型 说明
capacityCost

integer (int32)

作业产品/服务消耗的容量成本。

expiresAt

string (date-time)

产品/服务将以 UTC 格式过期时的时间戳。

jobId

string

作业的 ID。

offerId

string

产品/服务的 ID。

offeredAt

string (date-time)

在 UTC 中创建产品/服务的时间戳。

RouterWorker

要路由到的作业的实体。

名称 类型 说明
assignedJobs

RouterWorkerAssignment[]

附加到此辅助角色的已分配作业的列表。

availableForOffers

boolean

一个标志,指示此辅助角色已打开以接收产品/服务。

capacity

integer (int32)

此辅助角色必须管理多个并发作业的总容量分数。

channels

RouterChannel[]

此辅助角色可以处理的通道集合及其对辅助角色容量的影响。

etag

string

此资源的实体标记。

id

string

辅助角色的 ID。

labels

一组键/值对,用于标识规则引擎用于做出决策的属性。 值必须是基元值 - number、string、boolean 类型的值。

loadRatio

number (double)

指示辅助角色容量的值。 值为“1”表示使用所有容量。 值为“0”表示当前未使用任何容量。

offers

RouterJobOffer[]

向此辅助角色颁发的活动产品/服务列表。

queues

string[]

此工作线程可从中接收工作的队列集合。

state

RouterWorkerState

辅助角色的当前状态。

tags

附加到此辅助角色的一组非标识属性。 值必须是基元值 - number、string、boolean 类型的值。

RouterWorkerAssignment

工作线程的工作分配。

名称 类型 说明
assignedAt

string (date-time)

作业的分配时间(UTC)。

assignmentId

string

工作分配的 ID。

capacityCost

integer (int32)

此分配在辅助角色上消耗的容量量。

jobId

string

分配的作业的 ID。

RouterWorkerCreateOrUpdate

要路由到的作业的实体。

名称 类型 说明
availableForOffers

boolean

一个标志,指示此辅助角色已打开以接收产品/服务。

capacity

integer (int32)

此辅助角色必须管理多个并发作业的总容量分数。

channels

RouterChannel[]

此辅助角色可以处理的通道集合及其对辅助角色容量的影响。

labels

一组键/值对,用于标识规则引擎用于做出决策的属性。 值必须是基元值 - number、string、boolean 类型的值。

queues

string[]

此工作线程可从中接收工作的队列集合。

tags

附加到此辅助角色的一组非标识属性。 值必须是基元值 - number、string、boolean 类型的值。

RouterWorkerState

辅助角色状态的枚举。

说明
active

辅助角色处于活动状态,可用于获取产品/服务。

draining

如果存在现有产品/服务,则辅助角色不会处于活动状态。 未发送任何新产品/服务。

inactive

辅助角色未处于活动状态。 未发送任何新产品/服务。