-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3133279 Direct routing GA - Quick Starts (#79)
* #3133279 Direct routing GA - Quick Starts Add Quick Start code for dotnet * #3133279 Direct routing GA - Quick Starts correction * #3133279 Direct routing GA - Quick Starts correction * #3133279 Direct routing GA - Quick Starts Remove VS installation dependency * #3133279 Direct routing GA - Quick Starts Remove white-space --------- Co-authored-by: Nikita Kuklich <[email protected]>
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Communication.PhoneNumbers" Version="1.1.0-beta.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Azure.Communication.PhoneNumbers.SipRouting; | ||
|
||
var connectionString = "endpoint=https://<RESOURCE_NAME>.communication.azure.com/;accesskey=<ACCESS_KEY>"; | ||
var client = new SipRoutingClient(connectionString); | ||
|
||
var usSbcFqdn = "sbc.us.contoso.com"; | ||
var euSbcFqdn = "sbc.eu.contoso.com"; | ||
var sbcPort = 1234; | ||
var usTrunk = new SipTrunk(usSbcFqdn, sbcPort); | ||
var euTrunk = new SipTrunk(euSbcFqdn, sbcPort); | ||
|
||
var response = await client.SetTrunksAsync(new List<SipTrunk> { usTrunk, euTrunk }); | ||
|
||
Console.WriteLine($"SetTrunks operation result: { response.Status }.{Environment.NewLine}Trunks: { response.Content }"); | ||
|
||
var usRoute = new SipTrunkRoute("UsRoute", "^\\+1(\\d{10})$", trunks: new List<string> { usSbcFqdn }); | ||
var defaultRoute = new SipTrunkRoute("DefaultRoute", "^\\+\\d+$", trunks: new List<string> { usSbcFqdn, euSbcFqdn }); | ||
|
||
response = await client.SetRoutesAsync(new List<SipTrunkRoute> { usRoute, defaultRoute }); | ||
|
||
Console.WriteLine($"SetRoutes operation result: {response.Status}.{Environment.NewLine}Routes: {response.Content}"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
page_type: sample | ||
languages: | ||
- csharp | ||
products: | ||
- azure | ||
- azure-communication-services | ||
--- | ||
|
||
|
||
# Direct Routing Configuration | ||
|
||
For full instructions on how to build this code sample from scratch, look at [Quickstart: Direct Routing](https://docs.microsoft.com/azure/communication-services/quickstarts/telephony-sms/voice-routing-sdk-config?pivots=programming-language-csharp) | ||
|
||
## Prerequisites | ||
|
||
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). | ||
- The latest version [.NET Core client library](https://dotnet.microsoft.com/download/dotnet-core) for your operating system. | ||
- An active Communication Services resource and connection string. [Create a Communication Services resource](https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-net). | ||
|
||
## Code Structure | ||
|
||
- **./DirectRouting/Program.cs:** Core application code with manage phone numbers implementation. | ||
- **./DirectRouting/DirectRouting.csproj:** Project configuration file. | ||
|
||
## Before running sample code | ||
|
||
1. Open an instance of PowerShell, Windows Terminal, Command Prompt or equivalent and navigate to the directory that you'd like to clone the sample to. | ||
2. `git clone https://github.com/Azure-Samples/Communication-Services-dotnet-quickstarts.git` | ||
3. With the `Connection String` procured in pre-requisites, add it to the **DirectRouting/program.cs** file. Assign your connection string in line 3: | ||
```csharp | ||
var connectionString = "endpoint=https://<RESOURCE_NAME>.communication.azure.com/;accesskey=<ACCESS_KEY>"; | ||
``` | ||
|
||
## Run Locally | ||
|
||
```console | ||
dotnet run | ||
``` |