public async Task GetAllNamespaces() { //create two namespaces string namespaceName1 = await CreateValidNamespaceName("testnamespacemgmt1"); string namespaceName2 = await CreateValidNamespaceName("testnamespacemgmt2"); _resourceGroup = await CreateResourceGroupAsync(); EventHubNamespaceCollection namespaceCollection = _resourceGroup.GetEventHubNamespaces(); _ = (await namespaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName1, new EventHubNamespaceData(DefaultLocation))).Value; _ = (await namespaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName2, new EventHubNamespaceData(DefaultLocation))).Value; int count = 0; EventHubNamespaceResource namespace1 = null; EventHubNamespaceResource namespace2 = null; //validate await foreach (EventHubNamespaceResource eventHubNamespace in namespaceCollection.GetAllAsync()) { count++; if (eventHubNamespace.Id.Name == namespaceName1) { namespace1 = eventHubNamespace; } if (eventHubNamespace.Id.Name == namespaceName2) { namespace2 = eventHubNamespace; } } Assert.AreEqual(count, 2); VerifyNamespaceProperties(namespace1, true); VerifyNamespaceProperties(namespace2, true); }
public async Task List() { #region Snippet:Managing_Namespaces_ListNamespaces EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces(); await foreach (EventHubNamespace eventHubNamespace in namespaceCollection.GetAllAsync()) { Console.WriteLine(eventHubNamespace.Id.Name); } #endregion }
public async Task ClearNamespaces() { //remove all namespaces under current resource group if (_resourceGroup != null) { EventHubNamespaceCollection namespaceCollection = _resourceGroup.GetEventHubNamespaces(); List <EventHubNamespaceResource> namespaceList = await namespaceCollection.GetAllAsync().ToEnumerableAsync(); foreach (EventHubNamespaceResource eventHubNamespace in namespaceList) { await eventHubNamespace.DeleteAsync(WaitUntil.Completed); } _resourceGroup = null; } }