Jupyter Notebooks for Azure Administrators

Disclaimer

This post is an add-on to the recorded AzureTalks podcast, where I went through the topic of Jupyter Notebooks for Azure Administrators, so here you can find the links and resources I mentioned during the talk. Still, the entire content with my comments is available in the podcast. The blog post can be updated in the future. You can find podcast also on Spotify.

The demos that I showed during the video are available in the GitHub repository: Jupyter-Demo.

Introduction

Jupyter Notebook is an open-source web-based interactive computing environment that allows users to create and share documents containing live code, equations, visualizations, and narrative text. It supports various programming languages, with Python being the most popular choice. “Jupyter” combines three core programming languages: Julia, Python, and R.

In a Jupyter Notebook, users can write and execute code in individual cells, making it easy to experiment and visualize the results step-by-step. This interactive nature makes it an excellent tool for data analysis, scientific computing, machine learning, and educational purposes.

Each notebook runs on a Jupyter server, which can be hosted locally or on a remote server and accessed through a web browser. Notebooks are saved with the file extension .ipynb and can be shared and collaborated.

Jupyter Notebook has gained widespread popularity among data scientists, researchers, educators, and developers due to its flexibility, ease of use, and ability to combine code with explanatory text and visualizations in a single document.

Examples of notebooks

You can find some examples of the Jupyter Notebooks in the Notebook Community.

Online services

You can also work with cloud-hosted Jupyter Notebooks. An example of such a service is Google Colab. Google Colab allows you to create notebooks, work online, and run computations on CPU, GPU, and TPU (for Tensorflow computations).

Also, you can run Jupyter on a dedicated server in your environment to have more control over the environment and data.

Prerequisites

To successfully install Jupyter Notebook, you must install Python 3 or greater on your machine. You can download the latest version of Python from the official website. Also, it would be best to install Node.js installed. Then, you can install Jupyter as a pip package or via brew. More info about installation can be found on jupyter.org/install.

When you run the command jupyter-lab in the chosen folder, the Jupyter environment will run, and in the browser, you will get the main view of Jupyter. Now, you should be able to create your first notebook in Python!

Working with Jupyter Notebooks

Debugger issue

In the console, you can see the below debugger warning:

1
2
3
4
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

The above warning is related to the recent changes in Python (if you have a version higher than 3.11), but at this time, it is not related to our usage, and you can ignore this. You can read more in this issue description on the Jupyter Community Forum.

PowesShell Core, Azure PowerShell, and .NET Interactive

You will need PowerShell Core with [Azure PowerShell to proceed with our exercise. Later, you will need .NET Interactive. .NET Interactive enables you to run .NET family languages within Jupyter Notebooks.

Visual Studio Code

Two extensions are required to work with Jupyter Notebooks in VS Code:

GitHub

Jupyter Notebooks have been rendered on GitHub for a long time: Rendering Notebooks on GitHub.

You can find more info about how Microsoft and GitHub support Jupyter Notebooks here: Learn more about all the notebooks experiences from Microsoft and GitHub.

Exporting notebooks

To export notebooks, you need LaTeX and nbconvert installed.

There are some known issues with exporting notebooks in VS Code:

Polyglot Notebooks

Those notebooks are a new way to work with .NET Interactive and Jupyter Notebook. Thanks to them, we can have multiple types of languages in a single notebook.

SQL

You can find more info about using SQL in .NET Interactive in this blogpost on Microsoft’s blog. Also, you can find the information for SQL connections in the .NET Interactive documentation.

When I prepared the post, I faced the issue described in GitHub, so I could not play with it alone.

Azure Data Studio

Azure Data Studio is a cross-platform tool for data management and connectivity to popular databases. And it also supports playing with Jupyter Notebooks.

Thanks to using the Kusto (KQL) and Azure Monitor Logs extensions in Azure Data Studio, you can connect to Log Analytics Workspaces or Azure Data Explorer clusters and do queries with KQL.

In Azure Data Studio, you have built-in buttons to translate outcomes to charts, Excel, or CSV.

To sum up

Jupyter Notebook is an excellent tool for playing with any data. Thanks to .NET Interactive and Polyglot Notebooks, we can use it with .NET family languages. Also, we can use it with PowerShell, which is a great way to automate our daily tasks. The above text is just an extract of my recording, so I encourage you to watch the entire video. Then you will find more info about the demos and the resources I mentioned.

comments powered by Disqus