You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/communication-services/concepts/analytics/logs/sms-logs.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,9 +89,9 @@ Communication Services offers the following types of logs:
89
89
|`SdkType`| The SDK type used in the request. |
90
90
|`PlatformType`| The platform type used in the request. |
91
91
|`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. |
95
95
96
96
#### Example SMS sent log
97
97
@@ -118,7 +118,7 @@ Communication Services offers the following types of logs:

81
81
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.
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/identity/includes/active-directory/service-principal-net.md
+42-25Lines changed: 42 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,34 +1,44 @@
1
1
> [!NOTE]
2
2
> Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/use-managed-Identity)
3
3
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
+
4
8
## Setting up
5
9
6
10
### Create a new C# application
7
11
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`:
9
13
10
14
```console
11
15
dotnet new console -o ActiveDirectoryAuthenticationQuickstart
12
16
```
13
17
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:
15
23
16
24
```console
17
25
cd ActiveDirectoryAuthenticationQuickstart
18
26
dotnet build
19
27
```
20
28
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:
22
32
23
33
```console
24
34
dotnet add package Azure.Communication.Identity
25
35
dotnet add package Azure.Communication.Sms
26
36
dotnet add package Azure.Identity
27
37
```
28
38
29
-
### Use the SDK packages
39
+
### Update the Program.cs file
30
40
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:
32
42
33
43
```csharp
34
44
usingAzure.Identity;
@@ -38,17 +48,17 @@ using Azure.Core;
38
48
usingAzure;
39
49
```
40
50
41
-
## Create a DefaultAzureCredential
51
+
## Authenticate with DefaultAzureCredential
42
52
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`:
@@ -62,7 +72,7 @@ public AccessToken CreateIdentityAndGetTokenAsync(Uri resourceEndpoint)
62
72
63
73
## Send an SMS with service principals
64
74
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:
@@ -81,16 +91,16 @@ public SmsSendResult SendSms(Uri resourceEndpoint, string from, string to, strin
81
91
82
92
## Write the Main method
83
93
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:
85
95
86
96
```csharp
87
97
staticvoidMain(string[] args)
88
98
{
89
-
//You can find your endpoint and access key from your resource in the Azure portal
Console.WriteLine("Sending SMS using Service Principals");
101
111
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.
103
113
SmsSendResultresult=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");
104
114
Console.WriteLine($"Sms id: {result.MessageId}");
105
115
Console.WriteLine($"Send Result Successful: {result.Successful}");
//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.
122
132
Programinstance=new();
123
133
124
134
Console.WriteLine("Retrieving new Access Token, using Service Principals");
@@ -127,7 +137,7 @@ class Program
127
137
128
138
Console.WriteLine("Sending SMS using Service Principals");
129
139
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.
131
141
SmsSendResultresult=instance.SendSms(endpoint, "<Your Azure Communication Services Phone Number>", "<The Phone Number you'd like to send the SMS to.>", "Hello from Service Principals");
132
142
Console.WriteLine($"Sms id: {result.MessageId}");
133
143
Console.WriteLine($"Send Result Successful: {result.Successful}");
@@ -156,11 +166,18 @@ class Program
156
166
157
167
## Run the program
158
168
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
166
173
```
174
+
175
+
The console output should appear as follows:
176
+
177
+
```Bash
178
+
Retrieving new Access Token, using Service Principals
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/identity/includes/active-directory/service-principal-python.md
+27-17Lines changed: 27 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,26 +5,28 @@
5
5
6
6
### Create a new Python application
7
7
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:
9
9
10
10
```console
11
11
mkdir active-directory-authentication-quickstart && cd active-directory-authentication-quickstart
12
12
```
13
13
14
14
### Install the SDK packages
15
15
16
+
Next we need to install the required Azure SDK packages. Run these commands:
17
+
16
18
```console
17
19
pip install azure-identity
18
20
pip install azure-communication-identity
19
21
pip install azure-communication-sms
20
22
```
21
23
22
24
### 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.
24
26
25
27
### Use the SDK packages
26
28
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:
28
30
29
31
```python
30
32
from azure.identity import DefaultAzureCredential
@@ -34,15 +36,17 @@ from azure.communication.sms import SmsClient
34
36
35
37
### Create a DefaultAzureCredential
36
38
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:
38
42
39
43
```python
40
44
credential = DefaultAzureCredential()
41
45
```
42
46
43
47
## Create an identity and issue a token with service principals
44
48
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:
#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.
86
93
sms_result = send_sms(endpoint, "<FROM_NUMBER>", "<TO_NUMBER>", "Hello from Service Principals");
87
94
print(f'SMS ID: {sms_result[0].message_id}');
88
95
print(f'Send Result Successful: {sms_result[0].successful}');
89
96
```
90
97
91
-
The final `authentication.py`file should look something like this:
98
+
This is how the `authentication.py`looks after all changes you made:
92
99
93
100
```python
94
101
from azure.identity import DefaultAzureCredential
@@ -131,13 +138,16 @@ print(f'Send Result Successful: {sms_result[0].successful}');
131
138
```
132
139
## Run the program
133
140
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:
136
146
```Bash
137
147
$ python authentication.py
138
148
Retrieving new Access Token, using Service Principals
"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
42
42
"eventTime": "2020-09-18T00:27:47Z"
43
43
}]
44
44
```
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.
45
47
46
48
To start generating events, configure Azure Event Grid to use your Azure Communication Services resource.
47
49
@@ -80,4 +82,4 @@ If you have a new toll-free number and want to send a [high volume of SMS messag
80
82
> [Phone number types](../../concepts/telephony/plan-solution.md)
81
83
82
84
> [!div class="nextstepaction"]
83
-
> [Learn more about SMS](../../concepts/sms/concepts.md)
85
+
> [Learn more about SMS](../../concepts/sms/concepts.md)
0 commit comments