Registry / azure / azure-mgmt-sql

azure-mgmt-sql

JSON →
library4.0.0pypypi✓ verified 29d ago

The `azure-mgmt-sql` library is the Microsoft Azure SQL Management Client Library for Python. It provides classes and methods to programmatically manage Azure SQL resources such as SQL Servers, databases, elastic pools, firewalls, and more. It is part of the Azure SDK for Python (Track 2) and is currently at version 3.0.1. Azure SDK libraries typically follow a regular release cadence with updates corresponding to Azure service API changes.

pip install azure-mgmt-sql azure-identity
INSTALL
IMPORT
SIG · AZURE-MGMT-SQL
A
azure-mgmt-sql
azurepythonv4.0.0
Install
4.7s avg
Import
1114ms
Disk
57MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.940s · 56.5MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 4.7s · import 0.842s · 57MB
57MB installed
● package 57MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SqlManagementClient
✓ from azure.mgmt.sql import SqlManagementClient
✗ from azure.mgmt.sql.sql_management_client import SqlManagementClient
The client class is directly available under the top-level package.
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
Standard authentication credential for Azure SDK (Track 2).

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential`, instantiate the `SqlManagementClient`, and then list all Azure SQL Servers within a specified subscription. Ensure `AZURE_SUBSCRIPTION_ID` is set in your environment variables for authentication.

import os from azure.identity import DefaultAzureCredential from azure.mgmt.sql import SqlManagementClient # Set your Azure Subscription ID in environment variables or replace directly # e.g., AZURE_SUBSCRIPTION_ID = 'your-subscription-id' subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID') if subscription_id == 'YOUR_SUBSCRIPTION_ID': raise ValueError("Please set the AZURE_SUBSCRIPTION_ID environment variable or replace 'YOUR_SUBSCRIPTION_ID'") # Authenticate using DefaultAzureCredential # This tries a series of authentication methods (environment variables, managed identity, VS Code, Azure CLI, etc.) credential = DefaultAzureCredential() # Create a SQL Management Client sql_client = SqlManagementClient(credential, subscription_id) print(f"Listing SQL Servers in subscription '{subscription_id}':") # List all SQL Servers in the subscription try: sql_servers = sql_client.servers.list() for server in sql_servers: print(f" - Server Name: {server.name}, Location: {server.location}") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingMigration from older Azure SDK (Track 1) clients to current (Track 2) clients involves significant breaking changes in client construction, authentication, and method signatures.
fix
Adopt `azure-identity` for authentication (e.g., `DefaultAzureCredential`). Client constructors now typically require a credential object and `subscription_id`. Method parameters and return types have been updated to be more consistent with the Azure REST API and Pythonic conventions. Consult the official Azure SDK documentation for the specific version.
affects: Users migrating from `azure-mgmt-sql` versions prior to 2.0.0 or from older `msrestazure` based clients.
gotchaMany Azure SQL management operations are resource group-scoped. Operations like creating a server or database, or getting specific properties, require the resource group name in addition to the resource name.
fix
Always be mindful of the required scope for an operation. If an operation fails with a 'resource not found' or 'bad request' error, double-check if the resource group name is correctly provided and if the resource actually exists within that resource group.
affects: All versions.
gotchaAzure SDK for Python offers both synchronous and asynchronous clients (e.g., `SqlManagementClient` vs `AsyncSqlManagementClient`). Mixing these can lead to runtime errors.
fix
Decide whether you need synchronous or asynchronous operations for your application. If using `asyncio`, import and instantiate the `AsyncSqlManagementClient` and `await` its methods. For synchronous operations, use `SqlManagementClient` and do not use `await`.
affects: All versions.
gotchaList operations (e.g., `servers.list()`, `databases.list_by_server()`) return an iterable object (a 'pager') which needs to be iterated over to fetch all results, rather than a simple Python list.
fix
Always iterate over the result of a list operation. For example, `for server in sql_client.servers.list():` or convert to a list explicitly if all results are needed upfront: `all_servers = list(sql_client.servers.list())`.
affects: All versions.
gotchaThe `azure-mgmt-sql` library has a dependency on `six`. If `six` is not installed in the environment, a `ModuleNotFoundError` will occur when importing the library.
fix
Ensure that the `six` package is installed in your Python environment. You can install it using `pip install six`. Typically, `pip install azure-mgmt-sql` should handle this dependency, but in some minimal environments or specific `pip` versions, it might require explicit installation.
affects: All versions.
breaking`azure-mgmt-sql` or its dependencies require the `six` package, which was not found during import. This prevents the library from being used.
fix
Install the `six` package explicitly using `pip install six` or ensure that `azure-mgmt-sql` is installed in an environment where all its transitive dependencies are correctly resolved (e.g., `pip install azure-mgmt-sql` should typically pull `six`).
affects: All versions.
Upgrade
Version history
4.0.0latest on PyPI · released Jul 1, 2026
Audit
Dependencies
azure-corerequiredCore utilities and HTTP pipeline for Azure SDK.
azure-identityrequiredRecommended credential types for Azure authentication.
azure-mgmt-corerequiredCommon management plane utilities for Azure SDK.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
azure-mgmt-sql — pip install azure-mgmt-sql · libregistry