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 CreateDeleteNamespace() { //create namespace and wait for completion string namespaceName = await CreateValidNamespaceName("testnamespacemgmt"); _resourceGroup = await CreateResourceGroupAsync(); EventHubNamespaceCollection namespaceCollection = _resourceGroup.GetEventHubNamespaces(); EventHubNamespace eventHubNamespace = (await namespaceCollection.CreateOrUpdateAsync(true, 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(true); //validate if deleted successfully eventHubNamespace = await namespaceCollection.GetIfExistsAsync(namespaceName); Assert.IsNull(eventHubNamespace); Assert.IsFalse(await namespaceCollection.ExistsAsync(namespaceName)); }
public async Task Get() { #region Snippet:Managing_Namespaces_GetNamespace EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces(); EventHubNamespace eventHubNamespace = await namespaceCollection.GetAsync("myNamespace"); Console.WriteLine(eventHubNamespace.Id.Name); #endregion }
public async Task Delete() { #region Snippet:Managing_Namespaces_DeleteNamespace EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces(); EventHubNamespace eventHubNamespace = await namespaceCollection.GetAsync("myNamespace"); await eventHubNamespace.DeleteAsync(true); #endregion }
public async Task AddTag() { #region Snippet:Managing_Namespaces_AddTag EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces(); EventHubNamespace eventHubNamespace = await namespaceCollection.GetAsync("myNamespace"); await eventHubNamespace.AddTagAsync("key", "value"); #endregion }