コード例 #1
0
        /// <summary>
        /// Overriding to add warning message
        /// </summary>
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.InstancePool))
            {
                this.ResourceGroupName = this.InstancePool.ResourceGroupName;
                this.InstancePoolName  = this.InstancePool.InstancePoolName;
                this.ComputeGeneration = this.InstancePool.ComputeGeneration;
                this.Edition           = this.InstancePool.Edition;
                this.SubnetId          = this.InstancePool.SubnetId;
                this.LicenseType       = this.InstancePool.LicenseType;
                this.Location          = this.InstancePool.Location;
            }

            if (this.IsParameterBound(c => c.InstancePoolResourceId))
            {
                var resourceId = new ResourceIdentifier(this.InstancePoolResourceId);
                this.ResourceGroupName = resourceId.ResourceGroupName;
                this.InstancePoolName  = resourceId.ResourceName;

                try
                {
                    AzureSqlInstancePoolCommunicator communicator = new AzureSqlInstancePoolCommunicator(DefaultContext);
                    var instancePool = communicator.GetInstancePool(this.ResourceGroupName, this.InstancePoolName);
                    this.ComputeGeneration = instancePool.Sku.Family;
                    this.Edition           = instancePool.Sku.Tier;
                    this.SubnetId          = instancePool.SubnetId;
                    this.LicenseType       = instancePool.LicenseType;
                    this.Location          = instancePool.Location;
                }
                catch (CloudException ex)
                {
                    if (ex.Response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        // The instance pool does not exist
                        throw new PSArgumentException(
                                  string.Format(Properties.Resources.AzureSqlInstancePoolNotExists, this.InstancePoolName),
                                  "InstancePoolName");
                    }

                    // Unexpected exception
                    throw;
                }
            }

            base.ExecuteCmdlet();
        }
コード例 #2
0
        /// <summary>
        /// Overriding to add warning message
        /// </summary>
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.InstancePool))
            {
                this.ResourceGroupName = this.InstancePool.ResourceGroupName;
                this.InstancePoolName  = this.InstancePool.InstancePoolName;
                this.ComputeGeneration = this.InstancePool.ComputeGeneration;
                this.Edition           = this.InstancePool.Edition;
                this.SubnetId          = this.InstancePool.SubnetId;
                this.LicenseType       = this.InstancePool.LicenseType;
                this.Location          = this.InstancePool.Location;
            }

            if (this.IsParameterBound(c => c.InstancePoolResourceId))
            {
                var resourceId = new ResourceIdentifier(this.InstancePoolResourceId);
                this.ResourceGroupName = resourceId.ResourceGroupName;
                this.InstancePoolName  = resourceId.ResourceName;

                try
                {
                    AzureSqlInstancePoolCommunicator communicator = new AzureSqlInstancePoolCommunicator(DefaultContext);
                    var instancePool = communicator.GetInstancePool(this.ResourceGroupName, this.InstancePoolName);
                    this.ComputeGeneration = instancePool.Sku.Family;
                    this.Edition           = instancePool.Sku.Tier;
                    this.SubnetId          = instancePool.SubnetId;
                    this.LicenseType       = instancePool.LicenseType;
                    this.Location          = instancePool.Location;
                }
                catch (CloudException ex)
                {
                    if (ex.Response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        // The instance pool does not exist
                        throw new PSArgumentException(
                                  string.Format(Properties.Resources.AzureSqlInstancePoolNotExists, this.InstancePoolName),
                                  "InstancePoolName");
                    }

                    // Unexpected exception
                    throw;
                }
            }

            if (ListOfRegionsToShowWarningMessageForGeoBackupStorage.Contains(this.Location.ToLower()))
            {
                if (this.BackupStorageRedundancy == null)
                {
                    if (!Force.IsPresent && !ShouldContinue(
                            string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.Name),
                            string.Format(CultureInfo.InvariantCulture, Properties.Resources.BackupRedundancyNotChosenTakeGeoWarning, this.Name)))
                    {
                        return;
                    }
                }
                else if (string.Equals(this.BackupStorageRedundancy, "Geo", System.StringComparison.OrdinalIgnoreCase))
                {
                    if (!Force.IsPresent && !ShouldContinue(
                            string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.Name),
                            string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyChosenWarning, this.Name)))
                    {
                        return;
                    }
                }
            }

            base.ExecuteCmdlet();
        }