public async Task CreateDeleteNamespace() { //create namespace and wait for completion string namespaceName = await CreateValidNamespaceName("testnamespacemgmt"); _resourceGroup = await CreateResourceGroupAsync(); EventHubNamespaceCollection namespaceCollection = _resourceGroup.GetEventHubNamespaces(); EventHubNamespace eventHubNamespace = (await namespaceCollection.CreateOrUpdateAsync(namespaceName, new EventHubNamespaceData(DefaultLocation))).Value; VerifyNamespaceProperties(eventHubNamespace, true); //validate if created successfully eventHubNamespace = await namespaceCollection.GetAsync(namespaceName); Assert.IsTrue(await namespaceCollection.CheckIfExistsAsync(namespaceName)); VerifyNamespaceProperties(eventHubNamespace, true); //delete namespace await eventHubNamespace.DeleteAsync(); //validate if deleted successfully eventHubNamespace = await namespaceCollection.GetIfExistsAsync(namespaceName); Assert.IsNull(eventHubNamespace); Assert.IsFalse(await namespaceCollection.CheckIfExistsAsync(namespaceName)); }
public async Task GetIfExist() { #region Snippet:Managing_Namespaces_GetNamespaceIfExists EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces(); EventHubNamespace eventHubNamespace = await namespaceCollection.GetIfExistsAsync("foo"); if (eventHubNamespace != null) { Console.WriteLine("namespace 'foo' exists"); } if (await namespaceCollection.CheckIfExistsAsync("bar")) { Console.WriteLine("namespace 'bar' exists"); } #endregion }