コード例 #1
0
        public override void ExecuteCmdlet()
        {
            switch (ParameterSetName)
            {
            case CreateByNameAndEnableAutoScaleParameterSet:
            case CreateByParentObjectAndEnableAutoScaleParameterSet:
                this.enableAutoScale = true;
                break;
            }

            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                this.WorkspaceName     = this.WorkspaceObject.Name;
            }

            if (string.IsNullOrEmpty(this.ResourceGroupName))
            {
                this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName);
            }

            BigDataPoolResourceInfo existingSparkPool = null;

            try
            {
                existingSparkPool = this.SynapseAnalyticsClient.GetSparkPool(this.ResourceGroupName, this.WorkspaceName, this.Name);
            }
            catch
            {
                existingSparkPool = null;
            }

            if (existingSparkPool != null)
            {
                throw new AzPSInvalidOperationException(string.Format(Resources.SynapseSparkPoolExists, this.Name, this.ResourceGroupName, this.WorkspaceName));
            }

            Workspace existingWorkspace = null;

            try
            {
                existingWorkspace = this.SynapseAnalyticsClient.GetWorkspace(this.ResourceGroupName, this.WorkspaceName);
            }
            catch
            {
                existingWorkspace = null;
            }

            if (existingWorkspace == null)
            {
                throw new AzPSResourceNotFoundCloudException(string.Format(Resources.WorkspaceDoesNotExist, this.WorkspaceName));
            }

            LibraryRequirements libraryRequirements = null;

            if (this.IsParameterBound(c => c.LibraryRequirementsFilePath))
            {
                var powerShellDestinationPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(LibraryRequirementsFilePath);

                libraryRequirements = new LibraryRequirements
                {
                    Filename = Path.GetFileName(powerShellDestinationPath),
                    Content  = this.ReadFileAsText(powerShellDestinationPath),
                };
            }

            var createParams = new BigDataPoolResourceInfo
            {
                Location       = existingWorkspace.Location,
                Tags           = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true),
                NodeCount      = this.enableAutoScale ? (int?)null : this.NodeCount,
                NodeSizeFamily = NodeSizeFamily.MemoryOptimized,
                NodeSize       = NodeSize,
                AutoScale      = !this.enableAutoScale ? null : new AutoScaleProperties
                {
                    Enabled      = this.enableAutoScale,
                    MinNodeCount = AutoScaleMinNodeCount,
                    MaxNodeCount = AutoScaleMaxNodeCount
                },
                AutoPause = !EnableAutoPause ? null : new AutoPauseProperties
                {
                    Enabled        = EnableAutoPause.IsPresent,
                    DelayInMinutes = AutoPauseDelayInMinute
                },
                SparkVersion        = this.SparkVersion,
                LibraryRequirements = libraryRequirements
            };

            if (this.ShouldProcess(this.Name, string.Format(Resources.CreatingSynapseSparkPool, this.ResourceGroupName, this.WorkspaceName, this.Name)))
            {
                var result = new PSSynapseSparkPool(this.SynapseAnalyticsClient.CreateOrUpdateSparkPool(this.ResourceGroupName, this.WorkspaceName, this.Name, createParams));
                WriteObject(result);
            }
        }
コード例 #2
0
 public PSLibraryRequirements(LibraryRequirements libraryRequirements)
 {
     this.Time     = libraryRequirements?.Time;
     this.Content  = libraryRequirements?.Content;
     this.Filename = libraryRequirements?.Filename;
 }