Microsoft Azure Web Apps Management Client Library for Python
npx @tessl/cli install tessl/pypi-azure-mgmt-web@10.0.0A comprehensive Python client library for managing Azure Web Apps and related web services through the Azure Resource Manager API. This library enables developers to programmatically create, configure, deploy, monitor, and manage web applications, API apps, and function apps on the Azure platform.
pip install azure-mgmt-webfrom azure.mgmt.web import WebSiteManagementClient
from azure.identity import DefaultAzureCredentialfrom azure.mgmt.web import WebSiteManagementClient
from azure.identity import DefaultAzureCredential
import os
# Authentication setup
credential = DefaultAzureCredential()
subscription_id = os.getenv("AZURE_SUBSCRIPTION_ID")
# Create the management client
client = WebSiteManagementClient(
credential=credential,
subscription_id=subscription_id
)
# List all web apps in subscription
web_apps = client.web_apps.list()
for app in web_apps:
print(f"App: {app.name}, Resource Group: {app.resource_group}")
# Get specific web app details
app_details = client.web_apps.get(
resource_group_name="my-resource-group",
name="my-web-app"
)
# Create a new App Service Plan
from azure.mgmt.web.models import AppServicePlan, SkuDescription
plan_params = AppServicePlan(
location="East US",
sku=SkuDescription(
name="B1",
tier="Basic",
capacity=1
)
)
plan = client.app_service_plans.begin_create_or_update(
resource_group_name="my-resource-group",
name="my-app-service-plan",
app_service_plan=plan_params
).result()The Azure Web Management Client is organized around a main client class that provides access to specialized operation classes:
The client uses the Azure Resource Manager REST API and provides high-level Python abstractions for managing web workloads at enterprise scale.
Core functionality for managing web applications, including creation, configuration, deployment, scaling, and monitoring. Handles web apps, API apps, and mobile app backends.
class WebAppsOperations:
def create_or_update(
self,
resource_group_name: str,
name: str,
site_envelope: Site,
**kwargs
) -> Site: ...
def get(
self,
resource_group_name: str,
name: str,
**kwargs
) -> Site: ...
def delete(
self,
resource_group_name: str,
name: str,
**kwargs
) -> None: ...
def list(self, **kwargs) -> List[Site]: ...
def restart(
self,
resource_group_name: str,
name: str,
**kwargs
) -> None: ...Recovery and management of deleted web applications, providing the ability to restore accidentally deleted apps and manage app lifecycle.
class DeletedWebAppsOperations:
def list(self, **kwargs) -> List[DeletedSite]: ...
def list_by_location(
self,
location: str,
**kwargs
) -> List[DeletedSite]: ...
def get_deleted_web_app_by_location(
self,
location: str,
deleted_site_id: str,
**kwargs
) -> DeletedSite: ...Management of App Service Plans that define the computing resources, scaling options, and pricing tiers for web applications.
class AppServicePlansOperations:
def begin_create_or_update(
self,
resource_group_name: str,
name: str,
app_service_plan: AppServicePlan,
**kwargs
) -> LROPoller[AppServicePlan]: ...
def get(
self,
resource_group_name: str,
name: str,
**kwargs
) -> AppServicePlan: ...
def list(self, **kwargs) -> List[AppServicePlan]: ...
def list_web_apps(
self,
resource_group_name: str,
name: str,
**kwargs
) -> List[Site]: ...Comprehensive SSL/TLS certificate and custom domain management including certificate orders, renewals, bindings, and domain registration.
class CertificatesOperations:
def create_or_update(
self,
resource_group_name: str,
name: str,
certificate_envelope: Certificate,
**kwargs
) -> Certificate: ...
class DomainsOperations:
def create_or_update(
self,
resource_group_name: str,
domain_name: str,
domain: Domain,
**kwargs
) -> Domain: ...Management of application settings, connection strings, authentication, and site configuration including runtime settings, environment variables, and deployment configurations.
class WebAppsOperations:
def list_application_settings(
self,
resource_group_name: str,
name: str,
**kwargs
) -> StringDictionary: ...
def update_application_settings(
self,
resource_group_name: str,
name: str,
app_settings: StringDictionary,
**kwargs
) -> StringDictionary: ...
def get_configuration(
self,
resource_group_name: str,
name: str,
**kwargs
) -> SiteConfig: ...Deployment operations including source control integration, continuous deployment, deployment slots, backups, and application deployment from various sources.
class WebAppsOperations:
def list_deployments(
self,
resource_group_name: str,
name: str,
**kwargs
) -> List[Deployment]: ...
def create_deployment(
self,
resource_group_name: str,
name: str,
id: str,
deployment: Deployment,
**kwargs
) -> Deployment: ...
def backup(
self,
resource_group_name: str,
name: str,
request: BackupRequest,
**kwargs
) -> BackupItem: ...Management of Azure Static Web Apps including build configuration, custom domains, user authentication, and API integration.
class StaticSitesOperations:
def create_or_update_static_site(
self,
resource_group_name: str,
name: str,
static_site_envelope: StaticSiteARMResource,
**kwargs
) -> StaticSiteARMResource: ...
def get_static_site(
self,
resource_group_name: str,
name: str,
**kwargs
) -> StaticSiteARMResource: ...Logic Apps workflow management including workflow definitions, runs, triggers, actions, and integration with other Azure services.
class WorkflowsOperations:
def create_or_update(
self,
resource_group_name: str,
name: str,
workflow_name: str,
workflow: Workflow,
**kwargs
) -> Workflow: ...
class WorkflowRunsOperations:
def list(
self,
resource_group_name: str,
name: str,
workflow_name: str,
**kwargs
) -> List[WorkflowRun]: ...Diagnostic capabilities, recommendations, health monitoring, and troubleshooting tools for web applications and services.
class DiagnosticsOperations:
def list_hosting_environment_detector_responses(
self,
resource_group_name: str,
name: str,
**kwargs
) -> List[DetectorResponse]: ...
class RecommendationsOperations:
def list(self, **kwargs) -> List[Recommendation]: ...Management of Kubernetes environments for container-based applications and microservices hosted on Azure Kubernetes Service integration.
class KubeEnvironmentsOperations:
def create_or_update(
self,
resource_group_name: str,
name: str,
kube_environment_envelope: KubeEnvironment,
**kwargs
) -> KubeEnvironment: ...
def get(
self,
resource_group_name: str,
name: str,
**kwargs
) -> KubeEnvironment: ...
def list_by_resource_group(
self,
resource_group_name: str,
**kwargs
) -> List[KubeEnvironment]: ...Management of App Service Environments (ASE) for isolated, high-scale application hosting with advanced networking and security features.
class AppServiceEnvironmentsOperations:
def create_or_update(
self,
resource_group_name: str,
name: str,
hosting_environment_envelope: AppServiceEnvironment,
**kwargs
) -> AppServiceEnvironment: ...Core types used across the API:
class WebSiteManagementClient:
def __init__(
self,
credential: TokenCredential,
subscription_id: str,
base_url: Optional[str] = None,
api_version: str = "2024-11-01",
**kwargs
): ...
def close(self) -> None: ...
class Site:
"""Represents a web app or function app resource."""
id: Optional[str]
name: Optional[str]
type: Optional[str]
location: str
resource_group: Optional[str]
server_farm_id: Optional[str]
enabled: Optional[bool]
host_names: Optional[List[str]]
repository_site_name: Optional[str]
usage_state: Optional[UsageState]
site_config: Optional[SiteConfig]
class AppServicePlan:
"""Represents an App Service plan resource."""
id: Optional[str]
name: Optional[str]
type: Optional[str]
location: str
sku: Optional[SkuDescription]
worker_size: Optional[WorkerSizeOptions]
number_of_workers: Optional[int]
hosting_environment_profile: Optional[HostingEnvironmentProfile]
class SiteConfig:
"""Configuration settings for a web app."""
number_of_workers: Optional[int]
default_documents: Optional[List[str]]
net_framework_version: Optional[str]
php_version: Optional[str]
python_version: Optional[str]
node_version: Optional[str]
linux_fx_version: Optional[str]
windows_fx_version: Optional[str]
request_tracing_enabled: Optional[bool]
http_logging_enabled: Optional[bool]
logs_directory_size_limit: Optional[int]
detailed_error_logging_enabled: Optional[bool]
app_settings: Optional[List[NameValuePair]]
connection_strings: Optional[List[ConnStringInfo]]
class DeletedSite:
"""Represents a deleted web application that can be restored."""
id: Optional[str]
name: Optional[str]
type: Optional[str]
deleted_site_id: Optional[str]
deleted_timestamp: Optional[str]
subscription: Optional[str]
resource_group: Optional[str]
deleted_site_name: Optional[str]
slot: Optional[str]
kind: Optional[str]
geo_region_name: Optional[str]
class KubeEnvironment:
"""Represents a Kubernetes environment for container apps."""
id: Optional[str]
name: Optional[str]
type: Optional[str]
location: str
kind: Optional[str]
provisioning_state: Optional[str]
deployment_errors: Optional[str]
is_internal: Optional[bool]
default_domain: Optional[str]
static_ip: Optional[str]
container_apps_configuration: Optional[ContainerAppsConfiguration]
app_logs_configuration: Optional[AppLogsConfiguration]