{"id":1929,"library":"azure-mgmt-extendedlocation","title":"Azure Extended Location Management","description":"The Microsoft Azure Extended Location Management Client Library for Python provides functionality to manage Custom Locations and Resource Sync Rules within Azure. These extended locations allow Azure services to run in environments outside of Azure datacenters. The current version is 2.0.0, and new versions are released regularly to keep pace with Azure service updates.","status":"active","version":"2.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","management","extended location","custom location","cloud","sdk","track2"],"install":[{"cmd":"pip install azure-mgmt-extendedlocation","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"ExtendedLocationMgmtClient","correct":"from azure.mgmt.extendedlocation import ExtendedLocationMgmtClient"},{"note":"Azure SDK for Python Track 2 libraries (like this one) use `azure.identity` for authentication, replacing older credential types.","wrong":"from azure.common.credentials import ServicePrincipalCredentials","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.extendedlocation import ExtendedLocationMgmtClient\n\n# Set your Azure Subscription ID as an environment variable (e.g., AZURE_SUBSCRIPTION_ID)\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\n\nif not subscription_id:\n    raise ValueError(\"AZURE_SUBSCRIPTION_ID environment variable must be set.\")\n\n# Authenticate using DefaultAzureCredential\n# This will attempt to authenticate via environment variables, managed identity,\n# Azure CLI, Azure Developer CLI, Visual Studio Code, etc.\ncredential = DefaultAzureCredential()\n\n# Create the ExtendedLocation Management client\nclient = ExtendedLocationMgmtClient(credential, subscription_id)\n\nprint(f\"Listing custom locations for subscription: {subscription_id}\")\n\n# Iterate through custom locations in the subscription\ntry:\n    custom_locations = client.custom_locations.list_by_subscription()\n    for cl in custom_locations:\n        print(f\"  - Custom Location Name: {cl.name}, Location: {cl.location}, ID: {cl.id}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Make sure your account has permissions and AZURE_SUBSCRIPTION_ID is correct.\")","lang":"python","description":"This quickstart demonstrates how to instantiate the `ExtendedLocationMgmtClient` using `DefaultAzureCredential` and list custom locations within your Azure subscription. Ensure `AZURE_SUBSCRIPTION_ID` is set as an environment variable and you have appropriate permissions."},"warnings":[{"fix":"Rewrite client instantiation and authentication to use `DefaultAzureCredential` from `azure.identity`. Refer to the official Azure SDK documentation for the new API surface.","message":"Major breaking changes occurred in Azure SDK for Python Track 2 (version 2.x) compared to older Track 1 versions (0.x or 1.x). Client instantiation, authentication (now using `azure.identity`), and object models have been completely revised.","severity":"breaking","affected_versions":"0.x.x, 1.x.x -> 2.x.x"},{"fix":"Ensure the necessary environment variables are set or you are logged in via an authenticated tool like Azure CLI (`az login`). For service principals, ensure required variables are present. The `AZURE_SUBSCRIPTION_ID` must also be explicitly passed to the management client.","message":"Authentication with `DefaultAzureCredential` relies on specific environment variables (e.g., `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID` for service principals, or `AZURE_SUBSCRIPTION_ID` for the management client) or other configured authentication mechanisms (Azure CLI, VS Code, etc.). Misconfiguration will lead to `CredentialUnavailableError`.","severity":"gotcha","affected_versions":"All 2.x.x versions"},{"fix":"Always call `.result()` on the object returned by methods like `create_or_update` to ensure the operation has finished and to get the fully provisioned resource: `custom_location = client.custom_locations.begin_create_or_update(...).result()`.","message":"Many resource creation or update operations in Azure management libraries are Long Running Operations (LROs). These methods return a poller object (e.g., `LROPoller`) immediately. You must call `.result()` on the poller to wait for the operation to complete and retrieve the final resource object.","severity":"gotcha","affected_versions":"All 2.x.x versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}