Azure Service Fabric Managed Clusters Management Client Library for Python

3.0.0 · active · verified Thu Apr 09

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.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then list all Service Fabric Managed Clusters within your Azure subscription. Ensure that the required environment variables (`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`, and `AZURE_SUBSCRIPTION_ID`) are set for authentication.

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})")

view raw JSON →