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);
        }
예제 #2
0
        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
        }
예제 #3
0
            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 void CreateNotebook()
 {
     #region Snippet:CreateNotebook
     Notebook notebook = new Notebook(
         new NotebookMetadata
     {
         LanguageInfo = new NotebookLanguageInfo(name: "Python")
     },
         nbformat: 4,
         nbformatMinor: 2,
         new List <NotebookCell>()
         );
     NotebookCreateOrUpdateNotebookOperation operation = notebookClient.StartCreateOrUpdateNotebook("MyNotebook", new NotebookResource(notebook));
     NotebookResource notebookResource = operation.WaitForCompletionAsync().ConfigureAwait(true).GetAwaiter().GetResult();
     #endregion
 }
        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);
        }
예제 #6
0
        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
        }
예제 #7
0
        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");
        }