{"id":1387,"library":"azure-mgmt-web","title":"Azure Web Management Client Library","description":"The `azure-mgmt-web` library provides a Pythonic interface for managing Azure App Services, Azure Functions, and other web-related resources within your Azure subscription. It is part of the Azure SDK for Python, allowing programmatic control over deployments, scaling, configurations, and monitoring of web applications. The current version is 10.1.0, and new versions are released regularly, often aligning with updates to the Azure REST API and broader Azure SDK guidelines.","status":"active","version":"10.1.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/websites/azure-mgmt-web","tags":["Azure","Cloud","Management","PaaS","Web Apps","Functions","App Service"],"install":[{"cmd":"pip install azure-mgmt-web azure-identity","lang":"bash","label":"Install core library and authentication"}],"dependencies":[{"reason":"Provides core functionalities for Azure management plane clients.","package":"azure-mgmt-core","optional":false},{"reason":"Recommended library for authentication with Azure services (e.g., DefaultAzureCredential).","package":"azure-identity","optional":false}],"imports":[{"symbol":"WebSiteManagementClient","correct":"from azure.mgmt.web import WebSiteManagementClient"},{"note":"Legacy authentication methods (e.g., from azure.common) are deprecated; use azure-identity for modern authentication patterns.","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.web import WebSiteManagementClient\n\n# Ensure AZURE_SUBSCRIPTION_ID is set in your environment variables,\n# or replace 'YOUR_SUBSCRIPTION_ID' directly. Make sure you are also\n# logged in via Azure CLI ('az login') or have other AZURE_IDENTITY\n# environment variables configured for DefaultAzureCredential to work.\n\n# Retrieve Azure Subscription ID from environment variable\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"YOUR_SUBSCRIPTION_ID\")\n\nif subscription_id == \"YOUR_SUBSCRIPTION_ID\":\n    print(\"WARNING: Please set the AZURE_SUBSCRIPTION_ID environment variable or replace 'YOUR_SUBSCRIPTION_ID'.\")\n    # Exit or raise error if no subscription ID is available for a real run\n    # exit(1)\n\ntry:\n    # Authenticate with Azure. DefaultAzureCredential attempts several common auth methods.\n    credential = DefaultAzureCredential()\n\n    # Create a WebSiteManagementClient instance\n    web_client = WebSiteManagementClient(credential, subscription_id)\n\n    print(f\"Listing App Service Plans in subscription: {subscription_id}\")\n\n    # List all App Service Plans in the subscription\n    app_service_plans = web_client.app_service_plans.list()\n\n    found_plans = False\n    for plan in app_service_plans:\n        print(f\"- Name: {plan.name}, Resource Group: {plan.resource_group_name}, Location: {plan.location}\")\n        found_plans = True\n    \n    if not found_plans:\n        print(\"No App Service Plans found or you may not have access to any.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure you are authenticated (e.g., 'az login') and have the correct AZURE_SUBSCRIPTION_ID.\")\n","lang":"python","description":"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`)."},"warnings":[{"fix":"Upgrade 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)`.","message":"Major 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.","severity":"breaking","affected_versions":"Before 9.0.0"},{"fix":"Refer 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.","message":"`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.","severity":"gotcha","affected_versions":"All versions using azure-identity"},{"fix":"Always loop through the result of `list` methods. Do not assume the first call returns all items. Example: `for item in client.resources.list(): ...`","message":"Many 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always 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.","message":"Many 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}