CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-web

Microsoft Azure Web Apps Management Client Library for Python

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

web-applications.mddocs/

Web Applications Management

Core functionality for managing Azure Web Apps, API Apps, and mobile app backends. This includes creation, configuration, deployment, scaling, monitoring, and lifecycle management of web applications hosted on Azure App Service.

Capabilities

Application Lifecycle Management

Create, update, delete, and manage the lifecycle of web applications with comprehensive configuration options.

def create_or_update(
    resource_group_name: str,
    name: str,
    site_envelope: Site,
    **kwargs
) -> Site:
    """
    Creates a new web app or updates an existing one.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - site_envelope (Site): Web app configuration and properties
    
    Returns:
    Site: The created or updated web app resource
    """

def get(
    resource_group_name: str,
    name: str,
    **kwargs
) -> Site:
    """
    Gets details of a specific web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    
    Returns:
    Site: Web app details and configuration
    """

def delete(
    resource_group_name: str,
    name: str,
    delete_metrics: Optional[bool] = None,
    delete_empty_server_farm: Optional[bool] = None,
    **kwargs
) -> None:
    """
    Deletes a web app, deployment slot, or specific version.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - delete_metrics (bool, optional): Delete metrics if true
    - delete_empty_server_farm (bool, optional): Delete server farm if empty
    """

def list(
    **kwargs
) -> List[Site]:
    """
    Lists all web apps in the subscription.
    
    Returns:
    List[Site]: List of all web apps
    """

def list_by_resource_group(
    resource_group_name: str,
    include_slots: Optional[bool] = None,
    **kwargs
) -> List[Site]:
    """
    Lists web apps in a specific resource group.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - include_slots (bool, optional): Include deployment slots
    
    Returns:
    List[Site]: List of web apps in the resource group
    """

def update(
    resource_group_name: str,
    name: str,
    site_envelope: SitePatchResource,
    **kwargs
) -> Site:
    """
    Updates an existing web app with patch operations.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - site_envelope (SitePatchResource): Properties to update
    
    Returns:
    Site: Updated web app resource
    """

Application Control Operations

Start, stop, restart web applications and manage their operational state.

def start(
    resource_group_name: str,
    name: str,
    **kwargs
) -> None:
    """
    Starts a stopped web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    """

def stop(
    resource_group_name: str,
    name: str,
    **kwargs
) -> None:
    """
    Stops a running web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    """

def restart(
    resource_group_name: str,
    name: str,
    soft_restart: Optional[bool] = None,
    synchronous: Optional[bool] = None,
    **kwargs
) -> None:
    """
    Restarts a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - soft_restart (bool, optional): Perform soft restart if true
    - synchronous (bool, optional): Wait for restart completion if true
    """

Application Settings and Configuration

Manage application settings, connection strings, and site configuration.

def list_application_settings(
    resource_group_name: str,
    name: str,
    **kwargs
) -> StringDictionary:
    """
    Gets application settings for a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    
    Returns:
    StringDictionary: Application settings key-value pairs
    """

def update_application_settings(
    resource_group_name: str,
    name: str,
    app_settings: StringDictionary,
    **kwargs
) -> StringDictionary:
    """
    Updates application settings for a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - app_settings (StringDictionary): New application settings
    
    Returns:
    StringDictionary: Updated application settings
    """

def list_connection_strings(
    resource_group_name: str,
    name: str,
    **kwargs
) -> ConnectionStringDictionary:
    """
    Gets connection strings for a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    
    Returns:
    ConnectionStringDictionary: Connection strings configuration
    """

def update_connection_strings(
    resource_group_name: str,
    name: str,
    connection_strings: ConnectionStringDictionary,
    **kwargs
) -> ConnectionStringDictionary:
    """
    Updates connection strings for a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - connection_strings (ConnectionStringDictionary): New connection strings
    
    Returns:
    ConnectionStringDictionary: Updated connection strings
    """

def get_configuration(
    resource_group_name: str,
    name: str,
    **kwargs
) -> SiteConfig:
    """
    Gets site configuration for a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    
    Returns:
    SiteConfig: Site configuration settings
    """

def update_configuration(
    resource_group_name: str,
    name: str,
    site_config: SiteConfig,
    **kwargs
) -> SiteConfig:
    """
    Updates site configuration for a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - site_config (SiteConfig): New site configuration settings
    
    Returns:
    SiteConfig: Updated site configuration
    """

Deployment Operations

Manage application deployments, source control, and backup operations.

def list_deployments(
    resource_group_name: str,
    name: str,
    **kwargs
) -> List[Deployment]:
    """
    Lists deployments for a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    
    Returns:
    List[Deployment]: List of deployments
    """

def create_deployment(
    resource_group_name: str,
    name: str,
    id: str,
    deployment: Deployment,
    **kwargs
) -> Deployment:
    """
    Creates a deployment for a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - id (str): Deployment ID
    - deployment (Deployment): Deployment configuration
    
    Returns:
    Deployment: Created deployment
    """

def sync_repository(
    resource_group_name: str,
    name: str,
    **kwargs
) -> None:
    """
    Synchronizes repository for continuous deployment.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    """

def backup(
    resource_group_name: str,
    name: str,
    request: BackupRequest,
    **kwargs
) -> BackupItem:
    """
    Creates a backup of a web app.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - request (BackupRequest): Backup configuration
    
    Returns:
    BackupItem: Backup information
    """

def restore(
    resource_group_name: str,
    name: str,
    backup_id: str,
    request: RestoreRequest,
    **kwargs
) -> None:
    """
    Restores a web app from backup.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - backup_id (str): Backup identifier
    - request (RestoreRequest): Restore configuration
    """

Deployment Slots Management

Manage deployment slots for staging and production deployments.

def create_or_update_slot(
    resource_group_name: str,
    name: str,
    slot: str,
    site_envelope: Site,
    **kwargs
) -> Site:
    """
    Creates or updates a deployment slot.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - slot (str): Name of the deployment slot
    - site_envelope (Site): Slot configuration
    
    Returns:
    Site: Created or updated deployment slot
    """

def get_slot(
    resource_group_name: str,
    name: str,
    slot: str,
    **kwargs
) -> Site:
    """
    Gets details of a deployment slot.
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - slot (str): Name of the deployment slot
    
    Returns:
    Site: Deployment slot details
    """

def swap_slot(
    resource_group_name: str,
    name: str,
    slot_swap_entity: CsmSlotEntity,
    **kwargs
) -> None:
    """
    Swaps deployment slots (e.g., staging to production).
    
    Parameters:
    - resource_group_name (str): Name of the resource group
    - name (str): Name of the web app
    - slot_swap_entity (CsmSlotEntity): Slot swap configuration
    """

Deleted Web Apps Recovery

Azure provides the ability to recover accidentally deleted web applications within a retention period.

List Deleted Web Apps

Retrieve all deleted web applications available for recovery.

def list_deleted(self, **kwargs) -> List[DeletedSite]:
    """
    List all deleted web apps in the subscription.
    
    Returns:
        List of DeletedSite objects
    """

def list_deleted_by_location(
    self,
    location: str,
    **kwargs
) -> List[DeletedSite]:
    """
    List deleted web apps in a specific location.
    
    Args:
        location: Azure region name
        
    Returns:
        List of DeletedSite objects
    """

Get Deleted Web App Details

Retrieve details for a specific deleted web application.

def get_deleted_web_app_by_location(
    self,
    location: str,
    deleted_site_id: str,
    **kwargs
) -> DeletedSite:
    """
    Get details for a deleted web app.
    
    Args:
        location: Azure region where the app was deleted
        deleted_site_id: ID of the deleted site
        
    Returns:
        DeletedSite object with recovery information
    """

Usage Example:

# List all deleted web apps
deleted_apps = client.deleted_web_apps.list_deleted()

for app in deleted_apps:
    print(f"Deleted App: {app.deleted_site_name}")
    print(f"Deleted Time: {app.deleted_timestamp}")
    print(f"Resource Group: {app.resource_group}")
    print(f"Location: {app.geo_region_name}")

# List deleted apps in specific region
deleted_east_us = client.deleted_web_apps.list_deleted_by_location(
    location="East US"
)

# Get specific deleted app details
deleted_app_details = client.deleted_web_apps.get_deleted_web_app_by_location(
    location="East US",
    deleted_site_id="deleted-app-12345"
)

# To restore a deleted web app, use the regular create_or_update operation
# with the same name and resource group as the deleted app

Note: Deleted web apps are retained for approximately 30 days and can be restored by creating a new web app with the same name in the same resource group and location. The restoration process will automatically recover the app's configuration and content if still available.

Types

class Site:
    """Represents a web app resource."""
    id: Optional[str]
    name: Optional[str]
    type: Optional[str]
    location: str
    tags: Optional[Dict[str, str]]
    server_farm_id: Optional[str]
    enabled: Optional[bool]
    host_names: Optional[List[str]]
    host_names_disabled: Optional[bool]
    enabled_host_names: Optional[List[str]]
    availability_state: Optional[SiteAvailabilityState]
    state: Optional[str]
    usage_state: Optional[UsageState]
    site_config: Optional[SiteConfig]
    reserved: Optional[bool]
    is_xenon: Optional[bool]
    hyper_v: Optional[bool]
    client_affinity_enabled: Optional[bool]
    client_cert_enabled: Optional[bool]
    https_only: Optional[bool]
    redundancy_mode: Optional[RedundancyMode]

class SitePatchResource:
    """Properties for updating a web app."""
    enabled: Optional[bool]
    host_names_disabled: Optional[bool]
    server_farm_id: Optional[str]
    site_config: Optional[SiteConfig]
    client_affinity_enabled: Optional[bool]
    client_cert_enabled: Optional[bool]
    https_only: Optional[bool]

class StringDictionary:
    """Dictionary of string key-value pairs."""
    properties: Optional[Dict[str, str]]

class ConnectionStringDictionary:
    """Dictionary of connection strings."""
    properties: Optional[Dict[str, ConnStringValueTypePair]]

class ConnStringValueTypePair:
    """Connection string value and type pair."""
    value: str
    type: ConnectionStringType

class BackupRequest:
    """Request for creating a backup."""
    backup_name: Optional[str]
    enabled: Optional[bool]
    storage_account_url: str
    backup_schedule: Optional[BackupSchedule]

class RestoreRequest:
    """Request for restoring from backup."""
    storage_account_url: str
    blob_name: Optional[str]
    overwrite: bool
    site_name: Optional[str]
    operation_type: BackupRestoreOperationType

class CsmSlotEntity:
    """Slot swap configuration."""
    target_slot: str
    preserve_vnet: bool

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]

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-web

docs

app-service-environments.md

app-service-plans.md

application-configuration.md

certificates-domains.md

deployment-management.md

diagnostics-monitoring.md

index.md

kubernetes-environments.md

static-sites.md

web-applications.md

workflow-management.md

tile.json