I need to get data from service bus from my console application, instead of my data I've got System.UnauthorizedAccessException error 401 I've got 2 static readonly string that I don't know how to use You may require one or both of the services below depending on the level of detail that you need-
//sample usage string briefingDetailsByIdURI = string.Format(Constants.BRIEFING_DETAILS_ID_URI, brfId);
public static readonly string ID_URI = "https://trtrtrtr.servicebus.windows.net/trtrtr/trttrttr/{0}";
//sample usage - string URI = string.Format(Constants.sdgsdgg, sgsgsg, sgsgsg);
public static readonly string DETAIL_ID_URI = "https://trtrtrtr.servicebus.windows.net/trtrtr/trrtrttr/{0}/{1}";
I just went in app.config and put this with the right namespace and password
<appSettings>
<!-- Service Bus specific app setings for messaging connections -->
<add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://<namespace>.servicebus.windows.net/;
SharedAccessKeyName=Root stManageSharedAccessKey;SharedAccessKey=<paasword> />
after that I went in my console program.cs
Console.Title = "Receiver2";
// Creating the topic if it does not exist already using the service bus connection string stored in the app.config file
string connectionString =
CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
//appSettings dans appsettings getSettings()
//connection au service bus
var namespaceManager =
NamespaceManager.CreateFromConnectionString(connectionString);
//verification si queue existe
if (!namespaceManager.QueueExists("CommentaireQueue"))
{
namespaceManager.CreateQueue("CommentaireQueue");
}
QueueClient client = QueueClient.Create("CommentaireQueue");
Console.WriteLine("test console");
//boucle infini pour recevoir tous les messages
while (true)
{
var message = client.Receive();
if (message != null)
{
var comm = message.GetBody<string>();
string myString = comm.Contenu;
try
{
Console.WriteLine(myString);
}
finally
{
//enlever le message de la queue
message.Complete();
}
}
}
}