Back to Azure Sdk For

Azure Communication Alpha ID client library for .NET

sdk/communication/Azure.Communication.AlphaIds/README.md

2019-05-16T16-524.1 KB
Original Source

Azure Communication Alpha ID client library for .NET

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

Getting started

Install the package

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

dotnetcli
dotnet add package Azure.Communication.AlphaIds --prerelease

Prerequisites

You need an Azure subscription, a Communication Service Resource.

To create these resource, you can use the Azure Portal, the Azure PowerShell, or the .NET management client library.

Key concepts

AlphaIdsClient provides the functionality to manage the usage of Alpha IDs.

Authenticate the client

Alpha ID clients can be authenticated using the connection string acquired from an Azure Communication Resource in the Azure Portal.

C#
var connectionString = "<connection_string>"; // Find your Communication Services resource in the Azure portal
AlphaIdsClient client = new AlphaIdsClient(connectionString);

Alternatively, Alpha Ids clients can also be authenticated using a valid token credential. With this option, AZURE_CLIENT_SECRET, AZURE_CLIENT_ID and AZURE_TENANT_ID environment variables need to be set up for authentication.

C#
string endpoint = "<endpoint_url>";
TokenCredential tokenCredential = new DefaultAzureCredential();
tokenCredential = new DefaultAzureCredential();
AlphaIdsClient client = new AlphaIdsClient(new Uri(endpoint), tokenCredential);

Examples

Get configuration

To get the current applied configuration, call the GetConfiguration or GetConfigurationAsync function from the AlphaIdsClient.

C#
try
{
    AlphaIdConfiguration configuration = await client.GetConfigurationAsync();

    Console.WriteLine($"The usage of Alpha IDs is currently {(configuration.Enabled ? "enabled" : "disabled")}");
}
catch (RequestFailedException ex)
{
    if (ex.Status == 403)
    {
        Console.WriteLine("Resource is not eligible for Alpha ID usage");
    }
}

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 [email protected] with any additional questions or comments.

<!-- LINKS -->