forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add azure communication messages sdk (Azure#39167)
* Add Messages SDK * Work around the issue with nextLink never empty, add more tests * Update CHANGELOG.md * Update autorest and use Github link for input file * Update README.md * dropping the Value suffix on everything but the base class (MessageTemplateValue) * change the param name from url to uri, filename to fileName * Update CHANGELOG.md * revert accidental check in of RecordedTestMode * sanitize session records * remove unneeded import * update to 2023-08-24-preview api version * update CommunicationMessagesClientOptions api version to 2023-08-24-preview * re-run live test recording * fix broken link * use latest swagger * Remove unsupported auth type, add more live tests, and re-run the live tests * use the swagger that does not have operation-id response header * Take Value suffix off MessageTemplateQuickAction * update sdk to latest - change autorest to using readme instead of swagger input-file - update Butotn from IDictionary to IEnumerable for maintaining orders - autorest point to azure-rest-api-specs-pr - re-run live tests to get new session records * update the source file to the public azure specs repo * fix recording * run "eng\scripts\Export-API.ps1 communication" * run "eng\scripts\CodeChecks.ps1 -ServiceDirectory communication"
- Loading branch information
1 parent
387d06b
commit ad3228a
Showing
110 changed files
with
8,640 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
sdk/communication/Azure.Communication.Messages/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Release History | ||
|
||
## 1.0.0-beta.1 (2023-08-15) | ||
|
||
This is the first Public Preview release of Azure Communication Services for advanced messages. For more information, please see the [README][read_me] and [documentation][documentation]. | ||
|
||
This is a Public Preview version, so breaking changes are possible in subsequent releases as we improve the product. To provide feedback, please submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues). | ||
|
||
<!-- LINKS --> | ||
[read_me]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/communication/Azure.Communication.Messages/README.md |
100 changes: 100 additions & 0 deletions
100
sdk/communication/Azure.Communication.Messages/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Azure Communication Messages client library for .NET | ||
|
||
This package contains a C# SDK for Azure Communication Messages Services. | ||
|
||
[Source code][source] | [Package (NuGet)][package] | [Product documentation][product_docs] | ||
|
||
|
||
## Getting started | ||
|
||
### Install the package | ||
Install the Azure Communication Messages client library for .NET with [NuGet][nuget]: | ||
|
||
```dotnetcli | ||
dotnet add package Azure.Communication.Messages --prerelease | ||
``` | ||
|
||
### Prerequisites | ||
You need an [Azure subscription][azure_sub] and a [Communication Service Resource][communication_resource_docs] to use this package. | ||
|
||
To create a new Communication Service, you can use the [Azure Portal][communication_resource_create_portal], the [Azure PowerShell][communication_resource_create_power_shell], or the [.NET management client library][communication_resource_create_net]. | ||
|
||
### Key concepts | ||
`NotificationMessagesClient` provides the functionality to send notification messages . | ||
|
||
### Using statements | ||
```C# | ||
using Azure.Communication.Messages; | ||
``` | ||
|
||
### Authenticate the client | ||
#### Connection String | ||
Messages clients can be authenticated using the connection string acquired from an Azure Communication Resource in the [Azure Portal][azure_portal]. | ||
|
||
```C# | ||
var connectionString = "<connection_string>"; // Find your Communication Services resource in the Azure portal | ||
NotificationMessagesClient notificationMessagesClient = new NotificationMessagesClient(connectionString); | ||
MessageTemplateClient messageTemplateClient = new MessageTemplateClient(connectionString); | ||
``` | ||
|
||
## Examples | ||
### Send an Notification Message | ||
To send a notification message, call the `SendMessage` or `SendMessageAsync` function from the `NotificationMessagesClient`. | ||
|
||
#### Send a text message | ||
```C# | ||
// Create the recipient list, currently only one recipient is supported | ||
var recipient = new List<string> { "<to-phone-number>" }; | ||
var options = new SendMessageOptions("<channel-registration-id>", recipient, "Come on everyone, let's go for lunch together."); | ||
SendMessageResult result = await notificationMessagesClient.SendMessageAsync(options); | ||
Console.WriteLine($"Message id: {result.Receipts[0].MessageId}"); | ||
``` | ||
|
||
#### Send a template message | ||
```C# | ||
// Create the recipient list, currently only one recipient is supported | ||
var recipient = new List<string> { "<to-phone-number>" }; | ||
string templateName = "sample_template"; | ||
string templateLanguage = "en_us"; | ||
var messageTemplate = new MessageTemplate(templateName, templateLanguage); | ||
var sendTemplateMessageOptions = new SendMessageOptions(channelRegistrationId, recipientList, messageTemplate); | ||
SendMessageResult result = await notificationMessagesClient.SendMessageAsync(sendTemplateMessageOptions); | ||
Console.WriteLine($"Message id: {result.Receipts[0].MessageId}"); | ||
``` | ||
|
||
#### Send a media message | ||
```C# | ||
// Create the recipient list, currently only one recipient is supported | ||
var recipient = new List<string> { "<to-phone-number>" }; | ||
var uri = new Uri("https://aka.ms/acsicon1"); | ||
var sendMediaMessageOptions = new SendMessageOptions(channelRegistrationId, recipientList, uri); | ||
SendMessageResult result = await notificationMessagesClient.SendMessageAsync(sendMediaMessageOptions); | ||
Console.WriteLine($"Message id: {result.Receipts[0].MessageId}"); | ||
``` | ||
|
||
### Retrieve templates | ||
To retrieve templates, call the `GetMessages` or `GetMessagesAsync` function from the `MessageTemplateClient`. | ||
|
||
|
||
```C# | ||
AsyncPageable<MessageTemplateItem> templates = messageTemplateClient.GetTemplatesAsync(channelId); | ||
await foreach (MessageTemplateItem template in templates) | ||
{ | ||
Console.WriteLine($"{template.Name}"); | ||
} | ||
``` | ||
|
||
## Troubleshooting | ||
A `RequestFailedException` is thrown as a service response for any unsuccessful requests. The exception contains information about what response code was returned from the service. | ||
|
||
## Next steps | ||
- Read more about Messages in Azure Communication Services (Link to be added). | ||
- Read more about how to set up Event Grid subscription for new message and message delivery status (Link to be added). | ||
|
||
|
||
## Contributing | ||
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla]. | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments. | ||
|
||
|
Oops, something went wrong.