Example #1
0
        public async Task AddSetRemoveTag()
        {
            //create namespace
            _resourceGroup = await CreateResourceGroupAsync();

            EventHubNamespaceCollection namespaceCollection = _resourceGroup.GetEventHubNamespaces();
            string namespaceName = await CreateValidNamespaceName("testnamespacemgmt");

            EventHubNamespace eventHubNamespace = (await namespaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, new EventHubNamespaceData(DefaultLocation))).Value;

            //add a tag
            eventHubNamespace = await eventHubNamespace.AddTagAsync("key", "value");

            Assert.AreEqual(eventHubNamespace.Data.Tags.Count, 1);
            Assert.AreEqual(eventHubNamespace.Data.Tags["key"], "value");

            //set the tag
            eventHubNamespace.Data.Tags.Add("key1", "value1");
            eventHubNamespace = await eventHubNamespace.SetTagsAsync(eventHubNamespace.Data.Tags);

            Assert.AreEqual(eventHubNamespace.Data.Tags.Count, 2);
            Assert.AreEqual(eventHubNamespace.Data.Tags["key1"], "value1");

            //remove a tag
            eventHubNamespace = await eventHubNamespace.RemoveTagAsync("key");

            Assert.AreEqual(eventHubNamespace.Data.Tags.Count, 1);

            //wait until provision state is succeeded
            await GetSucceededNamespace(eventHubNamespace);
        }
        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
        }