Microsoft Azure Client Libraries for Python meta-package providing comprehensive access to Azure cloud services and management capabilities
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Azure platform services provide container orchestration, service fabric management, and legacy service management capabilities. This includes Service Fabric for microservices orchestration and legacy Azure Service Management APIs.
Provides distributed systems platform for packaging, deploying, and managing scalable and reliable microservices and containers. Supports stateless and stateful services with built-in orchestration capabilities.
class ServiceFabricClientAPIs:
"""
Client for Azure Service Fabric operations.
Parameters:
- Various configuration parameters for connecting to Service Fabric cluster
"""
def __init__(self, **kwargs): ...
@property
def cluster(self): ... # Cluster operations
@property
def node(self): ... # Node operations
@property
def application_type(self): ... # Application type operations
@property
def application(self): ... # Application operations
@property
def service_type(self): ... # Service type operations
@property
def service(self): ... # Service operations
@property
def partition(self): ... # Partition operations
@property
def replica(self): ... # Replica operations
@property
def code_package(self): ... # Code package operations
@property
def property(self): ... # Property operations
@property
def repair_task(self): ... # Repair task operations
@property
def infrastructure_service(self): ... # Infrastructure service operations
@property
def backup_restore(self): ... # Backup and restore operations
@property
def events_store(self): ... # Events store operations
@property
def mesh_gateway(self): ... # Service Fabric Mesh gateway operations
@property
def mesh_volume(self): ... # Service Fabric Mesh volume operations
@property
def mesh_secret(self): ... # Service Fabric Mesh secret operations
@property
def mesh_secret_value(self): ... # Service Fabric Mesh secret value operations
@property
def mesh_network(self): ... # Service Fabric Mesh network operations
@property
def mesh_application(self): ... # Service Fabric Mesh application operations
@property
def mesh_service(self): ... # Service Fabric Mesh service operations
@property
def mesh_code_package(self): ... # Service Fabric Mesh code package operations
@property
def mesh_service_replica(self): ... # Service Fabric Mesh service replica operationsManage Service Fabric cluster information and health.
class ClusterOperations:
def get_cluster_manifest(self, **kwargs):
"""Get the Service Fabric cluster manifest."""
def get_cluster_health(self, **kwargs):
"""Get cluster health information."""
def report_cluster_health(self, health_information, **kwargs):
"""Report health information about the cluster."""
def get_provisioned_fabric_code_version_info_list(self, **kwargs):
"""Get list of fabric code versions provisioned in the cluster."""
def get_provisioned_fabric_config_version_info_list(self, **kwargs):
"""Get list of fabric config versions provisioned in the cluster."""
def provision_cluster(self, provision_fabric_description, **kwargs):
"""Provision code or configuration packages of a Service Fabric cluster."""
def unprovision_cluster(self, unprovision_fabric_description, **kwargs):
"""Unprovision code or configuration packages of a Service Fabric cluster."""
def start_cluster_upgrade(self, start_cluster_upgrade_description, **kwargs):
"""Start upgrading the code or configuration version of a Service Fabric cluster."""
def get_cluster_upgrade_progress(self, **kwargs):
"""Get the progress of the current cluster upgrade."""
def update_cluster_upgrade(self, update_cluster_upgrade_description, **kwargs):
"""Update parameters of a cluster upgrade."""
def resume_cluster_upgrade(self, resume_cluster_upgrade_description, **kwargs):
"""Resume an unmonitored Service Fabric cluster upgrade."""
def rollback_cluster_upgrade(self, **kwargs):
"""Rollback the upgrade of a Service Fabric cluster."""Manage Service Fabric applications and their lifecycle.
class ApplicationOperations:
def get_applications_info_list(self, **kwargs):
"""Get list of applications deployed in the Service Fabric cluster."""
def get_application_info(self, application_id, **kwargs):
"""Get information about a Service Fabric application."""
def create_application(self, application_description, **kwargs):
"""Create a Service Fabric application."""
def delete_application(self, application_id, **kwargs):
"""Delete a Service Fabric application."""
def get_application_load_info(self, application_id, **kwargs):
"""Get load information of a Service Fabric application."""
def get_application_health(self, application_id, **kwargs):
"""Get health information of a Service Fabric application."""
def report_application_health(self, application_id, health_information, **kwargs):
"""Report health information about a Service Fabric application."""
def start_application_upgrade(self, application_id, application_upgrade_description, **kwargs):
"""Start upgrading an application in the Service Fabric cluster."""
def get_application_upgrade_progress(self, application_id, **kwargs):
"""Get details for the latest upgrade performed on this application."""
def update_application_upgrade(self, application_id, application_upgrade_update_description, **kwargs):
"""Update an ongoing application upgrade in the Service Fabric cluster."""
def resume_application_upgrade(self, application_id, resume_application_upgrade_description, **kwargs):
"""Resume upgrading an application in the Service Fabric cluster."""
def rollback_application_upgrade(self, application_id, **kwargs):
"""Start rolling back the currently on-going upgrade of an application."""Manage Service Fabric services within applications.
class ServiceOperations:
def get_services_info_list(self, application_id, **kwargs):
"""Get list of services belonging to the specified application."""
def get_service_info(self, application_id, service_id, **kwargs):
"""Get information about the specified service."""
def create_service(self, application_id, service_description, **kwargs):
"""Create a Service Fabric service."""
def create_service_from_template(self, application_id, service_from_template_description, **kwargs):
"""Create a Service Fabric service from the service template."""
def delete_service(self, service_id, **kwargs):
"""Delete an existing Service Fabric service."""
def update_service(self, service_id, service_update_description, **kwargs):
"""Update a Service Fabric service using the specified update description."""
def get_service_description(self, service_id, **kwargs):
"""Get the description of an existing Service Fabric service."""
def get_service_health(self, service_id, **kwargs):
"""Get health information of the specified Service Fabric service."""
def report_service_health(self, service_id, health_information, **kwargs):
"""Report health information about the specified Service Fabric service."""
def resolve_service(self, service_id, **kwargs):
"""Resolve a Service Fabric partition to get the endpoints of the service replicas."""Provides legacy Azure Service Management API capabilities for older Azure services and deployments. This includes classic virtual machines, cloud services, and storage accounts.
class ServiceManagementService:
"""
Client for Azure Service Management (Legacy) operations.
Parameters:
- subscription_id: str, Azure subscription ID
- certificate_path: str, Path to management certificate file
- host: str, Service management endpoint (optional)
"""
def __init__(self, subscription_id: str, certificate_path: str, host: str = None): ...
# Cloud service operations
def list_hosted_services(self): ...
def get_hosted_service_properties(self, service_name: str, embed_detail: bool = False): ...
def create_hosted_service(self, service_name: str, label: str, description: str = None,
location: str = None, affinity_group: str = None): ...
def update_hosted_service(self, service_name: str, label: str = None, description: str = None): ...
def delete_hosted_service(self, service_name: str): ...
def check_hosted_service_name_availability(self, service_name: str): ...
# Deployment operations
def get_deployment_by_slot(self, service_name: str, deployment_slot: str): ...
def get_deployment_by_name(self, service_name: str, deployment_name: str): ...
def create_deployment(self, service_name: str, deployment_slot: str, name: str,
package_url: str, label: str, configuration: str, **kwargs): ...
def delete_deployment(self, service_name: str, deployment_name: str): ...
def swap_deployment(self, service_name: str, production_deployment: str,
source_deployment: str): ...
def update_deployment_status(self, service_name: str, deployment_name: str, status: str): ...
def upgrade_deployment(self, service_name: str, deployment_name: str, mode: str,
package_url: str, configuration: str, label: str, **kwargs): ...
def rollback_update_or_upgrade(self, service_name: str, deployment_name: str, mode: str): ...
def reboot_role_instance(self, service_name: str, deployment_name: str, role_instance_name: str): ...
def reimage_role_instance(self, service_name: str, deployment_name: str, role_instance_name: str): ...
# Virtual machine operations
def create_virtual_machine_deployment(self, service_name: str, deployment_name: str,
deployment_slot: str, label: str, role_name: str,
system_config: object, os_virtual_hard_disk: object, **kwargs): ...
def add_role(self, service_name: str, deployment_name: str, role_name: str,
system_config: object, os_virtual_hard_disk: object, **kwargs): ...
def update_role(self, service_name: str, deployment_name: str, role_name: str, **kwargs): ...
def delete_role(self, service_name: str, deployment_name: str, role_name: str): ...
def restart_role(self, service_name: str, deployment_name: str, role_name: str): ...
def shutdown_role(self, service_name: str, deployment_name: str, role_name: str): ...
def start_role(self, service_name: str, deployment_name: str, role_name: str): ...
def capture_role(self, service_name: str, deployment_name: str, role_name: str,
post_capture_action: str, target_image_name: str, target_image_label: str): ...
# Storage account operations
def list_storage_accounts(self): ...
def get_storage_account_properties(self, service_name: str): ...
def get_storage_account_keys(self, service_name: str): ...
def regenerate_storage_account_keys(self, service_name: str, key_type: str): ...
def create_storage_account(self, service_name: str, label: str, **kwargs): ...
def update_storage_account(self, service_name: str, **kwargs): ...
def delete_storage_account(self, service_name: str): ...
def check_storage_account_name_availability(self, service_name: str): ...
# Affinity group operations
def list_affinity_groups(self): ...
def get_affinity_group_properties(self, affinity_group_name: str): ...
def create_affinity_group(self, name: str, label: str, location: str, description: str = None): ...
def update_affinity_group(self, affinity_group_name: str, label: str = None, description: str = None): ...
def delete_affinity_group(self, affinity_group_name: str): ...
# Location operations
def list_locations(self): ...
# Operating system operations
def list_operating_systems(self): ...
def list_operating_system_families(self): ...
# Subscription operations
def get_subscription(self): ...
def list_subscription_operations(self, start_time: str = None, end_time: str = None,
object_id_filter: str = None, operation_result_filter: str = None,
continuation_token: str = None): ...
# Certificate operations
def list_service_certificates(self, service_name: str): ...
def get_service_certificate(self, service_name: str, thumbprint_algorithm: str, thumbprint_hex: str): ...
def add_service_certificate(self, service_name: str, data: str, certificate_format: str, password: str = None): ...
def delete_service_certificate(self, service_name: str, thumbprint_algorithm: str, thumbprint_hex: str): ...
# Management certificate operations
def list_management_certificates(self): ...
def get_management_certificate(self, thumbprint: str): ...
def add_management_certificate(self, public_key: str, thumbprint: str, data: str): ...
def delete_management_certificate(self, thumbprint: str): ...
# Reserved IP operations
def list_reserved_ip_addresses(self): ...
def get_reserved_ip_address(self, name: str): ...
def create_reserved_ip_address(self, name: str, location: str, label: str = None): ...
def delete_reserved_ip_address(self, name: str): ...
def associate_reserved_ip_address(self, name: str, service_name: str, deployment_name: str): ...
def disassociate_reserved_ip_address(self, name: str, service_name: str, deployment_name: str): ...from azure.servicefabric import ServiceFabricClientAPIs
# Create Service Fabric client
sf_client = ServiceFabricClientAPIs(
cluster_endpoint="https://mycluster.westus.cloudapp.azure.com:19080"
)
# Get cluster health
cluster_health = sf_client.cluster.get_cluster_health()
print(f"Cluster health state: {cluster_health.aggregated_health_state}")
# List applications
applications = sf_client.application.get_applications_info_list()
for app in applications:
print(f"Application: {app.name}, Status: {app.status}")
# Get application health
if applications:
app_id = applications[0].id
app_health = sf_client.application.get_application_health(app_id)
print(f"Application health: {app_health.aggregated_health_state}")
# List services for an application
if applications:
services = sf_client.service.get_services_info_list(applications[0].id)
for service in services:
print(f"Service: {service.name}, Status: {service.service_status}")from azure.servicefabric.models import ApplicationDescription
# Create application
app_description = ApplicationDescription(
name="fabric:/MyApplication",
type_name="MyApplicationType",
type_version="1.0"
)
sf_client.application.create_application(app_description)
print("Application created successfully")
# Monitor application upgrade
upgrade_progress = sf_client.application.get_application_upgrade_progress("MyApplication")
if upgrade_progress:
print(f"Upgrade state: {upgrade_progress.upgrade_state}")
print(f"Current upgrade domain: {upgrade_progress.current_upgrade_domain_progress}")
# Create service within application
from azure.servicefabric.models import StatelessServiceDescription
service_description = StatelessServiceDescription(
service_name="fabric:/MyApplication/MyService",
service_type_name="MyServiceType",
partition_description={
"PartitionScheme": "Singleton"
},
instance_count=3
)
sf_client.service.create_service("MyApplication", service_description)
print("Service created successfully")from azure.servicemanagement import ServiceManagementService
# Create service management client
sms = ServiceManagementService(
subscription_id='your-subscription-id',
certificate_path='/path/to/certificate.pem'
)
# List hosted services (cloud services)
hosted_services = sms.list_hosted_services()
for service in hosted_services:
print(f"Hosted Service: {service.service_name}")
print(f"Location: {service.hosted_service_properties.location}")
# Get hosted service details
if hosted_services:
service_name = hosted_services[0].service_name
service_props = sms.get_hosted_service_properties(service_name, embed_detail=True)
print(f"Service description: {service_props.hosted_service_properties.description}")
# List deployments
if service_props.deployments:
for deployment in service_props.deployments:
print(f"Deployment: {deployment.name}, Status: {deployment.status}")
# List storage accounts
storage_accounts = sms.list_storage_accounts()
for storage in storage_accounts:
print(f"Storage: {storage.service_name}")
print(f"Location: {storage.storage_service_properties.location}")
# Get storage account keys
if storage_accounts:
storage_name = storage_accounts[0].service_name
keys = sms.get_storage_account_keys(storage_name)
print(f"Primary key: {keys.storage_service_keys.primary}")
print(f"Secondary key: {keys.storage_service_keys.secondary}")
# List virtual machines
for service in hosted_services:
service_props = sms.get_hosted_service_properties(service.service_name, embed_detail=True)
if service_props.deployments:
for deployment in service_props.deployments:
if deployment.role_list:
for role in deployment.role_list:
if hasattr(role, 'role_type') and role.role_type == 'PersistentVMRole':
print(f"VM: {role.role_name}, Size: {role.role_size}")from azure.servicemanagement import (
OSVirtualHardDisk,
LinuxConfigurationSet,
WindowsConfigurationSet,
ConfigurationSet
)
# Create a Linux VM
linux_config = LinuxConfigurationSet(
host_name='mylinuxvm',
user_name='azureuser',
user_password='MyPassword123!',
disable_ssh_password_authentication=False
)
os_hd = OSVirtualHardDisk(
source_image_name='b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_2-LTS-amd64-server-20150506-en-us-30GB',
media_link='https://mystorageaccount.blob.core.windows.net/vhds/mylinuxvm.vhd'
)
# Create VM deployment
result = sms.create_virtual_machine_deployment(
service_name='mylinuxservice',
deployment_name='mylinuxdeployment',
deployment_slot='production',
label='My Linux VM',
role_name='mylinuxvm',
system_config=linux_config,
os_virtual_hard_disk=os_hd,
role_size='Small'
)
print(f"VM creation request ID: {result.request_id}")
# Add data disk to VM
from azure.servicemanagement import DataVirtualHardDisk
data_disk = DataVirtualHardDisk(
host_caching='ReadOnly',
disk_label='Data Disk',
disk_name='mydatadisk',
lun=0,
media_link='https://mystorageaccount.blob.core.windows.net/vhds/mydatadisk.vhd'
)
sms.add_data_disk('mylinuxservice', 'mylinuxdeployment', 'mylinuxvm', data_disk)
print("Data disk added to VM")Install with Tessl CLI
npx tessl i tessl/pypi-azure