This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
The open-source Azure libraries for Python simplify provisioning, managing, and using Azure resources from Python application code.
The Azure libraries are how you communicate with Azure servicesfrom Python code that you run either locally or in the cloud. (Whether you can run Python code within the scope of a particular service depends on whether that service itself currently supports Python.)
The libraries supportPython 3.8 or later. For more information about supported versions of Python, seeAzure SDKs Python version support policy. If you're usingPyPy, make sure the version you use at least supports the Python version mentioned previously.
The Azure SDK for Python is composed solely of over 180 individual Python libraries that relate to specific Azure services. There are no other tools in the SDK.
When you run code locally, authenticating with Azure relies on environment variables as described inHow to authenticate Python apps to Azure services using the Azure SDK for Python.
To install library packages with pip, usepip install <library_name>
using library names from thepackage index. To install library packages in conda environments, useconda install <package_name>
using names from theMicrosoft channel on anaconda.org. For more information, seeInstall Azure library packages.
There are distinctmanagement andclient libraries (sometimes referred to as "management plane" and "data plane" libraries). Each set serves different purposes and is used by different kinds of code. For more information, see the following sections later in this article:
Documentation for the libraries is found on theAzure for Python Reference, which is organized by Azure Service, or thePython API browser, which is organized by package name.
To try the libraries for yourself, we first recommendsetting up your local dev environment. Then you can try any of the following standalone examples (in any order):Example: Create a resource group,Example: Create and use Azure Storage,Example: Create and deploy a web app,Example: Create and query a MySQL database, andExample: Create a virtual machine.
For demonstration videos, seeIntroducing the Azure SDK for Python (PyCon 2021) andUsing Azure SDKs to interact with Azure resources (PyCon 2020).
Because theAzure 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. So, using the CLI (or its equivalent,Azure PowerShell) for automated creation and management scripts can be more convenient than writing the equivalent Python code, unless you want to have a much more exacting degree of control over the process.
The Azure libraries for Python build on top of the underlyingAzure REST API, allowing you to use those APIs through familiar Python paradigms. However, you can always use the REST API directly from Python code, if desired.
You can find the source code for the Azure libraries onhttps://github.com/Azure/azure-sdk-for-python. As an open-source project, contributions are welcome!
Although you can use the libraries with interpreters such as IronPython and Jython that we don't test against, you may encounter isolated issues and incompatibilities.
The source repo for the library API reference documentation resides onhttps://github.com/MicrosoftDocs/azure-docs-sdk-python/.
Starting in 2019, we updated Azure Python libraries to share common cloud patterns such as authentication protocols, logging, tracing, transport protocols, buffered responses, and retries. The updated libraries adhere tocurrent Azure SDK guidelines.
On 31 March 2023, we retired support for Azure SDK libraries that don't conform to current Azure SDK guidelines. While older libraries can still be used beyond 31 March 2023, they'll no longer receive official support and updates from Microsoft. For more information, see the noticeUpdate your Azure SDK libraries.
To avoid missing security and performance updates to the Azure SDKs, upgrade to thelatest Azure SDK libraries by 31 March 2023.
To check which Python libraries are impacted, seeAzure SDK Deprecated Releases for Python.
For details on the guidelines we apply to the libraries, see thePython Guidelines: Introduction.
The SDK'smanagement (or "management plane") libraries, the names of which all begin withazure-mgmt-
, help you create, configure, and otherwise manage Azure resources from Python scripts. All Azure services have corresponding management libraries. For more information, seeAzure control plane and data plane.
With the management libraries, you can write configuration and deployment scripts to perform the same tasks that you can through theAzure portal or theAzure CLI. (As noted earlier, the Azure CLI is written in Python and uses the management libraries to implement its various commands.)
The following examples illustrate how to use some of the primary management libraries:
For details on working with each management library, see theREADME.md orREADME.rst file located in the library's project folder in theSDK GitHub repository. You can also find more code snippets in thereference documentation and theAzure Samples.
If you're migrating code from older versions of the management libraries, see the following details:
ServicePrincipalCredentials
class, seeAuthenticate with token credentials.begin_
. In most cases, the API signature remains the same.The SDK'sclient (or "data plane") libraries help you write Python application code to interact with already-provisioned services. Client libraries exist only for those services that support a client API.
The article,Example: Use Azure Storage, provides a basic illustration of using client library.
Different Azure services also provide examples using these libraries. See the following index pages for other links:
For details on working with each client library, see theREADME.md orREADME.rst file located in the library's project folder in theSDK's GitHub repository. You can also find more code snippets in thereference documentation and theAzure Samples.
We strongly recommend doing a one-time setup of your local development environment so that you can easily use any of the Azure libraries for Python.
Was this page helpful?