public override void ExecuteCmdlet()
        {
            PSCluster parameters = new PSCluster()
            {
                Name     = this.ClusterName,
                Location = this.Location,
                Identity = new PSIdentity(this.IdentityType),
                Sku      = new PSClusterSku(this.SkuName, this.SkuCapacity),
                Tags     = this.Tag
            };

            if (ShouldProcess(this.ClusterName,
                              string.Format("create cluster: {0} in resource group: {1}", this.ClusterName, this.ResourceGroupName)))
            {
                WriteObject(this.OperationalInsightsClient.CreatePSCluster(this.ResourceGroupName, this.ClusterName, parameters));
            }
        }
Ejemplo n.º 2
0
        public override void ExecuteCmdlet()
        {
            PSCluster parameters = new PSCluster()
            {
                Name     = this.ClusterName,
                Location = this.Location,
                Identity = new PSIdentity(this.IdentityType),
                Sku      = new PSClusterSku(this.SkuName ?? AllowedClusterServiceTiers.CapacityReservation.ToString(), this.SkuCapacity),
                Tags     = this.Tag,
                IsDoubleEncryptionEnabled  = this.IsDoubleEncryptionEnabled,
                IsAvailabilityZonesEnabled = this.IsAvailabilityZonesEnabled,
                BillingType        = this.BillingType,
                KeyVaultProperties = PSKeyVaultProperties.CreateProperties(this.KeyVaultUri, this.KeyName, this.KeyVersion),
            };

            if (ShouldProcess(this.ClusterName,
                              string.Format("create cluster: {0} in resource group: {1}", this.ClusterName, this.ResourceGroupName)))
            {
                WriteObject(this.OperationalInsightsClient.CreatePSCluster(this.ResourceGroupName, this.ClusterName, parameters));
            }
        }
Ejemplo n.º 3
0
        public override void ExecuteCmdlet()
        {
            var vmss               = GetVmss(this.NodeType);
            var ext                = FindFabricVmExt(vmss.VirtualMachineProfile.ExtensionProfile.Extensions);
            var cluster            = GetCurrentCluster();
            var nodeType           = GetNodeType(cluster, this.NodeType);
            var oldDurabilityLevel = GetDurabilityLevel(nodeType.DurabilityLevel);
            var newDurabilityLevel = this.DurabilityLevel;
            var isMismatched       = oldDurabilityLevel != GetDurabilityLevel(vmss);

            if (newDurabilityLevel == oldDurabilityLevel && !isMismatched)
            {
                WriteObject(new PSCluster(cluster), true);
                return;
            }

            if (isMismatched)
            {
                WriteWarning(ServiceFabricProperties.Resources.DurabilityLevelMismatches);
            }

            if (!ChangeAllowed(oldDurabilityLevel, newDurabilityLevel, vmss.Sku.Name))
            {
                throw new PSInvalidOperationException(
                          string.Format(
                              ServiceFabricProperties.Resources.CannotChangeDurabilityFrom,
                              oldDurabilityLevel,
                              newDurabilityLevel));
            }

            if (newDurabilityLevel == DurabilityLevel.Bronze &&
                !string.IsNullOrEmpty(this.Sku) &&
                !this.Sku.Equals(vmss.Sku.Name))
            {
                throw new PSInvalidOperationException(
                          ServiceFabricProperties.Resources.CannotUpdateSkuWithBronzeDurability);
            }

            if (!string.IsNullOrEmpty(Sku))
            {
                vmss.Sku = new Sku(this.Sku, Constants.DefaultTier, vmss.Sku.Capacity);
            }

            ((JObject)ext.Settings)["durabilityLevel"]    = this.DurabilityLevel.ToString();
            ((JObject)ext.Settings)["enableParallelJobs"] = true;

            if (ShouldProcess(target: this.Name, action: string.Format("Update fabric durability level to {0} of {1}", this.DurabilityLevel, this.NodeType)))
            {
                var vmssTask = ComputeClient.VirtualMachineScaleSets.CreateOrUpdateAsync(
                    ResourceGroupName,
                    vmss.Name,
                    vmss);

                nodeType.DurabilityLevel = this.DurabilityLevel.ToString();

                var patchArg = new ClusterUpdateParameters
                {
                    NodeTypes = cluster.NodeTypes
                };

                var patchTask = PatchAsync(patchArg);

                WriteClusterAndVmssVerboseWhenUpdate(new List <Task>()
                {
                    vmssTask, patchTask
                }, true, this.NodeType);

                var psCluster = new PSCluster(patchTask.Result);
                WriteObject(psCluster, true);
            }
        }
        public virtual PSCluster CreatePSCluster(string resourceGroupName, string clusterName, PSCluster parameters)
        {
            PSCluster existingCluster;

            try
            {
                existingCluster = GetPSCluster(resourceGroupName, clusterName);
            }
            catch (RestException)
            {
                existingCluster = null;
            }

            if (existingCluster != null)
            {
                throw new PSInvalidOperationException(string.Format("cluster: '{0}' already exists in '{1}'. Please use Update-AzOperationalInsightsCluster for updating.", clusterName, resourceGroupName));
            }

            return(new PSCluster(this.OperationalInsightsManagementClient.Clusters.CreateOrUpdate(resourceGroupName, clusterName, parameters.getCluster())));
        }