You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: A quickstart on how to use Number Management C# SDK to configure direct routing.
3
+
description: Learn how to use the Number Management C# SDK to configure direct routing.
4
4
services: azure-communication-services
5
5
author: boris-bazilevskiy
6
6
@@ -16,24 +16,27 @@ ms.author: nikuklic
16
16
17
17
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
18
18
- An active Communication Services resource and connection string. [Create a Communication Services resource](../../create-communication-resource.md).
19
-
- The latest version [.NET Core client library](https://dotnet.microsoft.com/download/dotnet-core) for your operating system.
20
-
-Fully Qualified Domain Name (FQDN) and port number of a Session Border Controller (SBC) in operational telephony system.
21
-
-[Verified domain name](../../../how-tos/telephony/domain-validation.md) of the SBC FQDN.
19
+
- The latest version of the [.NET Core client library](https://dotnet.microsoft.com/download/dotnet-core) for your operating system.
20
+
-The fully qualified domain name (FQDN) and port number of a session border controller (SBC) in an operational telephony system.
21
+
-The [verified domain name](../../../how-tos/telephony/domain-validation.md) of the SBC FQDN.
22
22
23
23
## Final code
24
24
25
-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/DirectRouting)
25
+
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/DirectRouting).
26
26
27
-
## Create a new C# application
27
+
You can also find more usage examples for `SipRoutingClient` on [GitHub](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/communication/Azure.Communication.PhoneNumbers/README.md#siproutingclient).
28
28
29
-
In a console window (such as cmd, PowerShell, or Bash), use the `dotnet new` command to create a new console app.
29
+
## Create a C# application
30
+
31
+
In a console window (such as Command Prompt, PowerShell, or Bash), use the `dotnet new` command to create a new console app:
30
32
31
33
```console
32
34
dotnet new console -o DirectRoutingQuickstart
33
35
```
34
36
35
-
This command creates a simple "Hello World" C# project with a single source file: **Program.cs**.
36
-
Change your directory to the newly created app folder and use the dotnet build command to compile your application.
37
+
This command creates a simple "Hello World" C# project with a single source file: *Program.cs*.
38
+
39
+
Change your directory to the newly created app folder, and use the `dotnet build` command to compile your application:
37
40
38
41
```console
39
42
cd DirectRoutingQuickstart
@@ -42,39 +45,35 @@ Change your directory to the newly created app folder and use the dotnet build c
42
45
43
46
## Install the package
44
47
45
-
While still in the application directory, install the Azure Communication PhoneNumbers client library for .NET package by using the dotnet add package command.
48
+
While you're still in the application directory, install the Azure Communication PhoneNumbers client library for .NET package by using the `dotnet add package` command:
Add a using directive to the top of **Program.cs** to include the namespaces.
54
+
Add a `using` directive to the top of *Program.cs* to include the namespaces:
52
55
53
56
```csharp
54
57
usingAzure.Communication.PhoneNumbers.SipRouting;
55
58
```
56
59
57
60
## Authenticate the client
58
61
59
-
Phone Number clients can be authenticated using [connection string from an Azure Communication Services resource](../../create-communication-resource.md#access-your-connection-strings-and-service-endpoints).
62
+
Authenticate phone number clients by using a [connection string from an Azure Communication Services resource](../../create-communication-resource.md#access-your-connection-strings-and-service-endpoints):
60
63
61
64
```csharp
62
-
// Get a connection string to our Azure Communication Services resource.
65
+
// Get a connection string to the Azure Communication Services resource.
63
66
varconnectionString="<connection_string>";
64
67
varclient=newSipRoutingClient(connectionString);
65
68
```
66
69
67
-
## Setup direct routing configuration
70
+
## Set up a direct routing configuration
68
71
69
-
Direct routing configuration consists of:
72
+
In the [prerequisites](#prerequisites), you verified domain ownership. The next steps are to create trunks (add SBCs) and create voice routes.
70
73
71
-
1. Domain ownership verification - see [prerequisites](#prerequisites)
72
-
1. Creating trunks (adding SBCs)
73
-
1. Creating voice routes
74
+
### Create or update trunks
74
75
75
-
### Create or update Trunks
76
-
77
-
Azure Communication Services direct routing allows communication with registered SBCs only. To register an SBC you need its FQDN and port.
76
+
Azure Communication Services direct routing allows communication with registered SBCs only. To register an SBC, you need its FQDN and port:
78
77
79
78
```csharp
80
79
// Register your SBCs by providing their fully qualified domain names and port numbers.
> Order of routes does matter, as it determines priority of routes. The first route that matches the regex will be picked for a call.
92
+
Provide routing rules for outbound calls. Each rule consists of two parts: a regex pattern that should match a dialed phone number, and the FQDN of a registered trunk where the call is routed.
93
+
94
+
The order of routes determines the priority of routes. The first route that matches the regex will be picked for a call.
95
95
96
-
For outbound calling routing rules should be provided. Each rule consists of two parts: regex pattern that should match dialed phone number and FQDN of a registered trunk where call is routed. In this example, we create one route for numbers that start with `+1` and a second route for numbers that start with just `+`
96
+
In this example, you create one route for numbers that start with `+1` and a second route for numbers that start with just `+`:
>The same method is used to create and update routing rules. When updating routes, all routes should be sent in single update and routing configuration will be fully overwritten by the new one.
114
+
You use the same method to create and update routing rules. When you update routes, send all of them in a single update. The new routing configuration fully overwrites the former one.
116
115
117
-
### Removing a direct routing configuration
116
+
##Remove a direct routing configuration
118
117
119
-
You can't edit or remove single voice route. Entire voice routing configuration should be overwritten. Here's the example of an empty list that removes all the routes and trunks:
118
+
You can't edit or remove a single voice route. You should overwrite the entire voice routing configuration. Here's an example of an empty list that removes all the routes and trunks:
You can delete a single trunk (SBC), if it isn't used in any voice route. If SBC is listed in any voice route, that route should be deleted first.
128
+
You can use the following example to delete a single trunk (SBC), if no voice routes are using it. If the SBC is listed in any voice route, delete that route first.
<!-- All direct routing configuration can be deleted by overriding routes and trunks configuration with a new configuration or an empty list. Same methods are used in "Create or Update Trunks" and "Create or Update Routes" sections. -->
136
-
137
-
> [!NOTE]
138
-
> More usage examples for SipRoutingClient can be found [here](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/communication/Azure.Communication.PhoneNumbers/README.md#siproutingclient).
- A deployed Communication Services resource and connection string. [Create a Communication Services resource](../../create-communication-resource.md).
21
-
-Fully Qualified Domain Name (FQDN) and port number of a Session Border Controller (SBC) in operational telephony system.
22
-
-[Verified domain name](../../../how-tos/telephony/domain-validation.md) of the SBC FQDN.
21
+
-The fully qualified domain name (FQDN) and port number of a session border controller (SBC) in an operational telephony system.
22
+
-The [verified domain name](../../../how-tos/telephony/domain-validation.md) of the SBC FQDN.
23
23
24
24
## Final code
25
25
26
-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-java-quickstarts/tree/main/DirectRouting)
26
+
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-java-quickstarts/tree/main/DirectRouting).
27
27
28
-
## Setting Up
28
+
You can also find more usage examples for `SipRoutingClient` on [GitHub](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/communication/azure-communication-phonenumbers/src/samples/java/com/azure/communication/phonenumbers/siprouting/AsyncClientJavaDocCodeSnippets.java).
29
29
30
-
###Create a new Java application
30
+
## Create a Java application
31
31
32
-
Open your terminal or command window. Navigate to the directory where you'd like to create your Java application. Run the command to generate the Java project from the maven-archetype-quickstart template.
32
+
Open your terminal or command window. Go to the directory where you want to create your Java application. Then, run the command to generate the Java project from the *maven-archetype-quickstart* template:
You notice that the 'generate' task created a directory with the same name as the `artifactId`. Under this directory, the src/main/java directory contains the project source code, the `src/test/java directory` contains the test source, and the **pom.xml** file is the project's Project Object Model, or POM.
38
+
The `generate` task created a directory with the same name as the `artifactId` value. Under this directory, the *src/main/java* directory contains the project source code, the *src/test/java* directory contains the test source, and the *pom.xml* file is the project's Project Object Model, or POM.
39
39
40
-
###Install the package
40
+
## Install the package
41
41
42
-
Open the **pom.xml** file in your text editor. Add the following dependency elements to the group of dependencies.
42
+
Open the *pom.xml* file in your text editor. Add the following dependency elements to the group of dependencies:
43
43
44
44
```xml
45
45
<dependencies>
@@ -51,14 +51,14 @@ Open the **pom.xml** file in your text editor. Add the following dependency elem
51
51
</dependencies>
52
52
```
53
53
54
-
###Set up the app framework
54
+
## Set up the app framework
55
55
56
56
From the project directory:
57
57
58
-
1.Navigate to the */src/main/java/com/communication/quickstart* directory
59
-
1. Open the **App.java** file in your editor
58
+
1.Go to the */src/main/java/com/communication/quickstart* directory.
59
+
1. Open the *App.java* file in your editor.
60
60
1. Replace the `System.out.println("Hello world!");` statement
61
-
1. Add `import` directives
61
+
1. Add `import` directives.
62
62
63
63
Use the following code to begin:
64
64
@@ -81,7 +81,7 @@ public class App
81
81
82
82
## Authenticate the client
83
83
84
-
The SipRoutingClientBuilder is enabled to use Azure Active Directory Authentication
84
+
With `SipRoutingClientBuilder`, you can use Azure Active Directory authentication:
85
85
86
86
```java
87
87
// You can find your endpoint and access key from your resource in the Azure portal
@@ -93,7 +93,7 @@ SipRoutingAsyncClient sipRoutingAsyncClient = new SipRoutingClientBuilder()
93
93
.buildClient();
94
94
```
95
95
96
-
Alternatively, use the endpoint and access key from the communication resource to authenticate.
96
+
Alternatively, use the endpoint and access key from the communication resource to authenticate:
97
97
98
98
```java
99
99
// You can find your connection string from your resource in the Azure portal
@@ -104,17 +104,13 @@ SipRoutingAsyncClient sipRoutingAsyncClient = new SipRoutingClientBuilder()
104
104
.buildClient();
105
105
```
106
106
107
-
## Setup direct routing configuration
107
+
## Set up a direct routing configuration
108
108
109
-
Direct routing configuration consists of:
109
+
In the [prerequisites](#prerequisites), you verified domain ownership. The next steps are to create trunks (add SBCs) and create voice routes.
110
110
111
-
- Domain ownership verification - see [prerequisites](#prerequisites)
112
-
- Creating trunks (adding SBCs)
113
-
- Creating voice routes
111
+
### Create or update trunks
114
112
115
-
### Create or Update Trunks
116
-
117
-
Azure Communication Services direct routing allows communication with registered SBCs only. To register an SBC, you need its FQDN and port.
113
+
Azure Communication Services direct routing allows communication with registered SBCs only. To register an SBC, you need its FQDN and port:
Provide routing rules for outbound calls. Each rule consists of two parts: a regex pattern that should match a dialed phone number, and the FQDN of a registered trunk where the call is routed.
127
125
128
-
> [!NOTE]
129
-
> Order of routes does matter, as it determines priority of routes. The first route that matches the regex will be picked for a call.
126
+
The order of routes determines the priority of routes. The first route that matches the regex will be picked for a call.
130
127
131
-
For outbound calling routing rules should be provided. Each rule consists of two parts: regex pattern that should match dialed phone number and FQDN of a registered trunk where call is routed. In this example, we create one route for numbers that start with `+1` and a second route for numbers that start with just `+`.
128
+
In this example, you create one route for numbers that start with `+1` and a second route for numbers that start with just `+`:
>The same method is used to create and update routing rules. When updating routes, all routes should be sent in single update and routing configuration will be fully overwritten by the new one.
145
+
You use the same method to create and update routing rules. When you update routes, send all of them in a single update. The new routing configuration fully overwrites the former one.
150
146
151
-
### Removing a direct routing configuration
147
+
##Remove a direct routing configuration
152
148
153
-
You can't edit or remove single voice route. Entire voice routing configuration should be overwritten. Here's the example of an empty list that removes all the routes and trunks:
149
+
You can't edit or remove a single voice route. You should overwrite the entire voice routing configuration. Here's an example of an empty list that removes all the routes and trunks.
154
150
155
-
Add 2 imports:
151
+
Add two imports:
156
152
157
153
```java
158
154
importjava.util.Collections;
159
155
importjava.util.List;
160
156
```
161
157
162
-
Code to Delete Direct Routing config:
158
+
Use the following code to delete a direct routing configuration:
You can delete a single trunk (SBC), if it isn't used in any voice route. If SBC is listed in any voice route, that route should be deleted first.
172
+
You can use the following example to delete a single trunk (SBC), if no voice routes are using it. If the SBC is listed in any voice route, delete that route first.
> More usage examples for SipRoutingClient can be found [here](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/communication/azure-communication-phonenumbers/src/samples/java/com/azure/communication/phonenumbers/siprouting/AsyncClientJavaDocCodeSnippets.java).
0 commit comments