Skip to content

Commit 2d8794d

Browse files
sofiar-msftdanielortega-msftazure-sdk
authored
Release/azure communication phone numbers 1.4.0 (Azure#50312)
* Phonenumbers/reservations api (Azure#49637) * WIP: generate autorest client for API 2025-04-01 * Regenerate with latest spec * WIP: Add new methods for phonenumbers API 2025-04-01 * Revert commented out tests * Rename and regenerate code to match convention * Add tests for reservations * Update tests, use latest rest api spec for autorest * Use reservation object as input for create or update method * Add tests for Agreement to not resell and reservation purchase * minor update * Update tests, generate recordings * Remove time-sensitive assertions when in playback mode * Update recordings * Add convenience methods to reservation model * Update Reservation constructor * minor fix * Address feedback * Address feedback from SDK review * Remove remaining setters for ctor properties, update browse method to return object instead of list * update public API * update readme and changelog * Add cherry picker samples * fix readme * Update client and model descriptions * Fix CI * remove models namespace * update readme with PR suggestion * Add date to beta version changelog (Azure#50189) * Increment package version after release of Azure.Communication.PhoneNumbers (Azure#50190) * Add stable version to CHANGELOG * Remove unwanted changelog version * Update csproj * Empty commit * Empty commit * Refactor browsing description on README * Add dnr to changelog --------- Co-authored-by: Daniel Ortega <[email protected]> Co-authored-by: Azure SDK Bot <[email protected]>
1 parent a1ac75f commit 2d8794d

File tree

54 files changed

+3580
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3580
-51
lines changed

sdk/communication/Azure.Communication.PhoneNumbers/CHANGELOG.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# Release History
22

3-
## 1.4.0-beta.1 (Unreleased)
3+
## 1.4.0 (2025-06-20)
44

55
### Features Added
66

7-
### Breaking Changes
7+
- GA release of the reservations functionality.
8+
- GA support for automated purchases of phone numbers from countries requiring a do not resell agreement.
9+
- For more information, refer to: https://learn.microsoft.com/azure/communication-services/concepts/numbers/sub-eligibility-number-capability
810

9-
### Bugs Fixed
11+
## 1.4.0-beta.1 (2025-05-21)
1012

11-
### Other Changes
13+
### Features Added
14+
- Adds support for the Browse Available Phone Numbers and Reservations APIs
15+
- This adds an alternate way to search and purchase phone numbers that allows customers to select which phone numbers they want to reserve and purchase.
16+
- Adds support for automated purchases of phone numbers from countries requiring a Do Not Resell agreement.
17+
- For more information, refer to: https://learn.microsoft.com/azure/communication-services/concepts/numbers/sub-eligibility-number-capability
18+
- API version `2025-04-01` is the default.
1219

1320
## 1.3.0 (2025-02-11)
1421

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ Phone numbers can be searched through the search creation API by providing an ar
8383

8484
Phone numbers can also be released using the release API.
8585

86+
#### Browsing and reserving phone numbers
87+
88+
The Browse and Reservations APIs provide an alternate way to acquire phone numbers via a shopping-cart-like experience. This is achieved by splitting the search operation, which finds and reserves numbers using a single LRO, into two separate synchronous steps: Browse and Reservation.
89+
90+
The browse operation retrieves a random sample of phone numbers that are available for purchase for a given country, with optional filtering criteria to narrow down results. The returned phone numbers are not reserved for any customer.
91+
92+
Reservations represent a collection of phone numbers that are locked by a specific customer and are awaiting purchase. They have an expiration time of 15 minutes after the last modification or 2 hours from creation time. A reservation can include numbers from different countries, in contrast with the Search operation. Customers can create, retrieve, modify (add/remove numbers), delete, and purchase reservations. Purchasing a reservation is an LRO.
93+
8694
### SIP routing client
8795

8896
Direct routing feature allows connecting customer-provided telephony infrastructure to Azure Communication Resources. In order to setup routing configuration properly, customer needs to supply the SIP trunk configuration and SIP routing rules for calls. SIP routing client provides the necessary interface for setting this configuration.
@@ -164,6 +172,53 @@ await releaseOperation.WaitForCompletionResponseAsync();
164172
await WaitForCompletionResponseAsync(releaseOperation);
165173
```
166174

175+
#### Acquiring phone numbers using the Reservations API
176+
177+
Using the Browse API, you can find phone numbers that are available for purchase. Note that these numbers are not reserved for any customer.
178+
179+
```C# Snippet:BrowseAvailablePhoneNumbersAsync
180+
var browseRequest = new PhoneNumbersBrowseOptions("US", PhoneNumberType.TollFree);
181+
var browseResponse = await client.BrowseAvailableNumbersAsync(browseRequest);
182+
var availablePhoneNumbers = browseResponse.Value.PhoneNumbers;
183+
```
184+
185+
Then, create a new reservation with the numbers from the Browse API response.
186+
```C# Snippet:CreateReservationAsync
187+
// Reserve the first two available phone numbers.
188+
var phoneNumbersToReserve = availablePhoneNumbers.Take(2).ToList();
189+
190+
// The reservation ID needs to be a unique GUID.
191+
var reservationId = Guid.NewGuid();
192+
193+
var request = new CreateOrUpdateReservationOptions(reservationId)
194+
{
195+
PhoneNumbersToAdd = phoneNumbersToReserve
196+
};
197+
var response = await client.CreateOrUpdateReservationAsync(request);
198+
var reservation = response.Value;
199+
```
200+
201+
Partial failures are possible, so it is important to check the status of each individual phone number.
202+
```C# Snippet:CheckForPartialFailure
203+
var phoneNumbersWithError = reservation.PhoneNumbers.Values
204+
.Where(n => n.Status == PhoneNumberAvailabilityStatus.Error);
205+
206+
if (phoneNumbersWithError.Any())
207+
{
208+
// Handle the error for the phone numbers that failed to reserve.
209+
foreach (var phoneNumber in phoneNumbersWithError)
210+
{
211+
Console.WriteLine($"Failed to reserve phone number {phoneNumber.Id}. Error Code: {phoneNumber.Error?.Code} - Message: {phoneNumber.Error?.Message}");
212+
}
213+
}
214+
```
215+
216+
Once all numbers are reserved, the reservation can be purchased.
217+
```C# Snippet:StartPurchaseReservationAsync
218+
var purchaseReservationOperation = await client.StartPurchaseReservationAsync(reservationId);
219+
await purchaseReservationOperation.WaitForCompletionResponseAsync();
220+
```
221+
167222
### SipRoutingClient
168223

169224
#### Retrieve SIP trunks and routes

0 commit comments

Comments
 (0)