Azure Synapse Management
The Microsoft Azure Synapse Management Client Library for Python (azure-mgmt-synapse) provides the necessary tools to manage Azure Synapse Analytics workspaces, SQL pools, Apache Spark pools, and integration runtimes. It enables programmatic control over Synapse resources within an Azure subscription. The library is currently at version 2.0.0 (released April 2021) and adheres to the standard Azure SDK guidelines, offering a stable interface for managing Synapse services.
Warnings
- breaking Breaking changes were introduced in version 2.0.0, significantly revamping the authentication and client interaction model. The legacy `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported. The `credentials` parameter was renamed to `credential`.
- breaking Long-running operations (LROs) that previously returned `msrest.polling.LROPoller` now return `azure.core.polling.LROPoller` and are typically prefixed with `begin_`.
- breaking The exception hierarchy has been simplified. Most exceptions now derive from `azure.core.exceptions.HttpResponseError`, and `CloudError` has been removed.
- breaking Model changes: `WorkspacePatchInfo` and `Workspace` models no longer have the `network_settings` parameter in version 2.0.0. Instead, `public_network_access` was added.
- gotcha Confusion between Python and .NET SDK status: The .NET NuGet package `Microsoft.Azure.Management.Synapse` is deprecated and no longer maintained. However, this Python library (`azure-mgmt-synapse`) remains active and supported. Users should ensure they are referencing the correct SDK for their language.
Install
-
pip install azure-mgmt-synapse
Imports
- SynapseManagementClient
from azure.mgmt.synapse import SynapseManagementClient
- DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.synapse import SynapseManagementClient
# Set the AZURE_SUBSCRIPTION_ID environment variable or replace with your actual 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 provide your subscription ID.")
# Authenticate using DefaultAzureCredential, which handles various Azure authentication methods.
# For local development, ensure you are logged in via Azure CLI (`az login`)
# or have appropriate environment variables set.
credential = DefaultAzureCredential()
# Create a SynapseManagementClient
client = SynapseManagementClient(credential, subscription_id)
print("Listing Synapse Workspaces:")
# Iterate over the workspaces in your subscription
for workspace in client.workspaces.list():
print(f"- {workspace.name} (Location: {workspace.location})")