Install & Compatibility
Where this runs
tested against v11.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.316s · 57.7MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.7s · import 1.180s · 58MB
59MB installed
● package 59MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
WebSiteManagementClient
✓ from azure.mgmt.web import WebSiteManagementClient
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
✗ from azure.common.credentials import ServicePrincipalCredentials
Legacy authentication methods (e.g., from azure.common) are deprecated; use azure-identity for modern authentication patterns.
This quickstart demonstrates how to authenticate using `DefaultAzureCredential` and then list all App Service Plans within your Azure subscription using the `WebSiteManagementClient`. Ensure your `AZURE_SUBSCRIPTION_ID` environment variable is set and you're authenticated (e.g., via `az login`).
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.web import WebSiteManagementClient
# Ensure AZURE_SUBSCRIPTION_ID is set in your environment variables,
# or replace 'YOUR_SUBSCRIPTION_ID' directly. Make sure you are also
# logged in via Azure CLI ('az login') or have other AZURE_IDENTITY
# environment variables configured for DefaultAzureCredential to work.
# Retrieve Azure Subscription ID from environment variable
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "YOUR_SUBSCRIPTION_ID")
if subscription_id == "YOUR_SUBSCRIPTION_ID":
print("WARNING: Please set the AZURE_SUBSCRIPTION_ID environment variable or replace 'YOUR_SUBSCRIPTION_ID'.")
# Exit or raise error if no subscription ID is available for a real run
# exit(1)
try:
# Authenticate with Azure. DefaultAzureCredential attempts several common auth methods.
credential = DefaultAzureCredential()
# Create a WebSiteManagementClient instance
web_client = WebSiteManagementClient(credential, subscription_id)
print(f"Listing App Service Plans in subscription: {subscription_id}")
# List all App Service Plans in the subscription
app_service_plans = web_client.app_service_plans.list()
found_plans = False
for plan in app_service_plans:
print(f"- Name: {plan.name}, Resource Group: {plan.resource_group_name}, Location: {plan.location}")
found_plans = True
if not found_plans:
print("No App Service Plans found or you may not have access to any.")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure you are authenticated (e.g., 'az login') and have the correct AZURE_SUBSCRIPTION_ID.")
Debug
Known issues
breakingMajor breaking changes occurred in version 9.0.0 regarding client construction and authentication. Older patterns using separate `azure.common.credentials` or `ServicePrincipalCredentials` objects are no longer supported.fixUpgrade to `azure-identity` and use `DefaultAzureCredential` (or other credentials from `azure-identity`). Client constructors now directly accept a credential object and the subscription ID: `WebSiteManagementClient(credential, subscription_id)`.
affects: Before 9.0.0
gotcha`DefaultAzureCredential` requires proper environment setup (e.g., `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`) or an active Azure CLI login (`az login`). Without this, authentication will fail.fixRefer to the `azure-identity` documentation for setting up authentication. For local development, `az login` is often sufficient. Ensure necessary environment variables are set for non-interactive scenarios.
affects: All versions using azure-identity
gotchaMany list operations (e.g., `list()`, `list_by_resource_group()`) return paginated iterators, not complete lists. You must iterate over the result to access all items.fixAlways loop through the result of `list` methods. Do not assume the first call returns all items. Example: `for item in client.resources.list(): ...`
affects: All versions
gotchaMany Azure Web Management operations are scoped to a specific resource group or location. Omitting these or providing incorrect values will lead to errors or resource not found.fixAlways provide the correct `resource_group_name` and `location` parameters where required by the API. Use `ResourceManagementClient` (from `azure-mgmt-resource`) to list available resource groups and locations if unsure.
affects: All versions
Upgrade
Version history
11.0.1latest on PyPI · released Jul 13, 2026
Audit
Dependencies
azure-mgmt-corerequiredProvides core functionalities for Azure management plane clients.
azure-identityrequiredRecommended library for authentication with Azure services (e.g., DefaultAzureCredential).