Skip to content

Commit 4cdc640

Browse files
authored
Update number-lookup-python.md
1 parent e6dcbdb commit 4cdc640

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

articles/communication-services/quickstarts/telephony/includes/number-lookup-python.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Get started with the Phone Numbers client library for Python to look up operator information for phone numbers, which can be used to determine whether and how to communicate with that phone number. Follow these steps to install the package and look up operator information about a phone number.
22

33
> [!NOTE]
4-
> Find the code for this quickstart on [GitHub](https://github.com/Azure/communication-preview/tree/master/samples/NumberLookup).
4+
> Find the code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-python-quickstarts/tree/main/lookup-phone-numbers-quickstart).
55
66
## Prerequisites
77

@@ -50,15 +50,28 @@ pip install azure-communication-phonenumbers==1.2.0b2
5050
## Code examples
5151

5252
### Authenticate the client
53-
The `PhoneNumbersClient` is enabled to use Microsoft Entra authentication. Using the `DefaultAzureCredential` object is the easiest way to get started with Microsoft Entra ID and you can install it using the `pip install` command.
53+
54+
The client can be authenticated using a connection string acquired from an Azure Communication Services resource in the [Azure portal](https://portal.azure.com). Using a `COMMUNICATION_SERVICES_CONNECTION_STRING` environment variable is recommended to avoid putting your connection string in plain text within your code. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string).
55+
56+
```python
57+
# This code retrieves your connection string from an environment variable
58+
connection_string = os.getenv('COMMUNICATION_SERVICES_CONNECTION_STRING')
59+
try:
60+
phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_string)
61+
except Exception as ex:
62+
print('Exception:')
63+
print(ex)
64+
```
65+
66+
Alternatively, the client can be authenticated using Microsoft Entra authentication. Using the `DefaultAzureCredential` object is the easiest way to get started with Microsoft Entra ID and you can install it using the `pip install` command.
5467

5568
```console
5669
pip install azure-identity
5770
```
5871

5972
Creating a `DefaultAzureCredential` object requires you to have `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, and `AZURE_TENANT_ID` already set as environment variables with their corresponding values from your registered Microsoft Entra application.
6073

61-
For a quick ramp-up on how to get these environment variables, you can follow the [Set up service principals from CLI quickstart](../../identity/service-principal-from-cli.md).
74+
For a ramp-up on how to get these environment variables, you can learn how to [set up service principals from CLI](https://learn.microsoft.com/en-us/cli/azure/authenticate-azure-cli-service-principal)).
6275

6376
Once the `azure-identity` library is installed, you can continue authenticating the client.
6477

@@ -75,18 +88,6 @@ except Exception as ex:
7588
print(ex)
7689
```
7790

78-
Alternatively, the client can be authenticated using a connection string, also acquired from an Azure Communication Services resource in the [Azure portal](https://portal.azure.com). Using a `COMMUNICATION_SERVICES_CONNECTION_STRING` environment variable is recommended to avoid putting your connection string in plain text within your code. Learn how to [manage your resource's connection string](../../create-communication-resource.md#store-your-connection-string).
79-
80-
```python
81-
# This code retrieves your connection string from an environment variable
82-
connection_string = os.getenv('COMMUNICATION_SERVICES_CONNECTION_STRING')
83-
try:
84-
phone_numbers_client = PhoneNumbersClient.from_connection_string(connection_string)
85-
except Exception as ex:
86-
print('Exception:')
87-
print(ex)
88-
```
89-
9091
### Look up phone number formatting
9192

9293
To look up the national and international formatting for a number, call `search_operator_information` from the `PhoneNumbersClient`.
@@ -110,7 +111,7 @@ operator_results = phone_numbers_client.search_operator_information("<target-pho
110111
```
111112

112113
> [!WARNING]
113-
> Using this functionality will incur a charge to your account
114+
> Using this functionality will incur a charge to your account.
114115
115116
### Use operator information
116117

@@ -149,4 +150,4 @@ python number_lookup_sample.py
149150

150151
## Sample code
151152

152-
You can download the sample app from [GitHub](https://github.com/Azure/communication-preview/tree/master/samples/NumberLookup).
153+
You can download the sample app from [GitHub](https://github.com/Azure-Samples/communication-services-python-quickstarts/tree/main/lookup-phone-numbers-quickstart).

0 commit comments

Comments
 (0)