{"id":1365,"library":"azure-mgmt-iotcentral","title":"Azure IoT Central Management","description":"The `azure-mgmt-iotcentral` library is the Microsoft Azure IoT Central Management Client Library for Python, enabling programmatic control and management of IoT Central applications. It is part of the Azure SDK for Python (Track 2 design) and currently at version 9.0.0. Azure SDK libraries follow a consistent release cadence, with updates often coinciding with new Azure service features or bug fixes.","status":"active","version":"9.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/iotcentral/azure-mgmt-iotcentral","tags":["azure","iot","iot-central","cloud","management","microsoft"],"install":[{"cmd":"pip install azure-mgmt-iotcentral azure-identity","lang":"bash","label":"Install with identity"}],"dependencies":[{"reason":"Required for authentication using Azure Active Directory, highly recommended for production.","package":"azure-identity","optional":false},{"reason":"Base components for the Azure SDK for Python, automatically installed.","package":"azure-core","optional":false}],"imports":[{"symbol":"IotCentralManagementClient","correct":"from azure.mgmt.iotcentral import IotCentralManagementClient"},{"note":"DefaultAzureCredential is the recommended and modern way to authenticate across environments, replacing older credential types.","wrong":"from msrestazure.azure_active_directory import ServicePrincipalCredentials","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.iotcentral import IotCentralManagementClient\n\n# Retrieve your subscription ID from an environment variable or replace with your actual ID\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\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 several ways, including\n# environment variables, managed identity, Azure CLI, and Visual Studio Code.\ncredential = DefaultAzureCredential()\n\n# Create an IoT Central Management client\nclient = IotCentralManagementClient(credential, subscription_id)\n\n# List all IoT Central applications in the subscription\nprint(\"Listing all IoT Central applications in the subscription:\")\nfor app in client.apps.list_by_subscription():\n    print(f\"- App Name: {app.display_name or app.name}, Location: {app.location}, SKU: {app.sku.name}\")\n\n# Example: Get an existing IoT Central application by name within a resource group\n# Replace with an actual app name and resource group you have, or set via environment variables\nresource_group_name = os.environ.get(\"AZURE_RESOURCE_GROUP\", \"my-resource-group\")\niot_central_app_name = os.environ.get(\"AZURE_IOTCENTRAL_APP_NAME\", \"my-iotc-app\")\n\nif resource_group_name and iot_central_app_name:\n    try:\n        print(f\"\\nAttempting to get app '{iot_central_app_name}' in resource group '{resource_group_name}':\")\n        app_details = client.apps.get(resource_group_name, iot_central_app_name)\n        print(f\"Found app: {app_details.display_name or app_details.name}, SKU: {app_details.sku.name}, ID: {app_details.id}\")\n    except Exception as e:\n        print(f\"Could not retrieve app {iot_central_app_name} (might not exist, permission issue, or incorrect RG/name): {e}\")\nelse:\n    print(\"\\nSkipping 'Get app' example: AZURE_RESOURCE_GROUP or AZURE_IOTCENTRAL_APP_NAME not set.\")","lang":"python","description":"This quickstart demonstrates how to authenticate with `DefaultAzureCredential`, create an `IotCentralManagementClient`, and then list all IoT Central applications within your Azure subscription. It also includes an example of retrieving a specific application by name and resource group."},"warnings":[{"fix":"Refer to the official migration guides in the Azure SDK for Python documentation for specific changes between major versions. Update code to use new method signatures and object structures.","message":"Major version updates (e.g., v8.x to v9.x) in Azure management plane SDKs often introduce breaking changes due to underlying REST API version updates or SDK design changes. This typically affects method signatures, parameter names, and object models.","severity":"breaking","affected_versions":"8.x.x to 9.x.x"},{"fix":"Always call `.result()` on the poller object returned by LROs: `resource = client.apps.begin_create_or_update(...).result()`.","message":"Many resource creation or update operations (e.g., `create_or_update`) are long-running operations (LROs) and return a poller object. Failing to call `.result()` on the poller will mean the operation might not have completed when you expect, potentially leading to errors if you immediately try to use the resource.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always iterate completely over the returned iterable, for example, using a `for` loop: `for item in client.apps.list_by_subscription(): ...`.","message":"List operations (e.g., `client.apps.list_by_subscription()`) return an iterable that yields results lazily. If you only iterate a few times or convert it to a list without iterating fully, you might not retrieve all resources, especially in subscriptions with many items.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Migrate authentication to use `azure-identity.DefaultAzureCredential`. This provides a robust and flexible authentication mechanism that works across various Azure environments without code changes.","message":"Direct use of `ServicePrincipalCredentials` or `AzureCliCredential` from older modules (like `msrestazure.azure_active_directory`) is deprecated in favor of `azure-identity`'s `DefaultAzureCredential` or more specific credential types.","severity":"deprecated","affected_versions":"< 9.0.0 (and older SDK patterns)"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}