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 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 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 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 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"); }