MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.22k stars 21.37k forks source link

Sender sample code is wrong #8788

Closed lant3rn1969 closed 6 years ago

lant3rn1969 commented 6 years ago

Hi folks, The code you've written to send messages to a topic is wrong. It's based on the 2.0.0.0 nuget package (according to the image), and it's quite different in 3.0.0.0, which is the current version. For example,

  1. The imported namespace is now Microsoft.ServiceBus (not Microsoft.Azure.ServiceBus)
  2. There is no longer an ITopicClient interface
  3. The TopicClient class is an abstract class, and so can't be instantiated. According to the current documentation (https://docs.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.topicclient?view=azure-dotnet), it needs to be created via a factory. Unfortunately, this code is also out of date (MessageFactorySettings does not have a property called Credential), but that may not be your problem...

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

lant3rn1969 commented 6 years ago

Never mind. I used the wrong nuget package. I used WindowsAzure.ServiceBus, which I assume is for the Service Management API?

SaurabhSharma-MSFT commented 6 years ago

@lant3rn1969 Thanks for your feedback! We will investigate and update as appropriate.

Mike-Ubezzi-MSFT commented 6 years ago

It looks like Microsoft.Azure.ServiceBus is the next gen iteration of Azure Service Bus (MaaS).

WindowsAzure.ServiceBus 4.1.9

Microsoft Azure Service Bus Use this for Microsoft Azure Service Bus Queues, Topics, EventHub and Relay backend operations.

It adds Microsoft.ServiceBus.dll along with related configuration files to your project. This library allows AMQP 1.0 to be used as one of the protocols for communication with Microsoft Azure Service Bus.

For more information on Messaging features, please visit: http://azure.microsoft.com/en-us/documentation/services/service-bus/ For more information on Event Hub features, please visit: http://go.microsoft.com/fwlink/?LinkID=403957

Please note that this package requires .Net Framework 4.5.2 Full Profile

-- Versus --

Microsoft.Azure.ServiceBus 3.0.0

This is the next generation Azure Service Bus .NET Standard client library that focuses on queues & topics. For more information about Service Bus, see https://azure.microsoft.com/en-us/services/service-bus/

Release Notes https://github.com/Azure/azure-service-bus-dotnet/releases

Please let me know if you require additional information. Mike

lant3rn1969 commented 6 years ago

Thanks, Mike. This is very helpful.

Cheers, Jack

Jack Q W Cantwell Senior Program Manager | XPander | DES EPIC | Universal Store

Mike-Ubezzi-MSFT commented 6 years ago

@lant3rn1969 We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.