Azure Service Linker Management Client Library for Python

1.1.0 · active · verified Thu Apr 09

The `azure-mgmt-servicelinker` library is the Microsoft Azure Service Linker Management Client Library for Python. It provides the tools to manage Azure Service Linkers, which connect Azure compute services to other Azure data services. The current stable version is 1.1.0. Azure SDKs typically follow a frequent release cadence, with minor releases quarterly or less, and patch releases as bug fixes become available.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the `ServiceLinkerManagementClient` and list existing Service Linkers for a given resource. It uses `DefaultAzureCredential` for authentication, which attempts to authenticate through various methods suitable for both local development and deployment environments.

import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.servicelinker import ServiceLinkerManagementClient

# Set environment variables for authentication (replace with your actual values or use Azure CLI/VS Code login)
# AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID
# For local development, DefaultAzureCredential will try various methods, including environment variables,
# managed identity, Azure CLI, or Visual Studio Code login.

subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") # Replace with your subscription ID
resource_uri = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app" # Example URI, replace as needed

# Authenticate using DefaultAzureCredential
credential = DefaultAzureCredential()

# Create a ServiceLinkerManagementClient
client = ServiceLinkerManagementClient(credential=credential, subscription_id=subscription_id)

# Example: List linkers for a given resource_uri
try:
    print(f"Listing linkers for resource: {resource_uri}")
    linkers = client.linkers.list(resource_uri=resource_uri)
    for linker in linkers:
        print(f"  - Linker Name: {linker.name}, Target Service: {linker.target_service.id if linker.target_service else 'N/A'}")
except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure the resource_uri and subscription_id are correct and you have the necessary permissions.")
    print("Also, verify your authentication environment variables (AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET) or local Azure login.")

view raw JSON →