public async Task Delete()
        {
            #region Snippet:Managing_EventHubs_DeleteEventHub
            EventHubResource eventHub = await eventHubCollection.GetAsync("myEventhub");

            await eventHub.DeleteAsync(WaitUntil.Completed);

            #endregion
        }
예제 #2
0
        public async Task CreateDeleteEventHub()
        {
            //create eventhub
            string           eventhubName = Recording.GenerateAssetName("eventhub");
            EventHubResource eventHub     = (await _eventHubCollection.CreateOrUpdateAsync(WaitUntil.Completed, eventhubName, new EventHubData())).Value;

            Assert.NotNull(eventHub);
            Assert.AreEqual(eventHub.Id.Name, eventhubName);

            //validate if created successfully
            Assert.IsTrue(await _eventHubCollection.ExistsAsync(eventhubName));
            eventHub = await _eventHubCollection.GetAsync(eventhubName);

            //delete eventhub
            await eventHub.DeleteAsync(WaitUntil.Completed);

            //validate
            var exception = Assert.ThrowsAsync <RequestFailedException>(async() => { await _eventHubCollection.GetAsync(eventhubName); });

            Assert.AreEqual(404, exception.Status);
            Assert.IsFalse(await _eventHubCollection.ExistsAsync(eventhubName));
        }