To check if library is installed on cluster using azure cli

n k 106 Reputation points
2022-08-17T03:24:18.777+00:00

Hello Experts,
Am new to CLI and wanted to check if there is a way to check if any given library is installed on cluster using databricks cli.
Command 'databricks libraries list - h' gives below
231798-image.png

if we cannot get output in json how can i check if a given library is installed ?

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
1,904 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShaktiSingh-MSFT 13,191 Reputation points Microsoft Employee
    2022-08-17T11:30:10.407+00:00

    Hi @n k ,

    In order to view the Libraries inside a Databricks cluster, perform below mentioned steps in Azure CLI:

    1. Create a virtual environment in which you can install the Databricks CLI. In the snippet below, you create a virtual environment called databrickscli. virtualenv -p /usr/bin/python2.7 databrickscli
      232041-image.png

    2.Switch to the virtual environment you created.

    source databrickscli/bin/activate  
    

    3.Install the Databricks CLI.

    pip install databricks-cli  
    

    231900-image.png

    4.Set up authentication with Databricks by using the access token that you must have created, listed as part of prerequisites. Use the following command:

    databricks configure --token  
    

    231989-image.png

    You will receive the following prompts:
    • First, you are prompted to enter the Databricks host. Enter the URL from the Databricks portal as below:

    231990-image.png

    • Next, you are prompted to enter a token.
    Token creation steps:
    Login to Databricks UI , from left panel go to Settings->User Settings:

    231976-image.png

    Click on Generate New Token. In the Comment give Token Usage(optional) and click Generate.

    232032-image.png

    A token will be created as shown below. Make sure to copy as it won’t be shown again

    232051-image.png

    Use the same copied token in the Step 4 configure token CLI command when prompted to write Token.

    5.To list all the Databricks clusters that you have in your workspace.

    databricks clusters list  
    

    6.To list all Libraries in cluster id:

    databricks libraries list --cluster-id <cluster-id>  
    

    232061-image.png

    This Library list will be the same which is visible when we open Cluster from Databricks Portal :

    232033-image.png

    Microsoft official documentation page link for the same is:

    databricks-cli-from-azure-cloud-shell
    libraries-cli

    Hope this will help. Please let us know if any further queries.


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.
      Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification