Azure Communication CallingServer client library for .NET - version 1.0.0-beta.3

This package contains a C# SDK for Azure Communication Services for Calling.

Source code |Product documentation

Getting started

Install the package

Install the Azure Communication CallingServer client library for .NET with NuGet:

dotnet add package Azure.Communication.CallingServer --version 1.0.0-beta.3

Prerequisites

You need an Azure subscription and a Communication Service Resource to use this package.

To create a new Communication Service, you can use the Azure Portal, the Azure PowerShell, or the .NET management client library.

Key concepts

CallingServerClient provides the functionality to make call connection, join call connection or initialize a server call.

Using statements

using System;
using System.Collections.Generic;
using Azure.Communication.CallingServer;

Authenticate the client

Calling server client can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal.

var connectionString = "<connection_string>"; // Find your Communication Services resource in the Azure portal
CallingServerClient callingServerClient = new CallingServerClient(connectionString);

Or alternatively using a valid Active Directory token.

var endpoint = new Uri("https://my-resource.communication.azure.com");
TokenCredential tokenCredential = new DefaultAzureCredential();
var client = new CallingServerClient(endpoint, tokenCredential);

Examples

Make a call to a phone number recipient

To make an outbound call, call the CreateCallConnection or CreateCallConnectionAsync function from the CallingServerClient.

var createCallOption = new CreateCallOptions(
       new Uri(TestEnvironment.AppCallbackUrl),
       new[] { MediaType.Audio },
       new[]
       {
           EventSubscriptionType.ParticipantsUpdated,
           EventSubscriptionType.DtmfReceived
       });
var callConnection = await callingServerClient.CreateCallConnectionAsync(
    source: new CommunicationUserIdentifier("<source-identifier>"), // Your Azure Communication Resource Guid Id used to make a Call
    targets: new List<CommunicationIdentifier>() { new PhoneNumberIdentifier("<targets-phone-number>") }, // E.164 formatted recipient phone number
    options: createCallOption // The options for creating a call.
    );
Console.WriteLine($"Call connection id: {callConnection.Value.CallConnectionId}");

Troubleshooting

A RequestFailedException is thrown as a service response for any unsuccessful requests. The exception contains information about what response code was returned from the service.

Next steps

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.