{"id":3416,"library":"azure-mgmt-relay","title":"Azure Management Relay Client Library","description":"The `azure-mgmt-relay` library is the Microsoft Azure Relay Client Library for Python. It enables programmatic management of Azure Relay resources, such as namespaces, hybrid connections, and WCF relays, through Azure Resource Manager (ARM). The library is currently at stable version 1.1.0, released in September 2021. A 2.0.0b1 beta version was released in November 2022, but no stable release has followed since 1.1.0.","status":"active","version":"1.1.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","management","relay","cloud","sdk","resource-manager"],"install":[{"cmd":"pip install azure-mgmt-relay","lang":"bash","label":"Install stable version"},{"cmd":"pip install --pre azure-mgmt-relay","lang":"bash","label":"Install preview version (e.g., 2.0.0b1)"}],"dependencies":[{"reason":"Recommended for modern Azure SDK authentication.","package":"azure-identity","optional":false},{"reason":"Base library providing shared primitives for Azure SDKs.","package":"azure-core","optional":false}],"imports":[{"symbol":"RelayManagementClient","correct":"from azure.mgmt.relay import RelayManagementClient"},{"symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"},{"note":"The `azure.common.credentials` module is deprecated. Use `azure-identity` classes like `DefaultAzureCredential` or `ClientSecretCredential` instead for authentication.","wrong":"from azure.common.credentials import ServicePrincipalCredentials","symbol":"ServicePrincipalCredentials (deprecated)","correct":"from azure.identity import ClientSecretCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.relay import RelayManagementClient\n\n# Retrieve subscription ID from environment variable\n# Ensure AZURE_SUBSCRIPTION_ID is set in your environment\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\n\nif not subscription_id:\n    raise ValueError(\"AZURE_SUBSCRIPTION_ID environment variable not set.\")\n\n# Authenticate using DefaultAzureCredential\n# This credential will attempt to authenticate in various environments:\n# environment variables, managed identity, VS Code, Azure CLI, etc.\ncredential = DefaultAzureCredential()\n\n# Create a RelayManagementClient\nclient = RelayManagementClient(credential, subscription_id)\n\nprint(\"Listing all Relay namespaces in the subscription...\")\ntry:\n    for namespace in client.namespaces.list():\n        print(f\"- {namespace.name}\")\n    print(\"\\nSuccessfully listed Relay namespaces.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your Azure credentials and subscription ID are correctly configured and you have the necessary permissions.\")\n","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and list all Azure Relay namespaces within a specified subscription. Ensure you have the `AZURE_SUBSCRIPTION_ID` environment variable set and appropriate permissions in Azure for `DefaultAzureCredential` to function."},"warnings":[{"fix":"Migrate your authentication code to use classes from the `azure-identity` library, such as `DefaultAzureCredential`, `ClientSecretCredential`, or `ManagedIdentityCredential`. Update parameter names accordingly.","message":"The credential system underwent a complete revamp in `azure-mgmt-relay` 1.0.0b1. Old `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported. The `credentials` parameter was also renamed to `credential`.","severity":"breaking","affected_versions":"< 1.0.0b1 to 1.0.0b1+"},{"fix":"Remove any direct access to `client.config`. Pass configuration settings directly to the client constructor as keyword arguments (e.g., `RelayManagementClient(credential, subscription_id, enable_logging=True)`).","message":"The `config` attribute on client objects has been removed starting from `azure-mgmt-relay` 1.0.0b1. All configuration options should now be passed as keyword arguments during client instantiation.","severity":"breaking","affected_versions":"< 1.0.0b1 to 1.0.0b1+"},{"fix":"Adjust your code to call the `begin_` prefixed methods for LROs and handle the `azure.core.polling.LROPoller` return type.","message":"For long-running operations (LROs), methods that previously returned `msrest.polling.LROPoller` now return `azure.core.polling.LROPoller` and are prefixed with `begin_` (e.g., `create` became `begin_create`).","severity":"breaking","affected_versions":"< 1.0.0b1 to 1.0.0b1+"},{"fix":"Review all calls to model constructors and methods. Convert any positional arguments to explicit keyword arguments.","message":"Model signatures now exclusively use keyword-argument syntax. Any positional arguments previously used for model creation or method calls must be rewritten as keyword arguments.","severity":"breaking","affected_versions":"< 0.2.0 to 0.2.0+"},{"fix":"Ensure `pip install azure-mgmt-relay` was successful. If using a virtual environment, activate it before running your script. Consider reinstalling in a clean virtual environment if issues persist. For Azure CLI users, ensure the correct CLI extension version is used if it bundles this SDK.","message":"A `ModuleNotFoundError: No module named 'azure.mgmt.relay'` can occur if the package is not correctly installed, if the Python environment is not activated, or if there are conflicts with other Azure CLI or SDK installations.","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"}