예제 #1
0
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.WorkspaceName = this.WorkspaceObject.Name;
            }

            if (!this.IsParameterBound(c => c.Name))
            {
                string path = this.TryResolvePath(DefinitionFile);
                this.Name = Path.GetFileNameWithoutExtension(path);
            }

            if (this.ShouldProcess(this.WorkspaceName, String.Format(Resources.SettingSynapseNotebook, this.Name, this.WorkspaceName)))
            {
                string           rawJsonContent   = SynapseAnalyticsClient.ReadJsonFileContent(this.TryResolvePath(DefinitionFile));
                Notebook         notebook         = JsonConvert.DeserializeObject <Notebook>(rawJsonContent);
                NotebookResource notebookResource = new NotebookResource(this.Name, notebook);

                if (this.IsParameterBound(c => c.SparkPoolName))
                {
                    NotebookMetadata metadata = notebookResource.Properties.Metadata;
                    var options = new ComputeOptions();

                    string suffix        = DefaultContext.Environment.GetEndpoint(AzureEnvironment.ExtendedEndpoint.AzureSynapseAnalyticsEndpointSuffix);
                    string endpoint      = "https://" + this.WorkspaceName + "." + suffix;
                    var    sparkPoolInfo = SynapseAnalyticsClient.GetBigDataPool(SparkPoolName);

                    options["auth"] = new ComputeOptions
                    {
                        ["type"]         = "AAD",
                        ["authResource"] = DefaultContext.Environment.GetEndpoint(AzureEnvironment.ExtendedEndpoint.AzureSynapseAnalyticsEndpointResourceId)
                    };
                    options["cores"]        = SynapseConstants.ComputeNodeSizes[this.ExecutorSize].Cores;
                    options["memory"]       = SynapseConstants.ComputeNodeSizes[this.ExecutorSize].Memory;
                    options["nodeCount"]    = this.ExecutorCount;
                    options["endpoint"]     = endpoint + "/livyApi/versions/" + SynapseConstants.SparkServiceEndpointApiVersion + "/sparkPools/" + this.SparkPoolName;
                    options["extraHeader"]  = new ComputeOptions();
                    options["id"]           = sparkPoolInfo.Id;
                    options["name"]         = this.SparkPoolName;
                    options["sparkVersion"] = sparkPoolInfo.SparkVersion;
                    options["type"]         = "Spark";
                    metadata.AdditionalProperties.Add("a365ComputeOptions", options);

                    notebookResource.Properties.BigDataPool       = new BigDataPoolReference(BigDataPoolReferenceType.BigDataPoolReference, this.SparkPoolName);
                    notebookResource.Properties.SessionProperties = new NotebookSessionProperties(options["memory"] + "g", (int)options["cores"], options["memory"] + "g", (int)options["cores"], (int)options["nodeCount"]);
                }

                if (this.IsParameterBound(c => c.FolderPath))
                {
                    NotebookFolder folder = new NotebookFolder();
                    folder.Name = this.FolderPath;
                    notebookResource.Properties.Folder = folder;
                }

                WriteObject(new PSNotebookResource(SynapseAnalyticsClient.CreateOrUpdateNotebook(this.Name, notebookResource), this.WorkspaceName));
            }
        }
예제 #2
0
 public PSNotebookFolder(NotebookFolder folder)
 {
     this.Name = folder?.Name;
 }