public SynapseAnalyticsArtifactsClient(string workspaceName, IAzureContext context) { if (context == null) { throw new SynapseException(Resources.InvalidDefaultSubscription); } Settings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; Settings.Converters.Add(new TransformationJsonConverter()); Settings.Converters.Add(new PolymorphicDeserializeJsonConverter <PSActivity>("type")); Settings.Converters.Add(new PolymorphicDeserializeJsonConverter <PSLinkedService>("type")); Settings.Converters.Add(new PolymorphicDeserializeJsonConverter <PSTrigger>("type")); string suffix = context.Environment.GetEndpoint(AzureEnvironment.ExtendedEndpoint.AzureSynapseAnalyticsEndpointSuffix); Uri uri = new Uri("https://" + workspaceName + "." + suffix); _pipelineClient = new PipelineClient(uri, new AzureSessionCredential(context)); _pipelineRunClient = new PipelineRunClient(uri, new AzureSessionCredential(context)); _linkedServiceClient = new LinkedServiceClient(uri, new AzureSessionCredential(context)); _notebookClient = new NotebookClient(uri, new AzureSessionCredential(context)); _triggerClient = new TriggerClient(uri, new AzureSessionCredential(context)); _triggerRunClient = new TriggerRunClient(uri, new AzureSessionCredential(context)); }
public SynapseAnalyticsArtifactsClient(string workspaceName, IAzureContext context) { if (context == null) { throw new AzPSInvalidOperationException(Resources.InvalidDefaultSubscription); } _context = context; string suffix = context.Environment.GetEndpoint(AzureEnvironment.ExtendedEndpoint.AzureSynapseAnalyticsEndpointSuffix); Uri uri = new Uri("https://" + workspaceName + "." + suffix); _endpoint = uri; _pipelineClient = new PipelineClient(uri, new AzureSessionCredential(context)); _pipelineRunClient = new PipelineRunClient(uri, new AzureSessionCredential(context)); _linkedServiceClient = new LinkedServiceClient(uri, new AzureSessionCredential(context)); _notebookClient = new NotebookClient(uri, new AzureSessionCredential(context)); _triggerClient = new TriggerClient(uri, new AzureSessionCredential(context)); _triggerRunClient = new TriggerRunClient(uri, new AzureSessionCredential(context)); _datasetClient = new DatasetClient(uri, new AzureSessionCredential(context)); _dataFlowClient = new DataFlowClient(uri, new AzureSessionCredential(context)); _dataFlowDebugSessionClient = new DataFlowDebugSessionClient(uri, new AzureSessionCredential(context)); _bigDataPoolsClient = new BigDataPoolsClient(uri, new AzureSessionCredential(context)); _sparkJobDefinitionClient = new SparkJobDefinitionClient(uri, new AzureSessionCredential(context)); _sqlScriptClient = new SqlScriptClient(uri, new AzureSessionCredential(context)); }
public async Task TestDeleteNotebook() { NotebookClient client = CreateClient(); string notebookName = Recording.GenerateId("Notebook", 16); Notebook notebook = new Notebook( new NotebookMetadata { LanguageInfo = new NotebookLanguageInfo(name: "Python") }, nbformat: 4, nbformatMinor: 2, new List <NotebookCell>() ); NotebookCreateOrUpdateNotebookOperation createOperation = await client.StartCreateOrUpdateNotebookAsync(notebookName, new NotebookResource(notebookName, notebook)); await createOperation.WaitForCompletionAsync(); NotebookDeleteNotebookOperation deleteOperation = await client.StartDeleteNotebookAsync(notebookName); Response response = await deleteOperation.WaitForCompletionAsync(); Assert.AreEqual(200, response.Status); }
public override void StartTestRecording() { base.StartTestRecording(); PipelineClient = CreatePipelineClient(); NotebookClient = CreateNotebookClient(); }
public async Task TestDeleteNotebook() { NotebookClient client = CreateClient(); NotebookResource resource = await DisposableNotebook.CreateResource(client, this.Recording); NotebookDeleteNotebookOperation operation = await client.StartDeleteNotebookAsync(resource.Name); await operation.WaitAndAssertSuccessfulCompletion(); }
public async Task TestDeleteNotebook() { var operation = await NotebookClient.StartDeleteNotebookAsync("MyNotebook"); while (!operation.HasValue) { operation.UpdateStatus(); } Assert.AreEqual(200, operation.Value.Status); }
public async Task TestGetSummary() { NotebookClient client = CreateClient(); await using DisposableNotebook notebook = await DisposableNotebook.Create(client, this.Recording); AsyncPageable <NotebookResource> summary = client.GetNotebookSummaryByWorkSpaceAsync(); Assert.GreaterOrEqual((await summary.ToListAsync()).Count, 1); }
public async Task TestGetNotebook() { await foreach (var expectedNotebook in NotebookClient.GetNotebooksByWorkspaceAsync()) { NotebookResource actualNotebook = await NotebookClient.GetNotebookAsync(expectedNotebook.Name); Assert.AreEqual(expectedNotebook.Name, actualNotebook.Name); Assert.AreEqual(expectedNotebook.Id, actualNotebook.Id); Assert.AreEqual(expectedNotebook.Properties.BigDataPool?.ReferenceName, actualNotebook.Properties.BigDataPool?.ReferenceName); } }
public async Task CreateAndUploadNotebook() { #region Snippet:CreateNotebookClient #if SNIPPET // Replace the string below with your actual endpoint url. string endpoint = "<my-endpoint-url>"; #else string endpoint = TestEnvironment.EndpointUrl; #endif var client = new NotebookClient(endpoint: new Uri(endpoint), credential: new DefaultAzureCredential()); #endregion #region Snippet:ConfigureNotebookResource string notebookName = "Test-Notebook"; var cell = new NotebookCell("code", new NotebookMetadata(), new string[] { "from azureml.opendatasets import NycTlcYellow\n", "\n", "data = NycTlcYellow()\n", "df = data.to_spark_dataframe()\n", "# Display 10 rows\n", "display(df.limit(10))" }); var newNotebook = new Notebook(new NotebookMetadata(), 4, 2, new NotebookCell[] { cell }); var notebookResource = new NotebookResource(notebookName, newNotebook); #endregion #region Snippet:CreateNotebook NotebookCreateOrUpdateNotebookOperation operation = await client.StartCreateOrUpdateNotebookAsync(notebookName, notebookResource); await operation.WaitForCompletionAsync(); Console.WriteLine("The notebook is created"); #endregion #region Snippet:RetrieveNotebook NotebookResource retrievedNotebook = client.GetNotebook(notebookName); #endregion #region Snippet:ListNotebooks Pageable <NotebookResource> notebooks = client.GetNotebooksByWorkspace(); foreach (NotebookResource notebook in notebooks) { Console.WriteLine(notebook.Name); } #endregion #region Snippet:DeleteNotebook NotebookDeleteNotebookOperation deleteNotebookOperation = client.StartDeleteNotebook(notebookName); await deleteNotebookOperation.WaitForCompletionResponseAsync(); #endregion }
public void CreateClient() { // Environment variable with the Synapse workspace endpoint. string workspaceUrl = TestEnvironment.WorkspaceUrl; #region Snippet:CreateNotebookClient // Create a new notebook client using the default credential from Azure.Identity using environment variables previously set, // including AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID. NotebookClient client = new NotebookClient(endpoint: new Uri(workspaceUrl), credential: new DefaultAzureCredential()); #endregion this.notebookClient = client; }
public static async ValueTask <NotebookResource> CreateResource(NotebookClient client, TestRecording recording) { string name = recording.GenerateId("Notebook", 16); Notebook notebook = new Notebook( new NotebookMetadata { LanguageInfo = new NotebookLanguageInfo(name: "Python") }, notebookFormat: 4, notebookFormatMinor: 2, new List <NotebookCell>() ); NotebookCreateOrUpdateNotebookOperation createOperation = await client.StartCreateOrUpdateNotebookAsync(name, new NotebookResource(name, notebook)); return(await createOperation.WaitForCompletionAsync()); }
public async Task TestCreateNotebook() { Notebook notebook = new Notebook( new NotebookMetadata { LanguageInfo = new NotebookLanguageInfo(name: "Python") }, nbformat: 4, nbformatMinor: 2, new List <NotebookCell>() ); string notebookName = Recording.GenerateName("Notebook"); NotebookCreateOrUpdateNotebookOperation operation = await NotebookClient.StartCreateOrUpdateNotebookAsync(notebookName, new NotebookResource(notebookName, notebook)); NotebookResource notebookResource = await operation.WaitForCompletionAsync(); Assert.AreEqual(notebookName, notebookResource.Name); }
public async Task TestGetNotebook() { NotebookClient client = CreateClient(); await using DisposableNotebook notebook = await DisposableNotebook.Create(client, this.Recording); IList <NotebookResource> notebooks = await client.GetNotebooksByWorkspaceAsync().ToListAsync(); Assert.GreaterOrEqual(notebooks.Count, 1); foreach (var expectedNotebook in notebooks) { NotebookResource actualNotebook = await client.GetNotebookAsync(expectedNotebook.Name); Assert.AreEqual(expectedNotebook.Name, actualNotebook.Name); Assert.AreEqual(expectedNotebook.Id, actualNotebook.Id); Assert.AreEqual(expectedNotebook.Properties.BigDataPool?.ReferenceName, actualNotebook.Properties.BigDataPool?.ReferenceName); } }
public async Task TestCreateNotebook() { Notebook notebook = new Notebook( new NotebookMetadata { LanguageInfo = new NotebookLanguageInfo(name: "Python") }, nbformat: 4, nbformatMinor: 2, new List <NotebookCell>() ); var operation = await NotebookClient.StartCreateOrUpdateNotebookAsync("MyNotebook", new NotebookResource(notebook)); while (!operation.HasValue) { operation.UpdateStatus(); } Assert.AreEqual("MyNotebook", operation.Value.Name); }
public async Task NotebookSample() { #region Snippet:CreateNotebookClient // Replace the string below with your actual endpoint url. string endpoint = "<my-endpoint-url>"; /*@@*/ endpoint = TestEnvironment.EndpointUrl; NotebookClient client = new NotebookClient(endpoint: new Uri(endpoint), credential: new DefaultAzureCredential()); #endregion #region Snippet:CreateNotebook Notebook newNotebook = new Notebook( new NotebookMetadata { LanguageInfo = new NotebookLanguageInfo(name: "Python") }, nbformat: 4, nbformatMinor: 2, new List <NotebookCell>() ); string notebookName = "MyNotebook"; NotebookCreateOrUpdateNotebookOperation operation = client.StartCreateOrUpdateNotebook(notebookName, new NotebookResource(notebookName, newNotebook)); Response <NotebookResource> createdNotebook = await operation.WaitForCompletionAsync(); #endregion #region Snippet:RetrieveNotebook NotebookResource retrievedNotebook = client.GetNotebook("MyNotebook"); #endregion #region Snippet:ListNotebooks Pageable <NotebookResource> notebooks = client.GetNotebooksByWorkspace(); foreach (NotebookResource notebook in notebooks) { System.Console.WriteLine(notebook.Name); } #endregion #region Snippet:DeleteNotebook client.StartDeleteNotebook("MyNotebook"); #endregion }
public async Task TestRenameLinkedService() { NotebookClient client = CreateClient(); NotebookResource resource = await DisposableNotebook.CreateResource(client, Recording); string newNotebookName = Recording.GenerateId("Notebook2", 16); NotebookRenameNotebookOperation renameOperation = await client.StartRenameNotebookAsync(resource.Name, new ArtifactRenameRequest() { NewName = newNotebookName }); await renameOperation.WaitForCompletionResponseAsync(); NotebookResource notebook = await client.GetNotebookAsync(newNotebookName); Assert.AreEqual(newNotebookName, notebook.Name); NotebookDeleteNotebookOperation operation = await client.StartDeleteNotebookAsync(newNotebookName); await operation.WaitForCompletionResponseAsync(); }
public async Task CreateAndUploadNotebook() { string notebookName = "demo_notebook"; string endpoint = TestEnvironment.EndpointUrl; var client = new NotebookClient(endpoint: new Uri(endpoint), credential: new DefaultAzureCredential()); var cell = new NotebookCell("code", new NotebookMetadata(), new string[] { "from azureml.opendatasets import NycTlcYellow\n", "\n", "data = NycTlcYellow()\n", "df = data.to_spark_dataframe()\n", "# Display 10 rows\n", "display(df.limit(10))" }); var notebook = new Notebook(new NotebookMetadata(), 4, 2, new NotebookCell[] { cell }); var notebookResource = new NotebookResource(notebookName, notebook); NotebookCreateOrUpdateNotebookOperation operation = await client.StartCreateOrUpdateNotebookAsync(notebookName, notebookResource); await operation.WaitForCompletionAsync(); Console.WriteLine("Notebook is created"); }
public static async ValueTask <DisposableNotebook> Create(NotebookClient client, TestRecording recording) => new DisposableNotebook(client, await CreateResource(client, recording));
private DisposableNotebook(NotebookClient client, NotebookResource resource) { _client = client; Resource = resource; }