This package contains a C# SDK for Azure Communication Services for Alpha IDs.
Install the Azure Communication Alpha ID client library for .NET with NuGet:
dotnet add package Azure.Communication.AlphaIds --prerelease
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.
AlphaIdsClient
provides the functionality to manage the usage of Alpha IDs.
Alpha ID clients 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
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.
string endpoint = "<endpoint_url>";
TokenCredential tokenCredential = new DefaultAzureCredential();
tokenCredential = new DefaultAzureCredential();
AlphaIdsClient client = new AlphaIdsClient(new Uri(endpoint), tokenCredential);
To get the current applied configuration, call the GetConfiguration
or GetConfigurationAsync
function from the AlphaIdsClient
.
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");
}
}
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.
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.