@azure-tools/communication-tiering v1.0.0-alpha.20230622.1
Azure Communication Tiering client library for JavaScript
The Tiering client library allows developers to retrieve limits for each capability (SMS/PSTN Calling/Phone Number purchasing) for a specific resource/tier.
Getting started
Prerequisites
- An Azure subscription.
- An existing Communication Services resource. If you need to create the resource, you can use the Azure Portal, the Azure PowerShell, or the Azure CLI.
Installing
npm install @azure-tools/communication-tiering
Browser support
JavaScript Bundle
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our bundling documentation.
Key concepts
Examples
Authentication
To create a client object to access the Communication Services API, you will need a connection string
or the endpoint
of your Communication Services resource and a credential
. The Tiering client can use either Azure Active Directory credentials or an API key credential to authenticate.
You can get a key and/or connection string from your Communication Services resource in the Azure Portal. You can also find the endpoint for your Communication Services resource in the Azure Portal.
Once you have a key, you can authenticate the TieringClient
with any of the following methods:
Using a connection string
const { TieringClient } = require("@azure-tools/communication-tiering");
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
const client = new TieringClient(connectionString);
Using an access key with AzureKeyCredential
If you use a key to initialize the client you will also need to provide the appropriate endpoint. You can get this endpoint from your Communication Services resource in Azure Portal. Once you have a key and endpoint, you can authenticate with the following code:
const { AzureKeyCredential } = require("@azure/core-auth");
const { TieringClient } = require("@azure-tools/communication-tiering");
const credential = new AzureKeyCredential("<key-from-resource>");
const client = new TieringClient("<endpoint-from-resource>", credential);
Using an Azure Active Directory Credential
Connection string authentication is used in most of the examples, but you can also authenticate with Azure Active Directory using the Azure Identity library. To use the DefaultAzureCredential provider shown below, or other credential providers provided with the Azure SDK, please install the @azure/identity
package:
npm install @azure/identity
The @azure/identity
package provides a variety of credential types that your application can use to do this. The README for @azure/identity
provides more details and samples to get you started.
const { DefaultAzureCredential } = require("@azure/identity");
const { TieringClient } = require("@azure-tools/communication-tiering");
let credential = new DefaultAzureCredential();
const client = new TieringClient("<endpoint-from-resource>", credential);
Usage
The following sections provide code snippets that cover some of the common tasks using the Azure Communication Services Tiering Client. The scenarios that are covered here consist of:
Get acquired number limits
import { Tiering } from "@azure-tools/communication-tiering";
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
const client = new Tiering(connectionString);
async main function() {
const resourceId = "5d41e908-de88-4bbf-94dc-fe9a1b51029b";
// Get acquired numbers and limits for a resource
var acquiredNumberLimits = await client.getAcquiredNumberLimits(resourceId);
// print all number limits
console.log(acquiredNumberLimits);
}
main();
Get tier info
import { Tiering } from "@azure-tools/communication-tiering";
const connectionString = "endpoint=<endpoint>;accessKey=<accessKey>";
const client = new Tiering(connectionString);
async main function() {
const resourceId = "5d41e908-de88-4bbf-94dc-fe9a1b51029b";
// Get tier info for a resource
var tierInfo = await client.getTierByResourceId(resourceId);
// print all tier info
console.log(tierInfo);
}
main();
Troubleshooting
Next steps
Please take a look at the samples directory for detailed examples on how to use this library.
Contributing
If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.
Related projects
14 hours ago
2 days ago
5 days ago
9 days ago
11 days ago
15 days ago
16 days ago
17 days ago
18 days ago
19 days ago
1 month ago
2 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
9 months ago
7 months ago
7 months ago
8 months ago
7 months ago
11 months ago