Skip to content

Commit b7b1fae

Browse files
committed
Update public docs with latest sdk changes
1 parent 2c27e0e commit b7b1fae

File tree

3 files changed

+79
-49
lines changed

3 files changed

+79
-49
lines changed

articles/communication-services/how-tos/router-sdk/azure-function.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ public static class GetPriority
6464
Inspect your deployed function in the Azure portal and locate the function Uri and authentication key. Then use the SDK to configure a policy that uses a rule engine to point to that function.
6565

6666
```csharp
67-
await client.SetClassificationPolicyAsync(
68-
"policy-1",
69-
prioritizationRule: new AzureFunctionRule("<insert function uri>", new AzureFunctionRuleCredential("<insert function key>")));
67+
await client.CreateClassificationPolicyAsync(
68+
options: new CreateClassificationPolicyOptions("policy-1")
69+
{
70+
PrioritizationRule = new AzureFunctionRule("<insert function uri>", new AzureFunctionRuleCredential("<insert function key>"))
71+
}
72+
);
7073
```
7174

7275
When a new job is submitted or updated, this function will be called to determine the priority of the job.

articles/communication-services/how-tos/router-sdk/manage-queue.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,39 @@ This guide outlines the steps to create and manage a Job Router queue.
2929
To create a simple queue in Job Router, use the SDK to specify the **queue ID**, **name**, and a **distribution policy ID**. The distribution policy must be created in advance as the Job Router will validate its existence upon creation of the queue. In the following example, a distribution policy is created to control how Job offers are generated for Workers.
3030

3131
```csharp
32-
var distributionPolicy = await client.SetDistributionPolicyAsync(
33-
id: "Longest_Idle_45s_Min1Max10",
34-
name: "Longest Idle matching with a 45s offer expiration; min 1, max 10 offers",
35-
offerTTL: TimeSpan.FromSeconds(45),
36-
mode: new LongestIdleMode(
37-
minConcurrentOffers: 1,
38-
maxConcurrentOffers: 10)
32+
var distributionPolicy = await administrationClient.CreateDistributionPolicyAsync(
33+
new CreateDistributionPolicyOptions(
34+
distributionPolicyId: "Longest_Idle_45s_Min1Max10",
35+
offerTtl: TimeSpan.FromSeconds(45),
36+
mode: new LongestIdleMode(
37+
minConcurrentOffers: 1,
38+
maxConcurrentOffers: 10)
39+
{
40+
Name = ""Longest Idle matching with a 45s offer expiration; min 1, max 10 offers"
41+
}
3942
);
4043

41-
var queue = await client.SetQueueAsync(
42-
id: "XBOX_DEFAULT_QUEUE",
43-
name: "XBOX Default Queue",
44-
distributionPolicy: "Longest_Idle_45s_Min1Max10"
44+
var queue = await administrationClient.CreateQueue(
45+
options: new CreateQueueOptions("XBOX_DEFAULT_QUEUE", "Longest_Idle_45s_Min1Max10")
46+
{
47+
Name = "XBOX Default Queue"
48+
}
4549
);
4650
```
4751
## Update a queue
4852

49-
The Job Router SDK will create a new queue or update an existing queue when the `SetQueue` or `SetQueueAsync` method is called.
53+
The Job Router SDK will update an existing queue when the `UpdateQueue` or `UpdateQueueAsync` method is called.
5054

5155
```csharp
52-
var queue = await client.SetQueueAsync(
53-
id: "XBOX_DEFAULT_QUEUE",
56+
var queue = await administrationClient.UpdateQueueAsync(
57+
options: new UpdateQueueOptions("XBOX_DEFAULT_QUEUE")
58+
{
59+
Labels = new Dictionary<string, LabelValue>()
60+
{
61+
["Additional-Queue-Label"] = new LabelValue("ChatQueue")
62+
}
63+
});
64+
id: "",
5465
name: "XBOX Default Queue",
5566
distributionPolicy: "Longest_Idle_45s_Min1Max10"
5667
);

articles/communication-services/quickstarts/router/get-started-router.md

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,30 @@ static async Task Main(string[] args)
6262
}
6363
```
6464

65-
## Authenticate the Job Router client
65+
## Authenticate the Job Router clients
6666

6767
Job Router clients can be authenticated using your connection string acquired from an Azure Communication Services resource in the Azure portal.
6868

6969
```csharp
7070
// Get a connection string to our Azure Communication Services resource.
7171
var connectionString = "your_connection_string";
72-
var client = new RouterClient(connectionString);
72+
var routerClient = new RouterClient(connectionString);
73+
var routerAdministrationClient = new RouterAdministrationClient(connectionString);
7374
```
7475

7576
## Create a distribution policy
7677

7778
Job Router uses a distribution policy to decide how Workers will be notified of available Jobs and the time to live for the notifications, known as **Offers**. Create the policy by specifying the **ID**, a **name**, an **offerTTL**, and a distribution **mode**.
7879

7980
```csharp
80-
var distributionPolicy = await routerClient.SetDistributionPolicyAsync(
81-
id: "distribution-policy-1",
82-
name: "My Distribution Policy",
83-
offerTTL: TimeSpan.FromSeconds(30),
84-
mode: new LongestIdleMode()
81+
var distributionPolicy = await routerAdministrationClient.CreateDistributionPolicyAsync(
82+
new CreateDistributionPolicyOptions(
83+
distributionPolicyId: "distribution-policy-1",
84+
offerTtl: TimeSpan.FromMinutes(1),
85+
mode: new LongestIdleMode())
86+
{
87+
Name = "My distribution policy"
88+
}
8589
);
8690
```
8791

@@ -90,10 +94,11 @@ var distributionPolicy = await routerClient.SetDistributionPolicyAsync(
9094
Create the Queue by specifying an **ID**, **name**, and provide the **Distribution Policy** object's ID you created above.
9195

9296
```csharp
93-
var queue = await routerClient.SetQueueAsync(
94-
id: "queue-1",
95-
name: "My Queue",
96-
distributionPolicyId: distributionPolicy.Value.Id
97+
var queue = await routerAdministrationClient.CreateQueueAsync(
98+
options: new CreateQueueOptions("queue-1", distributionPolicy.Value.Id)
99+
{
100+
Name = "My job queue"
101+
}
97102
);
98103
```
99104

@@ -103,34 +108,45 @@ Now, we can submit a job directly to that queue, with a worker selector the requ
103108

104109
```csharp
105110
var job = await routerClient.CreateJobAsync(
106-
channelId: "my-channel",
107-
queueId: queue.Value.Id,
108-
priority: 1,
109-
workerSelectors: new List<LabelSelector>
111+
options: new CreateJobOptions(
112+
jobId: jobId,
113+
channelId: "my-channel",
114+
queueId: queue.Value.Id) // this is optional
110115
{
111-
new LabelSelector(
112-
key: "Some-Skill",
113-
@operator: LabelOperator.GreaterThan,
114-
value: 10)
115-
});
116+
Priority = 1,
117+
RequestedWorkerSelectors = new List<WorkerSelector>
118+
{
119+
new WorkerSelector(
120+
key: "Some-Skill",
121+
labelOperator: LabelOperator.GreaterThan,
122+
value: 10)
123+
}
124+
}
125+
);
116126
```
117127

118-
## Register a worker
128+
## Create a worker
119129

120-
Now, we register a worker to receive work from that queue, with a label of `Some-Skill` equal to 11 and capacity on `my-channel`.
130+
Now, we create a worker to receive work from that queue, with a label of `Some-Skill` equal to 11 and capacity on `my-channel`.
121131

122132
```csharp
123-
var worker = await routerClient.RegisterWorkerAsync(
124-
id: "worker-1",
125-
queueIds: new[] { queue.Value.Id },
126-
totalCapacity: 1,
127-
labels: new LabelCollection()
128-
{
129-
["Some-Skill"] = 11
130-
},
131-
channelConfigurations: new List<ChannelConfiguration>
133+
var worker = await routerClient.CreateWorkerAsync(
134+
new CreateWorkerOptions(
135+
workerId: "worker-1",
136+
totalCapacity: 1)
132137
{
133-
new ChannelConfiguration("my-channel", 1)
138+
QueueIds = new Dictionary<string, QueueAssignment>()
139+
{
140+
[queue.Value.Id] = new QueueAssignment()
141+
},
142+
ChannelConfigurations = new Dictionary<string, ChannelConfiguration>()
143+
{
144+
["my-channel"] = new ChannelConfiguration(1)
145+
},
146+
Labels = new Dictionary<string, LabelValue>()
147+
{
148+
["Some-Skill"] = new LabelValue(11)
149+
}
134150
}
135151
);
136152
```

0 commit comments

Comments
 (0)