From bdeb76a30f0eb90ad32ce1d065af69e90c0ad133 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Mon, 8 Jun 2020 11:30:46 -0700 Subject: [PATCH 1/3] Update for Preview 3 --- .../Azure.Messaging.ServiceBus.sln | 1 + .../Azure.Messaging.ServiceBus/CHANGELOG.md | 16 +++- .../samples/README.md | 13 +-- .../samples/Sample07_CRUDOperations.md | 52 ++++++++++++ .../tests/Samples/Sample07_CRUDOperations.cs | 82 +++++++++++++++++++ 5 files changed, 157 insertions(+), 7 deletions(-) create mode 100644 sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample07_CRUDOperations.md create mode 100644 sdk/servicebus/Azure.Messaging.ServiceBus/tests/Samples/Sample07_CRUDOperations.cs diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/Azure.Messaging.ServiceBus.sln b/sdk/servicebus/Azure.Messaging.ServiceBus/Azure.Messaging.ServiceBus.sln index c0836e9dcc681..3bad4eacbc37e 100644 --- a/sdk/servicebus/Azure.Messaging.ServiceBus/Azure.Messaging.ServiceBus.sln +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/Azure.Messaging.ServiceBus.sln @@ -26,6 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{8B8C samples\Sample04_Processor.md = samples\Sample04_Processor.md samples\Sample05_SessionProcessor.md = samples\Sample05_SessionProcessor.md samples\Sample06_Transactions.md = samples\Sample06_Transactions.md + samples\Sample07_CRUDOperations.md = samples\Sample07_CRUDOperations.md EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.Experimental", "..\..\core\Azure.Core.Experimental\src\Azure.Core.Experimental.csproj", "{5871D9C6-F2DF-4F05-B29A-6C0D8709784A}" diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md b/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md index f8d86730c03ac..a262b4773e899 100644 --- a/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md @@ -1,7 +1,21 @@ # Release History -## 7.0.0-preview.3 (Unreleased) +## 7.0.0-preview.3 (2020-06-08) +### Acknowledgements +Thank you to our developer community members who helped to make the Service Bus client library better with their contributions and design input for this release: +- Daniel Marbach _([GitHub](https://github.com/danielmarbach))_ +- Sean Feldman _([GitHub](https://github.com/SeanFeldman))_ +### Added +- Added the ServiceBusManagementClient for CRUD operations on a namespace +- Add constructor for ServiceBusMessage taking a string +- Use the BinaryData type for ServiceBusMessage.Body +- Add diagnostic tracing + +### Breaking Changes +- Introduce ServiceBusSessionReceiverOptions/ServiceBusSessionProcessorOptions for creating + ServiceBusSessionReceiver/ServiceBusSessionProcessor +- Make ServiceBusReceivedMessage.Properties IReadOnlyDictionary rather than IDictionary ## 7.0.0-preview.2 (2020-05-04) diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/samples/README.md b/sdk/servicebus/Azure.Messaging.ServiceBus/samples/README.md index 10c3bd08d3794..7ba24b5f48a9f 100644 --- a/sdk/servicebus/Azure.Messaging.ServiceBus/samples/README.md +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/samples/README.md @@ -11,9 +11,10 @@ description: Samples for the Azure.Messaging.ServiceBus client library # Azure.Messaging.ServiceBus Samples -- [Sending and Receiving Messages](Sample01_HelloWorld.md) -- [Settling Messages](Sample02_MessageSettlement.md) -- [Sending and Receiving Session Messages](Sample03_SendReceiveSessions.md) -- [Using the Processor](Sample04_Processor.md) -- [Using the Session Processor](Sample05_SessionProcessor.md) -- [Working with Transactions](Sample06_Transactions.md) +- [Sending and Receiving Messages](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample01_HelloWorld.md) +- [Settling Messages](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample02_MessageSettlement.md) +- [Sending and Receiving Session Messages](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample03_SendReceiveSessions.md) +- [Using the Processor](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample04_Processor.md) +- [Using the Session Processor](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample05_SessionProcessor.md) +- [Working with Transactions](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample06_Transactions.md) +- [CRUD Operations](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample07_CRUDOperations.md) diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample07_CRUDOperations.md b/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample07_CRUDOperations.md new file mode 100644 index 0000000000000..78c4219cf194e --- /dev/null +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample07_CRUDOperations.md @@ -0,0 +1,52 @@ +## CRUD operations +This sample demonstrates how to use the management client to manage entities within a namespace. + +### Create a queue +```C# Snippet:CreateQueue +string connectionString = ""; +string queueName = ""; +var client = new ServiceBusClient(connectionString); +var queueDescription = new QueueDescription(queueName) +{ + AutoDeleteOnIdle = TimeSpan.FromDays(7), + DefaultMessageTimeToLive = TimeSpan.FromDays(2), + DuplicateDetectionHistoryTimeWindow = TimeSpan.FromMinutes(1), + EnableBatchedOperations = true, + DeadLetteringOnMessageExpiration = true, + EnablePartitioning = false, + ForwardDeadLetteredMessagesTo = null, + ForwardTo = null, + LockDuration = TimeSpan.FromSeconds(45), + MaxDeliveryCount = 8, + MaxSizeInMegabytes = 2048, + RequiresDuplicateDetection = true, + RequiresSession = true, + UserMetadata = "some metadata" +}; + +queueDescription.AuthorizationRules.Add(new SharedAccessAuthorizationRule( + "allClaims", + new[] { AccessRights.Manage, AccessRights.Send, AccessRights.Listen })); + +// The CreateQueueAsync method will return the created queue +// which would include values for all of the +// QueueDescription properties (the service will supply +// default values for properties not included in the creation). +QueueDescription createdQueue = await client.CreateQueueAsync(queueDescription); +``` + +### Get queue +```C# Snippet:GetQueue +QueueDescription queueDescription = await client.GetQueueAsync(queueName); +``` + +### Update queue +```C# Snippet:UpdateQueue +queueDescription.LockDuration = TimeSpan.FromSeconds(60); +QueueDescription updatedQueue = await client.UpdateQueueAsync(queueDescription); +``` + +### Delete queue +```C# Snippet:DeleteQueue +await client.DeleteQueueAsync(queueName); +``` diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/tests/Samples/Sample07_CRUDOperations.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/tests/Samples/Sample07_CRUDOperations.cs new file mode 100644 index 0000000000000..76b25b97c634e --- /dev/null +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/tests/Samples/Sample07_CRUDOperations.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections; +using System.Threading.Tasks; +using Azure.Messaging.ServiceBus.Management; +using Moq; +using NUnit.Framework; + +namespace Azure.Messaging.ServiceBus.Tests.Samples +{ + public class Sample07_CRUDOperations : ServiceBusLiveTestBase + { + [Test] + public async Task CreateQueue() + { + string queueName = Guid.NewGuid().ToString("D").Substring(0, 8); + string connectionString = TestEnvironment.ServiceBusConnectionString; + var client = new ServiceBusManagementClient(connectionString); + #region Snippet:CreateQueue + //@@ string connectionString = ""; + //@@ string queueName = ""; + //@@ var client = new ServiceBusClient(connectionString); + var queueDescription = new QueueDescription(queueName) + { + AutoDeleteOnIdle = TimeSpan.FromDays(7), + DefaultMessageTimeToLive = TimeSpan.FromDays(2), + DuplicateDetectionHistoryTimeWindow = TimeSpan.FromMinutes(1), + EnableBatchedOperations = true, + DeadLetteringOnMessageExpiration = true, + EnablePartitioning = false, + ForwardDeadLetteredMessagesTo = null, + ForwardTo = null, + LockDuration = TimeSpan.FromSeconds(45), + MaxDeliveryCount = 8, + MaxSizeInMegabytes = 2048, + RequiresDuplicateDetection = true, + RequiresSession = true, + UserMetadata = "some metadata" + }; + + queueDescription.AuthorizationRules.Add(new SharedAccessAuthorizationRule( + "allClaims", + new[] { AccessRights.Manage, AccessRights.Send, AccessRights.Listen })); + + // The CreateQueueAsync method will return the created queue + // which would include values for all of the + // QueueDescription properties (the service will supply + // default values for properties not included in the creation). + QueueDescription createdQueue = await client.CreateQueueAsync(queueDescription); + #endregion + Assert.AreEqual(queueDescription, createdQueue); + } + + [Test] + public async Task GetUpdateDeleteQueue() + { + string queueName = Guid.NewGuid().ToString("D").Substring(0, 8); + string connectionString = TestEnvironment.ServiceBusConnectionString; + var client = new ServiceBusManagementClient(connectionString); + var qd = new QueueDescription(queueName); + + await client.CreateQueueAsync(qd); + #region Snippet:GetQueue + QueueDescription queueDescription = await client.GetQueueAsync(queueName); + #endregion + #region Snippet:UpdateQueue + queueDescription.LockDuration = TimeSpan.FromSeconds(60); + QueueDescription updatedQueue = await client.UpdateQueueAsync(queueDescription); + #endregion + Assert.AreEqual(TimeSpan.FromSeconds(60), updatedQueue.LockDuration); + #region Snippet:DeleteQueue + await client.DeleteQueueAsync(queueName); + #endregion + Assert.That( + async () => + await client.GetQueueAsync(queueName), + Throws.InstanceOf().And.Property(nameof(ServiceBusException.Reason)).EqualTo(ServiceBusException.FailureReason.MessagingEntityNotFound)); + } + } +} From 8b34598d0de72c85ce35a338663e4360eb250423 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Mon, 8 Jun 2020 11:38:36 -0700 Subject: [PATCH 2/3] Added -> Add --- sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md b/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md index a262b4773e899..b2ad354609e29 100644 --- a/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md @@ -7,7 +7,7 @@ Thank you to our developer community members who helped to make the Service Bus - Sean Feldman _([GitHub](https://github.com/SeanFeldman))_ ### Added -- Added the ServiceBusManagementClient for CRUD operations on a namespace +- Add the ServiceBusManagementClient for CRUD operations on a namespace - Add constructor for ServiceBusMessage taking a string - Use the BinaryData type for ServiceBusMessage.Body - Add diagnostic tracing From bab23abd0795d08cdb21aed20e64f85fd1b69fea Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Mon, 8 Jun 2020 11:47:29 -0700 Subject: [PATCH 3/3] Update version in readme --- sdk/servicebus/Azure.Messaging.ServiceBus/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/README.md b/sdk/servicebus/Azure.Messaging.ServiceBus/README.md index 6084053d26fcc..45d2529dd6e95 100755 --- a/sdk/servicebus/Azure.Messaging.ServiceBus/README.md +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/README.md @@ -37,7 +37,7 @@ To quickly create the needed Service Bus resources in Azure and to receive a con Install the Azure Service Bus client library for .NET with [NuGet](https://www.nuget.org/): ```PowerShell -dotnet add package Azure.Messaging.ServiceBus --version 7.0.0-preview.2 +dotnet add package Azure.Messaging.ServiceBus --version 7.0.0-preview.3 ``` ### Authenticate the client