First we will go to service bus:
And we will create one service bus:
After we created service bus, we can create either queue or topic. Topic is like a "view of queues" - can be understood like view in MS SQL Server. Topic and queues can be created manually or programmatically.
One example of creating topics, is something like:
TokenProvider tokenProvider = TokenProvider.CreateSharedSecretTokenProvider (TopicUtilities.GetIssuerName (), TopicUtilities.GetIssuerKey ()); Uri serviceUri = ServiceBusEnvironment.CreateServiceUri ("sb", TopicUtilities.GetServiceNamespace (), string.Empty); NamespaceManager namespaceManager = new NamespaceManager (serviceUri, tokenProvider);
Where GetIssuerName, GetIssuerKey, and GetServiceNamespace are like:
public static String GetIssuerName() { if (_IssuerName == null) { lock (SYNC_LOCK) { if (_IssuerName == null) { _IssuerName = ReadAttribute("myNameSpace.something.Client.IssuerName", DefaulIssuerName); } } } return _IssuerName; } public static String GetIssuerKey() { if (_IssuerKey == null) { lock (SYNC_LOCK) { if (_IssuerKey == null) { _IssuerKey = ReadAttribute("myNameSpace.something.Client.IssuerKey");
} } } return _IssuerKey; } public static String GetServiceNamespace() { if (_ServiceNamespace == null) { lock (SYNC_LOCK) { if (_ServiceNamespace == null) { _ServiceNamespace = ReadAttribute("myNameSpace.something.Client.ServiceNamespace");
} } } return _ServiceNamespace; }
Then in, for example, ServiceConfiguration.Local.myApp.cscfg you must have something like:
<ConfigurationSettings> <Setting name="myNameSpace.something.Client.IssuerName" value="owner" /> <Setting name="myNameSpace.something.Client.IssuerKey" value="myKey" /> <Setting name="myNameSpace.something.Client.ServiceNamespace" value="stanko2" /> </ConfigurationSettings>
Where myKey you can get if you click on service bus, and then on the access key, like on the picture
ServiceConfiguration.Local.myApp.cscfg is configuration if you want to deploy your app to Azure, but first to test it locally, so this configuration is for local Azure deployment.
For command line test, you can just something like:
NamespaceManager namespaceManager = NamespaceManager.Create();
but in your app.config you must to have something like:
<?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <!-- Service Bus specific app setings for messaging connections --> <add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://stanko.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=Bqcy7BC020Top5t1jcQnJ7CZN23t2JmqhpXwIRDGjEU=" /> </appSettings> </configuration>
None of these examples were not tested.