public async Task CreateGetUpdateDeleteCluster()
        {
            //create a cluster
            _resourceGroup = await CreateResourceGroupAsync();

            string clusterName = Recording.GenerateAssetName("cluster");
            EventHubClusterCollection clusterCollection = _resourceGroup.GetEventHubClusters();
            EventHubClusterData       parameter         = new EventHubClusterData(AzureLocation.EastUS2);
            EventHubClusterResource   cluster           = (await clusterCollection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, parameter)).Value;

            Assert.NotNull(cluster);
            Assert.AreEqual(cluster.Data.Name, clusterName);

            //get the cluster
            cluster = await clusterCollection.GetAsync(clusterName);

            Assert.NotNull(cluster);
            Assert.AreEqual(cluster.Data.Name, clusterName);

            //get the namespace under cluster
            SubResource subResource = null;

            await foreach (var namespaceId in cluster.GetNamespacesAsync())
            {
                subResource = namespaceId;
                break;
            }

            Assert.NotNull(subResource);

            //update the cluster
            cluster.Data.Tags.Add("key", "value");
            cluster = (await cluster.UpdateAsync(WaitUntil.Completed, cluster.Data)).Value;
            Assert.AreEqual(cluster.Data.Tags["key"], "value");

            //delete the cluster
            await cluster.DeleteAsync(WaitUntil.Completed);

            Assert.IsFalse(await clusterCollection.ExistsAsync(clusterName));
        }
Exemple #2
0
 public static Response <EventHubClusterResource> GetEventHubCluster(this ResourceGroupResource resourceGroupResource, string clusterName, CancellationToken cancellationToken = default)
 {
     return(resourceGroupResource.GetEventHubClusters().Get(clusterName, cancellationToken));
 }
Exemple #3
0
 public static async Task <Response <EventHubClusterResource> > GetEventHubClusterAsync(this ResourceGroupResource resourceGroupResource, string clusterName, CancellationToken cancellationToken = default)
 {
     return(await resourceGroupResource.GetEventHubClusters().GetAsync(clusterName, cancellationToken).ConfigureAwait(false));
 }