Azure Service Fabric Managed Clusters Management Client Library for Python
The `azure-mgmt-servicefabricmanagedclusters` library is the Microsoft Azure Service Fabric Managed Clusters Management Client Library for Python. It simplifies the deployment and management of Service Fabric managed clusters, which encapsulate underlying resources into a single Azure Resource Manager resource. This library is actively maintained and currently at version 3.0.0, supporting Python 3.9 and newer.
Common errors
-
ModuleNotFoundError: No module named 'azure.mgmt.servicefabricmanagedclusters'
cause The `azure-mgmt-servicefabricmanagedclusters` package, or one of its dependencies like `azure-identity`, is not installed in the current Python environment or the Python interpreter cannot find it.fixEnsure the package and its authentication dependency are installed: `pip install azure-mgmt-servicefabricmanagedclusters azure-identity` -
azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
cause The `DefaultAzureCredential` could not find valid credentials configured in the environment (e.g., environment variables, Azure CLI login, Managed Identity) to authenticate with Azure.fixConfigure Azure credentials by setting environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID) or by logging in via Azure CLI (`az login`). -
AttributeError: 'ServiceFabricManagedClustersManagementClient' object has no attribute 'some_method_name'
cause This error typically occurs when attempting to call a method that has been renamed, deprecated, or does not exist on the client object, often due to an outdated SDK version or incorrect method invocation.fixCheck the official SDK documentation for `azure-mgmt-servicefabricmanagedclusters` (version 3.0.0) to find the correct method name and its signature. Upgrade the library to the latest version if using an old API. -
azure.core.exceptions.HttpResponseError: (LocationRequired) The location property is required for this definition.
cause An Azure resource creation or update operation was attempted without specifying the 'location' property, which is a mandatory parameter for many Azure resources.fixEnsure that the `location` parameter is included and correctly specified when creating or updating Azure Service Fabric Managed Cluster resources. Example: `cluster_resource = client.managed_clusters.begin_create_or_update(resource_group_name, cluster_name, {'location': 'eastus', ...}).result()`
Warnings
- breaking The `sku` parameter of the `ManagedCluster` model became required in version 2.0.0. If you are upgrading from a version older than 2.0.0, ensure this parameter is always provided when creating or updating managed clusters.
- breaking Operations `ManagedClusterVersionOperations.get_by_environment` and `ManagedClusterVersionOperations.list_by_environment` gained a new required `environment` parameter in version 2.0.0. Calls to these methods without the `environment` parameter will break.
- gotcha There is no in-place migration path from existing (traditional) Azure Service Fabric clusters to Service Fabric Managed Clusters. You must create a new managed cluster resource.
- gotcha Manual changes to the underlying resources of a Service Fabric managed cluster (e.g., Virtual Machine Scale Sets, Load Balancers) are not supported. Managed clusters are fully encapsulated, and Azure manages these resources on your behalf.
- gotcha This library requires Python 3.9 or newer. Using older Python versions will result in compatibility issues.
Install
-
pip install azure-mgmt-servicefabricmanagedclusters azure-identity
Imports
- ServiceFabricManagedClustersManagementClient
from azure.mgmt.servicefabricmanagedclusters import ServiceFabricManagedClustersManagementClient
- DefaultAzureCredential
from azure.common.credentials import ServicePrincipalCredentials
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.servicefabricmanagedclusters import ServiceFabricManagedClustersManagementClient
# Set environment variables for authentication:
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
# And AZURE_SUBSCRIPTION_ID
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
raise ValueError("AZURE_SUBSCRIPTION_ID environment variable not set.")
# Authenticate using DefaultAzureCredential
credential = DefaultAzureCredential()
# Create a Service Fabric Managed Clusters Management Client
client = ServiceFabricManagedClustersManagementClient(credential, subscription_id)
# Example: List all managed clusters in the subscription
print("Listing Service Fabric Managed Clusters...")
for cluster in client.managed_clusters.list_by_subscription():
print(f"- {cluster.name} (Resource Group: {cluster.resource_group})")