How to install azure cli on databricks

Rohit Boddu 466 Reputation points
2022-05-20T11:54:18.353+00:00

Hi Team,

I want to install azure cli in databricks nodes ..could u pls help on how to install it ..

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

1 answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,091 Reputation points
    2022-05-23T18:37:26.553+00:00

    Hello @Rohit Boddu ,
    Thanks for the question and using MS Q&A platform.

    As we understand the ask here is "how to install azure cli in databricks".

    First, let me explain. Azure CLI is a "Command Line Interface." This means you run it from a command prompt. Databricks notebook isn't exactly a command prompt. I do not think it is possible to install Azure CLI on Databricks. If it is, the usage would be very roundabout, indirect, and awkward. More on that after the alternative below.

    While Azure CLI inside Databricks might not work, there is another option. You can install the Python SDK's for the relevant module, and use that directly in a PySpark notebook. This would be more direct and in keeping with the coding experience. The Azure CLI is like the Azure Powershell commands but in a different flavor and OS. You wouldn't use Powershell inside databricks, would you?

    Excerpt from Python SDK overview:

    Because the Azure CLI is written in Python using the management libraries, anything you can do with Azure CLI commands you can also do from a Python script. That said, the CLI commands provide many helpful features such as performing multiple tasks together, automatically handling asynchronous operations, formatting output like connection strings, and so on...

    List of Python libraries for Azure, by Microsoft
    How to install libraries on a cluster.

    Picture for installing library to a single cluster only:
    204776-image.png

    If you are dead-set on invoking the CLI from inside PySpark, you will need the subprocess module. The learning curve for subprocess might outweigh the simplification Azure CLI brings, and that is if it works. I anticipate lots of path errors. You would need to download the Azure CLI and/or installer into the databricks storage, and run off that.

    Please do let me if you have any queries.

    Thanks
    Martin


    • 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
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.