本文整理汇总了C#中NamespaceManager.CreateEventHubIfNotExists方法的典型用法代码示例。如果您正苦于以下问题:C# NamespaceManager.CreateEventHubIfNotExists方法的具体用法?C# NamespaceManager.CreateEventHubIfNotExists怎么用?C# NamespaceManager.CreateEventHubIfNotExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceManager
的用法示例。
在下文中一共展示了NamespaceManager.CreateEventHubIfNotExists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
try
{
// Connection String as can be found on the azure portal https://manage.windowsazure.com/microsoft.onmicrosoft.com#Workspaces/ServiceBusExtension/namespaces
//
// The needed Shared access policy is Manage, this can either be the RootManageSharedAccessKey or one create with Manage priviledges
// "Endpoint = sb://NAMESPACE.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=THISISMYKEY";
var policyName = "RootManageSharedAccessKey";
var policySharedAccessKey = "THISISMYKEY";
var serviceBusNamespace = "NAMESPACE";
var credentials = TokenProvider.CreateSharedAccessSignatureTokenProvider(policyName, policySharedAccessKey);
// access the namespace
var serviceBusUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceBusNamespace, string.Empty);
var manager = new NamespaceManager(serviceBusUri, credentials);
// Create the eventhub if needed
var description = manager.CreateEventHubIfNotExists("MyHub");
Console.WriteLine("AT: " + description.CreatedAt + " EventHub:" + description.Path + " Partitions: " + description.PartitionIds);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.ReadLine();
}