Azure MySQL Flexible Servers Management Client Library for Python
The `azure-mgmt-mysqlflexibleservers` library provides a client for managing Azure Database for MySQL Flexible Servers. It enables Python developers to create, read, update, and delete MySQL Flexible Server resources including servers, databases, firewall rules, and configurations within an Azure subscription. The current version is 1.0.0, and it is part of the actively maintained Azure SDK for Python ecosystem.
Warnings
- breaking Migration from `azure-mgmt-rdbms`: The `azure-mgmt-rdbms` library's MySQL single server management is deprecated. Users should migrate to `azure-mgmt-mysqlflexibleservers` for managing MySQL Flexible Servers as soon as possible.
- breaking Authentication system revamp: Older credential mechanisms like `azure.common.credentials` or `msrestazure.azure_active_directory` are no longer supported across Azure SDKs.
- breaking Model `OperationProgressResult` instance variable `object_type` moved under `properties`; `Provisioning` model deleted. This introduces API changes in `1.0.0` compared to earlier beta versions.
- gotcha TLS 1.0/1.1 connections denied: Azure Database for MySQL Flexible Server enforces TLS 1.2 by default. Older clients attempting to connect with TLS 1.0 or 1.1 will be denied.
- gotcha Lack of `SUPER` privilege and `DBA` role: The Azure Database for MySQL Flexible Server service does not support `SUPER` privilege or `DBA` role. Operations requiring these privileges will fail.
Install
-
pip install azure-mgmt-mysqlflexibleservers azure-identity
Imports
- MySQLManagementClient
from azure.mgmt.mysqlflexibleservers import MySQLManagementClient
- DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.mysqlflexibleservers import MySQLManagementClient
# Set environment variables for authentication:
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET (for service principal)
# AZURE_SUBSCRIPTION_ID
subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID')
# Authenticate using DefaultAzureCredential
# This credential type tries multiple authentication methods, like environment variables or managed identity.
credential = DefaultAzureCredential()
# Create a MySQLManagementClient instance
client = MySQLManagementClient(credential=credential, subscription_id=subscription_id)
# Example: List all MySQL Flexible Servers in the subscription
print(f"Listing MySQL Flexible Servers in subscription: {subscription_id}")
for server in client.servers.list():
print(f"- Server Name: {server.name}, Resource Group: {server.resource_group}")
# For more operations, use client.servers, client.databases, etc.
# e.g., print(client.servers.get(resource_group_name='myResourceGroup', server_name='myServerName'))