Ejemplo n.º 1
0
        public PSKustoCluster CreateOrUpdateCluster(string resourceGroupName,
                                                    string clusterName,
                                                    string location,
                                                    string skuName                 = null,
                                                    int?capacity                   = null,
                                                    Hashtable customTags           = null,
                                                    PSKustoCluster existingCluster = null)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByCluster(clusterName);
            }

            var tags = (customTags != null)
                ? TagsConversionHelper.CreateTagDictionary(customTags, true)
                : null;

            Cluster newOrUpdatedCluster;

            if (existingCluster != null)
            {
                var updateParameters = new ClusterUpdate();
                newOrUpdatedCluster = _client.Clusters.Update(resourceGroupName, clusterName, updateParameters);
            }
            else
            {
                newOrUpdatedCluster = _client.Clusters.CreateOrUpdate(
                    resourceGroupName,
                    clusterName,
                    new Cluster()
                {
                    Location = location,
                    Tags     = tags,
                    Sku      = new AzureSku(skuName, capacity),
                });
            }

            return(new PSKustoCluster(newOrUpdatedCluster));
        }
Ejemplo n.º 2
0
        public bool CheckIfClusterExists(string resourceGroupName, string clusterName, out PSKustoCluster cluster)
        {
            try
            {
                cluster = GetCluster(resourceGroupName, clusterName);
                return(true);
            }
            catch (CloudException ex)
            {
                if ((ex.Response != null && ex.Response.StatusCode == HttpStatusCode.NotFound) || ex.Message.Contains(string.Format(Properties.Resources.FailedToDiscoverResourceGroup, clusterName,
                                                                                                                                    _subscriptionId)))
                {
                    cluster = null;
                    return(false);
                }

                throw;
            }
        }