Skip to content

Commit 0769ef7

Browse files
authored
Merge pull request #301521 from kirill-linnik/sms-message-id-content-fix
ACS SMS, removing/adjusting message ID examples
2 parents 036f128 + 13a64a6 commit 0769ef7

File tree

9 files changed

+93
-64
lines changed

9 files changed

+93
-64
lines changed

articles/communication-services/concepts/analytics/logs/sms-logs.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ Communication Services offers the following types of logs:
8989
| `SdkType` | The SDK type used in the request. |
9090
| `PlatformType` | The platform type used in the request. |
9191
| `Method` | The method used in the request. |
92-
|`NumberType`| The type of number, the SMS message is being sent from. It can be either **LongCodeNumber**, **ShortCodeNumber**, or **DynamicAlphaSenderID**.|
93-
|`MessageID`| Represents the unique messageId generated for every outgoing and incoming message. Find the MessageId in the SMS API response object. |
94-
|`Country`| Represents the countries/regions where SMS messages are sent to or received from. |
92+
| `NumberType` | The type of number, the SMS message is being sent from. It can be either **LongCodeNumber**, **ShortCodeNumber**, or **DynamicAlphaSenderID**.|
93+
| `MessageID` | Represents the unique message ID generated for every outgoing and incoming message. Find the MessageId in the SMS API response object. The format of message ID returned by this API is considered an internal implementation detail and is subject to change without notice. Clients must treat message ID as opaque identifiers and must not parse, infer structure, or build logic based on their format or content.|
94+
| `Country` | Represents the countries/regions where SMS messages are sent to or received from. |
9595

9696
#### Example SMS sent log
9797

@@ -118,7 +118,7 @@ Communication Services offers the following types of logs:
118118
"SdkType": "azsdk-net-Communication.Sms",
119119
"PlatformType": "Microsoft Windows 10.0.17763",
120120
"Method": "POST",
121-
"MessageId": "Outgoing_20230118181300ff00e5c9-876d-4958-86e3-4637484fe5bd_noam",
121+
"MessageId": "ff00e5c9-876d-4958-86e3-4637484fe5bd",
122122
"Country": "US"
123123
}
124124
]
@@ -149,7 +149,7 @@ Communication Services offers the following types of logs:
149149
"SdkType": "",
150150
"PlatformType": "",
151151
"Method": "POST",
152-
"MessageId": "Outgoing_20230118181300ff00e5c9-876d-4958-86e3-4637484fe5bd_noam",
152+
"MessageId": "ff00e5c9-876d-4958-86e3-4637484fe5bd",
153153
"Country": "US"
154154
}
155155
]
@@ -180,7 +180,7 @@ Communication Services offers the following types of logs:
180180
"SdkType": "",
181181
"PlatformType": "",
182182
"Method": "POST",
183-
"MessageId": "Incoming_2023011818121211c6ee31-63fe-477c-8d51-f800543c6694",
183+
"MessageId": "11c6ee31-63fe-477c-8d51-f800543c6694",
184184
"Country": "US"
185185
}
186186
]
@@ -189,4 +189,4 @@ Communication Services offers the following types of logs:
189189

190190
## Related articles
191191

192-
[SMS FAQ](/azure/azure-monitor/overview#frequently-asked-questions)
192+
[SMS FAQ](/azure/azure-monitor/overview#frequently-asked-questions)

articles/communication-services/how-tos/event-grid/local-testing-event-grid.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ http://localhost:7071/runtime/webhooks/EventGrid?functionName={functionname}
4848
```json
4949

5050
{
51-
"id": "Incoming_20200918002745d29ebbea-3341-4466-9690-0a03af35228e",
51+
"id": "d29ebbea-3341-4466-9690-0a03af35228e",
5252
"topic": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/acse2e/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
5353
"subject": "/phonenumber/15555555555",
5454
"data": {
55-
"MessageId": "Incoming_20200918002745d29ebbea-3341-4466-9690-0a03af35228e",
55+
"MessageId": "d29ebbea-3341-4466-9690-0a03af35228e",
5656
"From": "15555555555",
5757
"To": "15555555555",
5858
"Message": "Great to connect with Azure Communication Services events",
@@ -79,4 +79,4 @@ http://localhost:7071/runtime/webhooks/EventGrid?functionName={functionname}
7979

8080
![Screenshot of Postman send button.](media/postman-send.png)
8181

82-
At this point, an event should trigger in your Azure Function. You can verify the event by looking at the execution of your Azure Function. You can then validate that the function is doing its job correctly.
82+
At this point, an event should trigger in your Azure Function. You can verify the event by looking at the execution of your Azure Function. You can then validate that the function is doing its job correctly.
12.4 KB
Loading

articles/communication-services/quickstarts/identity/includes/active-directory/service-principal-java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,6 @@ The final output should resemble the following:
201201
Retrieving new Access Token, using Service Principals
202202
Retrieved Access Token: ey..A
203203
Sending SMS using using Service Principals
204-
Sms id: Outgoing_202104...33f8ae1f_noam
204+
Sms id: ...
205205
Send Result Successful: true
206206
```

articles/communication-services/quickstarts/identity/includes/active-directory/service-principal-js.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,6 @@ With everything complete, you can run the file by entering `node index.js` from
158158
Retrieving new Access Token, using Service Principals
159159
Retrieved Access Token: ey...Q
160160
Sending SMS using Service Principals
161-
SMS ID: Outgoing_2021040602194...._noam
161+
SMS ID: ...
162162
Send Result Successful: true
163-
```
163+
```

articles/communication-services/quickstarts/identity/includes/active-directory/service-principal-net.md

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
11
> [!NOTE]
22
> Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/use-managed-Identity)
33
4+
## Overview
5+
6+
This quickstart demonstrates how to use managed identities via Azure Service Principals to authenticate with Azure Communication Services. It provides examples for issuing an access token for Voice over IP (VoIP) calls and sending SMS messages.
7+
48
## Setting up
59

610
### Create a new C# application
711

8-
In a console window (such as cmd, PowerShell, or Bash), use the `dotnet new` command to create a new console app with the name `ActiveDirectoryQuickstart`. This command creates a simple "Hello World" C# project with a single source file: `Program.cs`.
12+
The goal is to create a new console application in C# to run the quickstart code. Open a terminal window (e.g., Command Prompt, PowerShell, or Bash) and execute the following command to create a new console app named `ActiveDirectoryAuthenticationQuickstart`:
913

1014
```console
1115
dotnet new console -o ActiveDirectoryAuthenticationQuickstart
1216
```
1317

14-
Change your directory to the newly created app folder and use the `dotnet build` command to compile your application.
18+
This command will generate a simple "Hello World" C# project, including a single source file: `Program.cs`.
19+
20+
### Build the Application
21+
22+
Navigate to the newly created app folder and compile your application using the `dotnet build` command:
1523

1624
```console
1725
cd ActiveDirectoryAuthenticationQuickstart
1826
dotnet build
1927
```
2028

21-
### Install the SDK packages
29+
### Install the Required SDK Packages
30+
31+
To interact with Azure Communication Services and Azure Identity, add the following NuGet packages to your project:
2232

2333
```console
2434
dotnet add package Azure.Communication.Identity
2535
dotnet add package Azure.Communication.Sms
2636
dotnet add package Azure.Identity
2737
```
2838

29-
### Use the SDK packages
39+
### Update the Program.cs file
3040

31-
Add the following `using` directives to `Program.cs` to use the Azure Identity and Azure Storage SDKs.
41+
To use the installed Azure SDK packages, include the following `using` directives at the top of your `Program.cs` file:
3242

3343
```csharp
3444
using Azure.Identity;
@@ -38,17 +48,17 @@ using Azure.Core;
3848
using Azure;
3949
```
4050

41-
## Create a DefaultAzureCredential
51+
## Authenticate with DefaultAzureCredential
4252

43-
We'll be using the [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential) for this quickstart. This credential is suitable for production and development environments. As it is needed for each operation let's create it within the `Program.cs` class. Add the following to the top of the file.
53+
For this quickstart, we'll use the [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential), which is suitable for both development and production environments. Declare an instance of this credential at the class level in `Program.cs`:
4454

4555
```csharp
4656
private DefaultAzureCredential credential = new DefaultAzureCredential();
4757
```
4858

4959
## Issue a token with service principals
5060

51-
Now we'll add code which uses the created credential, to issue a VoIP Access Token. We'll call this code later on.
61+
Add the following method to your `Program.cs` file. This method uses the Azure Communication Services SDK to issue a VoIP Access Token:
5262

5363
```csharp
5464
public AccessToken CreateIdentityAndGetTokenAsync(Uri resourceEndpoint)
@@ -62,7 +72,7 @@ public AccessToken CreateIdentityAndGetTokenAsync(Uri resourceEndpoint)
6272

6373
## Send an SMS with service principals
6474

65-
As another example of using service principals, we'll add this code which uses the same credential to send an SMS:
75+
To demonstrate sending an SMS, add the following method to your `Program.cs` file. This method uses the Azure Communication Services SDK to send an SMS message:
6676

6777
```csharp
6878
public SmsSendResult SendSms(Uri resourceEndpoint, string from, string to, string message)
@@ -81,16 +91,16 @@ public SmsSendResult SendSms(Uri resourceEndpoint, string from, string to, strin
8191

8292
## Write the Main method
8393

84-
Your `Program.cs` should already have a Main method, let's add some code which will call our previously created code to demonstrate the use of service principals:
94+
In the `Main` method of your `Program.cs` file, add code to call the methods you created for issuing a token and sending an SMS. Your `Main` method should look similar to this:
8595

8696
```csharp
8797
static void Main(string[] args)
8898
{
89-
// You can find your endpoint and access key from your resource in the Azure portal
90-
// e.g. "https://<RESOURCE_NAME>.communication.azure.com";
99+
// Replace <RESOURCE_NAME> with your Communication Services resource name,
100+
// for example: "https://<RESOURCE_NAME>.communication.azure.com".
91101
Uri endpoint = new("https://<RESOURCENAME>.communication.azure.com/");
92102

93-
// We need an instance of the program class to use within this method.
103+
// Create an instance of the Program class to invoke instance methods.
94104
Program instance = new();
95105

96106
Console.WriteLine("Retrieving new Access Token, using Service Principals");
@@ -99,7 +109,7 @@ static void Main(string[] args)
99109

100110
Console.WriteLine("Sending SMS using Service Principals");
101111

102-
// You will need a phone number from your resource to send an SMS.
112+
// Replace with your Azure Communication Services phone number and the target phone number.
103113
SmsSendResult result = instance.SendSms(endpoint, "<Your Azure Communication Services Phone Number>", "<The Phone Number you'd like to send the SMS to.>", "Hello from using Service Principals");
104114
Console.WriteLine($"Sms id: {result.MessageId}");
105115
Console.WriteLine($"Send Result Successful: {result.Successful}");
@@ -114,11 +124,11 @@ class Program
114124
private DefaultAzureCredential credential = new DefaultAzureCredential();
115125
static void Main(string[] args)
116126
{
117-
// You can find your endpoint and access key from your resource in the Azure portal
118-
// e.g. "https://<RESOURCE_NAME>.communication.azure.com";
127+
// Replace <RESOURCE_NAME> with your Communication Services resource name,
128+
// for example: "https://<RESOURCE_NAME>.communication.azure.com".
119129
Uri endpoint = new("https://acstestingrifox.communication.azure.com/");
120130

121-
// We need an instance of the program class to use within this method.
131+
// Create an instance of the Program class to invoke instance methods.
122132
Program instance = new();
123133

124134
Console.WriteLine("Retrieving new Access Token, using Service Principals");
@@ -127,7 +137,7 @@ class Program
127137

128138
Console.WriteLine("Sending SMS using Service Principals");
129139

130-
// You will need a phone number from your resource to send an SMS.
140+
// Replace with your Azure Communication Services phone number and the target phone number.
131141
SmsSendResult result = instance.SendSms(endpoint, "<Your Azure Communication Services Phone Number>", "<The Phone Number you'd like to send the SMS to.>", "Hello from Service Principals");
132142
Console.WriteLine($"Sms id: {result.MessageId}");
133143
Console.WriteLine($"Send Result Successful: {result.Successful}");
@@ -156,11 +166,18 @@ class Program
156166

157167
## Run the program
158168

159-
You should now be able to run your application, using `dotnet run` from your application folder. The output should resemble the following:
160-
```
161-
Retrieving new Access Token, using Service Principals
162-
Retrieved Access Token: ey....
163-
Sending SMS using Service Principals
164-
Sms id: Outgoing_..._noam
165-
Send Result Successful: True
169+
It is time to run your application and verify that it retrieves an access token and sends an SMS. Open a terminal, navigate to your application directory, and run:
170+
171+
```console
172+
dotnet run
166173
```
174+
175+
The console output should appear as follows:
176+
177+
```Bash
178+
Retrieving new Access Token, using Service Principals
179+
Retrieved Access Token: ...
180+
Sending SMS using Service Principals
181+
Sms id: ...
182+
Send Result Successful: True
183+
```

articles/communication-services/quickstarts/identity/includes/active-directory/service-principal-python.md

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,28 @@
55

66
### Create a new Python application
77

8-
Open your terminal or command window create a new directory for your app, and navigate to it.
8+
Let us set up your working directory for the application. For that, open your terminal or command window, create a new directory, and navigate to it:
99

1010
```console
1111
mkdir active-directory-authentication-quickstart && cd active-directory-authentication-quickstart
1212
```
1313

1414
### Install the SDK packages
1515

16+
Next we need to install the required Azure SDK packages. Run these commands:
17+
1618
```console
1719
pip install azure-identity
1820
pip install azure-communication-identity
1921
pip install azure-communication-sms
2022
```
2123

2224
### Create a new file
23-
Open and save a new file within your created folder called `authentication.py`, we'll be placing our code inside this file.
25+
Now we need a Python file to hold your code. Open and save a new file called `authentication.py` within your directory.
2426

2527
### Use the SDK packages
2628

27-
Add the following `import` statements to the top of your file to use the SDKs that we installed.
29+
Our next goal is to import the necessary Azure SDK modules to work with identity and SMS. Add the following statements at the top of your file:
2830

2931
```python
3032
from azure.identity import DefaultAzureCredential
@@ -34,15 +36,17 @@ from azure.communication.sms import SmsClient
3436

3537
### Create a DefaultAzureCredential
3638

37-
We'll be using the [DefaultAzureCredential](/python/api/azure-identity/azure.identity.defaultazurecredential). This credential is suitable for production and development environments. As we'll be using it throughout this quickstart we'll create it at the top of the file.
39+
We need to initialize a credential for both production and development environments.
40+
41+
Place this line with [DefaultAzureCredential](/python/api/azure-identity/azure.identity.defaultazurecredential) after previously inserted lines:
3842

3943
```python
4044
credential = DefaultAzureCredential()
4145
```
4246

4347
## Create an identity and issue a token with service principals
4448

45-
Now we'll add code which uses the created credential, to issue a VoIP Access Token. We'll call this code later on:
49+
Create an identity and request a Voice over Internet Protocol (VoIP) access token:
4650

4751
```python
4852
def create_identity_and_get_token(resource_endpoint):
@@ -53,7 +57,8 @@ def create_identity_and_get_token(resource_endpoint):
5357
```
5458

5559
### Send an SMS with service principals
56-
As another example of using service principals, we'll add this code which uses the same credential to send an SMS:
60+
61+
Alternatively, you can utilize your credential to send a Short Message Service (SMS) as shown in the example below:
5762

5863
```python
5964
def send_sms(resource_endpoint, from_phone_number, to_phone_number, message_content):
@@ -69,11 +74,13 @@ def send_sms(resource_endpoint, from_phone_number, to_phone_number, message_cont
6974

7075
## Write our main code
7176

72-
With our functions created we can now write the main code which will call the functions we've previous written.
77+
Now we have all the necessary code blocks to execute the functions to create an identity, obtain an access token, and send an SMS.
78+
79+
Include the main code that calls your functions:
7380

7481
```python
75-
# You can find your endpoint and access key from your resource in the Azure portal
76-
# e.g. "https://<RESOURCE_NAME>.communication.azure.com";
82+
# Retrieve your endpoint and access key from your resource in the Azure portal
83+
# For example: "https://<RESOURCE_NAME>.communication.azure.com"
7784
endpoint = "https://<RESOURCE_NAME>.communication.azure.com/"
7885

7986
print("Retrieving new Access Token, using Service Principals");
@@ -82,13 +89,13 @@ print(f'Retrieved Access Token: {result.token}');
8289

8390
print("Sending SMS using Service Principals");
8491

85-
# You will need a phone number from your resource to send an SMS.
92+
# Provide a valid phone number from your Azure resource to send an SMS.
8693
sms_result = send_sms(endpoint, "<FROM_NUMBER>", "<TO_NUMBER>", "Hello from Service Principals");
8794
print(f'SMS ID: {sms_result[0].message_id}');
8895
print(f'Send Result Successful: {sms_result[0].successful}');
8996
```
9097

91-
The final `authentication.py` file should look something like this:
98+
This is how the `authentication.py` looks after all changes you made:
9299

93100
```python
94101
from azure.identity import DefaultAzureCredential
@@ -131,13 +138,16 @@ print(f'Send Result Successful: {sms_result[0].successful}');
131138
```
132139
## Run the program
133140

134-
With everything complete, you can run the file by entering `python authentication.py` from your project's directory. If everything went well you should see something similar to the following.
135-
141+
It is time to execute your Python script to verify functionality. Run the file from your project's directory with the command:
142+
```console
143+
python authentication.py
144+
```
145+
If successful, you see output similar to this:
136146
```Bash
137147
$ python authentication.py
138148
Retrieving new Access Token, using Service Principals
139-
Retrieved Access Token: ey...Q
140-
Sending SMS using using Service Principals
141-
SMS ID: Outgoing_2021040602194...._noam
149+
Retrieved Access Token: ...
150+
Sending SMS using Service Principals
151+
SMS ID: ...
142152
Send Result Successful: true
143-
```
153+
```

articles/communication-services/quickstarts/sms/receive-sms.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ The `SMSReceived` event generated when an SMS is sent to an Azure Communication
2626

2727
```json
2828
[{
29-
"id": "Incoming_20200918002745d29ebbea-3341-4466-9690-0a03af35228e",
29+
"id": "d29ebbea-3341-4466-9690-0a03af35228e",
3030
"topic": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/acse2e/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
3131
"subject": "/phonenumber/15555555555",
3232
"data": {
33-
"MessageId": "Incoming_20200918002745d29ebbea-3341-4466-9690-0a03af35228e",
33+
"MessageId": "d29ebbea-3341-4466-9690-0a03af35228e",
3434
"From": "15555555555",
3535
"To": "15555555555",
3636
"Message": "Great to connect with Azure Communication Services events",
@@ -42,6 +42,8 @@ The `SMSReceived` event generated when an SMS is sent to an Azure Communication
4242
"eventTime": "2020-09-18T00:27:47Z"
4343
}]
4444
```
45+
> [!NOTE]
46+
> The format of `MessageId` returned by this API is considered an internal implementation detail and is subject to change without notice. Clients must treat message IDs as opaque identifiers and must not parse, infer structure, or build logic based on their format or content.
4547
4648
To start generating events, configure Azure Event Grid to use your Azure Communication Services resource.
4749

@@ -80,4 +82,4 @@ If you have a new toll-free number and want to send a [high volume of SMS messag
8082
> [Phone number types](../../concepts/telephony/plan-solution.md)
8183
8284
> [!div class="nextstepaction"]
83-
> [Learn more about SMS](../../concepts/sms/concepts.md)
85+
> [Learn more about SMS](../../concepts/sms/concepts.md)

0 commit comments

Comments
 (0)