Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Preview 3 #12608

Merged
merged 3 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
16 changes: 15 additions & 1 deletion sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
- 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

### Breaking Changes
- Introduce ServiceBusSessionReceiverOptions/ServiceBusSessionProcessorOptions for creating
ServiceBusSessionReceiver/ServiceBusSessionProcessor
- Make ServiceBusReceivedMessage.Properties IReadOnlyDictionary rather than IDictionary

## 7.0.0-preview.2 (2020-05-04)

Expand Down
2 changes: 1 addition & 1 deletion sdk/servicebus/Azure.Messaging.ServiceBus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions sdk/servicebus/Azure.Messaging.ServiceBus/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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 = "<connection_string>";
string queueName = "<queue_name>";
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);
```
Original file line number Diff line number Diff line change
@@ -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 = "<connection_string>";
//@@ string queueName = "<queue_name>";
//@@ 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<ServiceBusException>().And.Property(nameof(ServiceBusException.Reason)).EqualTo(ServiceBusException.FailureReason.MessagingEntityNotFound));
}
}
}