{"id":3418,"library":"azure-servicefabric","title":"Azure Service Fabric Client Library for Python","description":"The `azure-servicefabric` library provides a client for programmatically interacting directly with Microsoft Azure Service Fabric clusters using Python. It allows for management of applications, services, nodes, and other cluster resources. This library is part of the older Azure SDK for Python (Track 1) and was last updated in April 2021. It is currently in maintenance mode, receiving critical bug fixes but not active feature development.","status":"maintenance","version":"8.2.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/servicefabric/azure-servicefabric","tags":["Azure","Service Fabric","Cloud","Management","Orchestration"],"install":[{"cmd":"pip install azure-servicefabric","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for service client and data models in older Azure SDKs.","package":"msrest","optional":false},{"reason":"Azure-specific extensions for `msrest`, often for authentication and models.","package":"msrestazure","optional":false}],"imports":[{"note":"The primary client for interacting with a Service Fabric cluster.","symbol":"ServiceFabricClient","correct":"from azure.servicefabric import ServiceFabricClient"},{"note":"`ServiceFabricCredential` is part of the `msrest` library, not `azure.servicefabric` directly.","wrong":"from azure.servicefabric import ServiceFabricCredential","symbol":"ServiceFabricCredential","correct":"from msrest.service_fabric import ServiceFabricCredential"}],"quickstart":{"code":"import os\nfrom azure.servicefabric import ServiceFabricClient\nfrom msrest.service_fabric import ServiceFabricCredential\n\n# Connect to a secure Service Fabric cluster using client certificates\n# Replace with your cluster endpoint and certificate paths\ncluster_endpoint = os.environ.get('SF_CLUSTER_ENDPOINT', 'https://your_cluster_fqdn:19080')\ncert_file = os.environ.get('SF_CLIENT_CERT_FILE', 'path/to/your/client.pem')\nkey_file = os.environ.get('SF_CLIENT_KEY_FILE', 'path/to/your/client.key') # or .pfx if combined\n\nif not all([cluster_endpoint, cert_file, key_file]):\n    print(\"Please set SF_CLUSTER_ENDPOINT, SF_CLIENT_CERT_FILE, and SF_CLIENT_KEY_FILE environment variables.\")\n    print(\"Example: export SF_CLUSTER_ENDPOINT='https://mycluster.westus.cloudapp.azure.com:19080'\")\n    print(\"Example: export SF_CLIENT_CERT_FILE='/etc/sf/client.pem'\")\n    print(\"Example: export SF_CLIENT_KEY_FILE='/etc/sf/client.key'\")\nelse:\n    try:\n        # Service Fabric client expects a tuple of (cert_file, key_file) for ServiceFabricCredential\n        credentials = ServiceFabricCredential((cert_file, key_file))\n        client = ServiceFabricClient(base_url=cluster_endpoint, credentials=credentials)\n\n        print(f\"Connecting to Service Fabric cluster at: {cluster_endpoint}\")\n\n        # Example: List all nodes in the cluster\n        nodes = client.nodes.get_node_list()\n        print(f\"Found {len(nodes)} nodes in the cluster:\")\n        for node in nodes:\n            print(f\"- Node Name: {node.name}, Status: {node.health_state}, Type: {node.type}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Ensure the certificate paths are correct and the cluster endpoint is reachable.\")","lang":"python","description":"This quickstart demonstrates how to initialize the `ServiceFabricClient` and connect to a secure Service Fabric cluster using client certificates, then list the nodes. Ensure you have the cluster endpoint, client certificate (.pem) and private key (.key) files accessible and their paths set in environment variables."},"warnings":[{"fix":"Refer to the `msrest` and `azure-servicefabric` documentation for `ServiceFabricCredential` and certificate setup. Ensure certificates are in the correct format (e.g., .pem, .key).","message":"This library is part of the older Azure SDK Track 1. It does not use the newer `azure-identity` credential types. Authentication typically requires `msrest.service_fabric.ServiceFabricCredential` which supports certificate-based authentication. This can be complex to configure correctly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For direct cluster API interactions, `azure-servicefabric` is still functional. For ARM-level management (creating/updating clusters), use `pip install azure-mgmt-servicefabric` and the newer client. Differentiate between cluster management plane (ARM) and cluster runtime interactions (this library).","message":"The `azure-servicefabric` library is in maintenance mode and was last updated in April 2021. For managing Service Fabric clusters via Azure Resource Manager (ARM), consider using `azure-mgmt-servicefabric` which is part of the newer Azure SDK Track 2 and actively maintained.","severity":"deprecated","affected_versions":"<=8.2.0.0"},{"fix":"Design your application to handle synchronous I/O or wrap calls in a separate thread/process if non-blocking behavior is required.","message":"Unlike newer Azure SDK libraries that often use `Async` variants, `azure-servicefabric` is synchronous. All client operations will block until the call completes.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}