Azure PowerShell vs Azure SDK for Python

As an Azure engineer, I have used both Azure PowerShell and the Azure SDK for Python to manage and provision Azure resources. I like to share comparisons based on my experience and real work scenarios in the many years engineering and designing for solutions in Azure. Hope this blog post gives some perspective.

Azure PowerShell:

PowerShell is a general purpose scripting language popular for windows environments. Azure PowerShell is a module for PowerShell. Neat thing about is that it is object oriented, but I haven’t used this capability in my scripting experience. Earlier in my career I have used PowerShell for basic file management, exporting data, read and import data into SharePoint Document libraries and list, and simple creation and modification of Azure resources.

  1. Cross Platform: Azure PowerShell is originally built for windows environment; however, there is a cross platform version called “Azure PowerShell Core”. In my day to day workings in windows over the many years, Azure PowerShell was normally what I would work with in windows environments as it is deeply integrated and easy to install and setup. Although I haven’t had a lot of experience with PowerShell Core, there may be a little of limitations compared to the windows version.
  2. Object-Oriented: PowerShell is object oriented and so you have easier data manipulation with data structures. But it isn’t something I have seen common in the sample code or I have done in practice.
  3. Community Support: Many code samples and GitHub repos and documentation.
  4. Programmability with Azure: Azure PowerShell commands can be used standalone in a command line which makes it flexible and simple. Or you can use it within a PowerShell script and work with the return objects from the command execution.

Here is the New-AzStorageAccount command and easy to apply arguments and get a result object. And then see the functions and properties against that storage object via intellisense. Azure Powershell is slightly more of a “declarative” style given the command and argument structure.

Azure SDK for Python:

Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability. Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including structured, object-oriented and functional programming. Recently, I have been developing scripts and small backend applications to manage azure resources. In order to manage Azure resources, you have to also install the Azure SDK for Python. This is by doing the Python package install.

  1. Cross-Platform Support: Python is by design cross-platform, and the Azure SDK for Python is cross platform as well.
  2. Object Oriented: Python is object oriented which helps with structuring your code with data structures and functions. Working with Azure SDK for Python is very much working with class objects and instances.
  3. Async Programming: The Azure SDK for Python supports asynchronous programming, which can be beneficial for building responsive and scalable applications. For example, when creating multiple resources at once and polling to wait on completion of one of or all those resources.
  4. Community Support: Python is used for many types of applications such as for web apps, backend APIs, data and AI and cloud infrastructure management. The Azure SDK for Python integrates well with this ecosystem, allowing users to combine Azure services with other Python tools. There is also many online communities, public repos and code samples.

Here is creating a storage account with the Azure SDK management and client libraries. It is more imperative programming style than Azure PowerShell.

Key Decision Points

These are decision factors from greatest to least in my opinion.

Linux or Windows environment: If you are working in a Linux environment, then go with Python and Azure SDK for Python as it is truly cross platform and wide adoption in Linux.

Your organization or team preference: I find that if your peers, cross functional teams and organization has adopted a particular language whether it is PowerShell, Python, Bash or other, then you don’t have much choice.

Community Support and Adoption: Because you may find more articles, tutorials and sample code for PowerShell or Python, then that may be a determining factor. For example, there are much more data analytics oriented code samples for Python.

Language Capabilities and Features: They are both capable and have a lot of programming features. For complex application designs that require object oriented programming. Python on the other hand has a lot of open source libraries for manipulating and managing data as it is very popular in the data engineering and data science community.

Final Thoughts

I will continue to use PowerShell, Python or other programming language depending on the complexity, functional requirements and organization requirements. In the end, it is valuable to be flexible and open to pick up new languages or how you apply the languages you already know. It is not just the languages but learning the appropriate frameworks and libraries to work against various API, data sets and cloud infrastructure.

References:

Leave a Reply