{"id":1383,"library":"azure-mgmt-servicefabric","title":"Azure Service Fabric Management","description":"The `azure-mgmt-servicefabric` library is the Microsoft Azure Service Fabric Management Client Library for Python. It allows developers to programmatically manage Azure Service Fabric resources, such as clusters, applications, and services. The current stable version is 2.1.0, released on December 18, 2023. As part of the broader Azure SDK for Python, it follows a frequent release cadence, with updates often aligning with new features and fixes across Azure services.","status":"active","version":"2.1.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["Azure","Cloud Management","Service Fabric"],"install":[{"cmd":"pip install azure-mgmt-servicefabric azure-identity","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for modern Azure Active Directory authentication.","package":"azure-identity"}],"imports":[{"note":"Prior to version 1.0.0b1, the client could be imported directly from its submodule. Post-1.0.0b1, the client should be imported directly from the top-level package.","wrong":"from azure.mgmt.servicefabric.service_fabric_management_client import ServiceFabricManagementClient","symbol":"ServiceFabricManagementClient","correct":"from azure.mgmt.servicefabric import ServiceFabricManagementClient"},{"symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.servicefabric import ServiceFabricManagementClient\n\n# Ensure these environment variables are set:\n# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET (for DefaultAzureCredential)\n# AZURE_SUBSCRIPTION_ID\n# AZURE_RESOURCE_GROUP_NAME (for listing clusters)\n\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"<your-subscription-id>\")\nresource_group_name = os.environ.get(\"AZURE_RESOURCE_GROUP_NAME\", \"<your-resource-group>\")\n\ntry:\n    # Authenticate using DefaultAzureCredential\n    # This credential will attempt to authenticate in various ways, including \n    # environment variables, managed identity, and Azure CLI login.\n    credential = DefaultAzureCredential()\n\n    # Create a Service Fabric Management client\n    client = ServiceFabricManagementClient(credential=credential, subscription_id=subscription_id)\n\n    # Example: List all Service Fabric clusters in a specified resource group\n    print(f\"Listing Service Fabric clusters in resource group: {resource_group_name}...\")\n    clusters = client.clusters.list_by_resource_group(resource_group_name)\n\n    for cluster in clusters:\n        print(f\"  - Cluster Name: {cluster.name}, Location: {cluster.location}, Resource ID: {cluster.id}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your Azure environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP_NAME) are correctly set and your service principal has the necessary permissions.\")","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and instantiate the `ServiceFabricManagementClient`. It then shows how to list Service Fabric clusters within a specified resource group. Ensure relevant Azure environment variables for authentication and subscription ID are set."},"warnings":[{"fix":"Migrate authentication to use classes from `azure-identity` (e.g., `DefaultAzureCredential`) and update client instantiation to use the `credential` parameter. Review the migration guide for the Azure SDK for Python if upgrading from very old versions.","message":"Major breaking changes occurred around version 1.0.0b1 (before 2.0.0) with the transition to the 'Track 2' Azure SDK guidelines. Authentication methods using `azure.common.credentials` or `msrestazure.azure_active_directory` are no longer supported. The `credentials` parameter for client constructors was renamed to `credential`.","severity":"breaking","affected_versions":">=1.0.0b1"},{"fix":"Update import statements to `from azure.mgmt.servicefabric import ServiceFabricManagementClient` and `from azure.mgmt.servicefabric.models import MyClass`.","message":"Direct imports from specific submodules like `azure.mgmt.servicefabric.service_fabric_management_client` for client classes, and `azure.mgmt.servicefabric.models.my_class` for models, were changed. Imports should now typically be from the top-level package or `azure.mgmt.servicefabric.models` for models.","severity":"breaking","affected_versions":">=1.0.0b1"},{"fix":"Upgrade to Python 3.7 or higher. The current version requires Python >=3.7.","message":"Support for Python 2.7 in Azure SDK Python packages ended on January 1, 2022. Using `azure-mgmt-servicefabric` with Python 2.7 is unsupported and may lead to unpatched security vulnerabilities or functional issues.","severity":"deprecated","affected_versions":"<=2.1.0"},{"fix":"Ensure you are using the correct management library based on your Service Fabric cluster type. If managing Service Fabric Managed Clusters, install and use `azure-mgmt-servicefabricmanagedclusters`.","message":"Azure Service Fabric has two deployment models: 'classic' clusters and 'managed' clusters. This library (`azure-mgmt-servicefabric`) is for managing 'classic' Service Fabric clusters. For Service Fabric *managed* clusters, use the `azure-mgmt-servicefabricmanagedclusters` library, which provides a simplified cluster management experience.","severity":"gotcha","affected_versions":"All"},{"fix":"When deploying or configuring Service Fabric clusters, ensure that the durability tier is set to Silver or Gold for production environments. This often implies a minimum number of VMs (e.g., 5 or more for Silver/Gold).","message":"For production Service Fabric clusters, it is critical to configure Silver or Gold durability tiers. Azure Service Fabric blocks deployments that do not meet Silver or Gold durability requirements to prevent data loss during underlying VM infrastructure operations, especially for production workloads.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}