public async Task CreateDeleteNamespace() { //create namespace and wait for completion string namespaceName = await CreateValidNamespaceName("testnamespacemgmt"); _resourceGroup = await CreateResourceGroupAsync(); EventHubNamespaceCollection namespaceCollection = _resourceGroup.GetEventHubNamespaces(); EventHubNamespaceResource eventHubNamespace = (await namespaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, new EventHubNamespaceData(DefaultLocation))).Value; VerifyNamespaceProperties(eventHubNamespace, true); //validate if created successfully eventHubNamespace = await namespaceCollection.GetAsync(namespaceName); Assert.IsTrue(await namespaceCollection.ExistsAsync(namespaceName)); VerifyNamespaceProperties(eventHubNamespace, true); //delete namespace await eventHubNamespace.DeleteAsync(WaitUntil.Completed); //validate if deleted successfully var exception = Assert.ThrowsAsync <RequestFailedException>(async() => { await namespaceCollection.GetAsync(namespaceName); }); Assert.AreEqual(404, exception.Status); Assert.IsFalse(await namespaceCollection.ExistsAsync(namespaceName)); }
public async Task Delete() { #region Snippet:Managing_Namespaces_DeleteNamespace EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces(); EventHubNamespaceResource eventHubNamespace = await namespaceCollection.GetAsync("myNamespace"); await eventHubNamespace.DeleteAsync(WaitUntil.Completed); #endregion }
public async Task GetNamespacesInSubscription() { //create two namespaces in two resourcegroups string namespaceName1 = await CreateValidNamespaceName("testnamespacemgmt1"); string namespaceName2 = await CreateValidNamespaceName("testnamespacemgmt2"); _resourceGroup = await CreateResourceGroupAsync(); ResourceGroupResource resourceGroup = await CreateResourceGroupAsync(); EventHubNamespaceCollection namespaceCollection1 = _resourceGroup.GetEventHubNamespaces(); EventHubNamespaceCollection namespaceCollection2 = resourceGroup.GetEventHubNamespaces(); _ = (await namespaceCollection1.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName1, new EventHubNamespaceData(DefaultLocation))).Value; _ = (await namespaceCollection2.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName2, new EventHubNamespaceData(DefaultLocation))).Value; int count = 0; EventHubNamespaceResource namespace1 = null; EventHubNamespaceResource namespace2 = null; //validate await foreach (EventHubNamespaceResource eventHubNamespace in DefaultSubscription.GetEventHubNamespacesAsync()) { count++; if (eventHubNamespace.Id.Name == namespaceName1) { namespace1 = eventHubNamespace; } if (eventHubNamespace.Id.Name == namespaceName2) { namespace2 = eventHubNamespace; } } VerifyNamespaceProperties(namespace1, true); VerifyNamespaceProperties(namespace2, true); Assert.AreEqual(namespace1.Id.ResourceGroupName, _resourceGroup.Id.Name); Assert.AreEqual(namespace2.Id.ResourceGroupName, resourceGroup.Id.Name); await namespace2.DeleteAsync(WaitUntil.Completed); }