Microsoft Azure Resource Management Client Library for Python providing comprehensive Azure resource lifecycle, governance, and deployment capabilities.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Resource locks for preventing accidental deletion or modification, resource links for creating relationships, managed applications, and data boundary management. These services provide additional governance and management capabilities for Azure resources.
Protect critical resources by applying locks that prevent deletion or modification at the subscription, resource group, or resource level.
class ManagementLocksOperations:
def create_or_update_at_resource_group_level(
self,
resource_group_name: str,
lock_name: str,
parameters: ManagementLockObject,
**kwargs
) -> ManagementLockObject:
"""
Create or update a lock at the resource group level.
Args:
resource_group_name (str): Resource group name
lock_name (str): Lock name
parameters (ManagementLockObject): Lock properties
Returns:
ManagementLockObject: The created lock
"""
def delete_at_resource_group_level(
self,
resource_group_name: str,
lock_name: str,
**kwargs
) -> None:
"""Delete a lock at the resource group level."""
def get_at_resource_group_level(
self,
resource_group_name: str,
lock_name: str,
**kwargs
) -> ManagementLockObject:
"""Get a lock at the resource group level."""
def create_or_update_by_scope(
self,
scope: str,
lock_name: str,
parameters: ManagementLockObject,
**kwargs
) -> ManagementLockObject:
"""
Create or update a lock at any scope.
Args:
scope (str): Lock scope (subscription, resource group, or resource)
lock_name (str): Lock name
parameters (ManagementLockObject): Lock properties
Returns:
ManagementLockObject: The created lock
"""
def delete_by_scope(
self,
scope: str,
lock_name: str,
**kwargs
) -> None:
"""Delete a lock at any scope."""
def get_by_scope(
self,
scope: str,
lock_name: str,
**kwargs
) -> ManagementLockObject:
"""Get a lock at any scope."""
def create_or_update_at_resource_level(
self,
resource_group_name: str,
resource_provider_namespace: str,
parent_resource_path: str,
resource_type: str,
resource_name: str,
lock_name: str,
parameters: ManagementLockObject,
**kwargs
) -> ManagementLockObject:
"""Create or update a lock at the resource level."""
def create_or_update_at_subscription_level(
self,
lock_name: str,
parameters: ManagementLockObject,
**kwargs
) -> ManagementLockObject:
"""Create or update a lock at the subscription level."""
def list_at_subscription_level(
self,
**kwargs
) -> Iterable[ManagementLockObject]:
"""
List locks at the subscription level.
Returns:
Iterable[ManagementLockObject]: Iterator of locks
"""
def list_at_resource_group_level(
self,
resource_group_name: str,
**kwargs
) -> Iterable[ManagementLockObject]:
"""List locks at the resource group level."""
def list_by_scope(
self,
scope: str,
**kwargs
) -> Iterable[ManagementLockObject]:
"""List locks at any scope."""Create and manage links between Azure resources to represent dependencies and relationships.
class ResourceLinksOperations:
def delete(self, link_id: str, **kwargs) -> None:
"""
Delete a resource link.
Args:
link_id (str): Link ID
"""
def create_or_update(
self,
link_id: str,
parameters: ResourceLink,
**kwargs
) -> ResourceLink:
"""
Create or update a resource link.
Args:
link_id (str): Link ID
parameters (ResourceLink): Link properties
Returns:
ResourceLink: The created link
"""
def get(self, link_id: str, **kwargs) -> ResourceLink:
"""
Get a resource link.
Args:
link_id (str): Link ID
Returns:
ResourceLink: Link details
"""
def list_at_subscription(self, **kwargs) -> Iterable[ResourceLink]:
"""
List all resource links in the subscription.
Returns:
Iterable[ResourceLink]: Iterator of resource links
"""
def list_at_source_scope(
self,
scope: str,
**kwargs
) -> Iterable[ResourceLink]:
"""
List resource links at a specific source scope.
Args:
scope (str): Source scope
Returns:
Iterable[ResourceLink]: Iterator of resource links
"""Manage Azure managed applications including application definitions and application instances.
class ApplicationsOperations:
def get(
self,
resource_group_name: str,
application_name: str,
**kwargs
) -> Application:
"""
Get managed application details.
Args:
resource_group_name (str): Resource group name
application_name (str): Application name
Returns:
Application: Application details
"""
def delete(
self,
resource_group_name: str,
application_name: str,
**kwargs
) -> None:
"""Delete a managed application."""
def begin_create_or_update(
self,
resource_group_name: str,
application_name: str,
parameters: Application,
**kwargs
) -> LROPoller[Application]:
"""
Create or update a managed application.
Args:
resource_group_name (str): Resource group name
application_name (str): Application name
parameters (Application): Application properties
Returns:
LROPoller[Application]: Long-running operation poller
"""
def update(
self,
resource_group_name: str,
application_name: str,
parameters: ApplicationPatchable,
**kwargs
) -> Application:
"""Update a managed application."""
def list_by_resource_group(
self,
resource_group_name: str,
**kwargs
) -> Iterable[Application]:
"""List managed applications in a resource group."""
def list_by_subscription(self, **kwargs) -> Iterable[Application]:
"""List managed applications in the subscription."""
def update_access(
self,
resource_group_name: str,
application_name: str,
parameters: UpdateAccessDefinition,
**kwargs
) -> UpdateAccessDefinition:
"""Update access permissions for a managed application."""Manage application definitions that define the blueprint for managed applications.
class ApplicationDefinitionsOperations:
def get(
self,
resource_group_name: str,
application_definition_name: str,
**kwargs
) -> ApplicationDefinition:
"""Get application definition details."""
def delete(
self,
resource_group_name: str,
application_definition_name: str,
**kwargs
) -> None:
"""Delete an application definition."""
def begin_create_or_update(
self,
resource_group_name: str,
application_definition_name: str,
parameters: ApplicationDefinition,
**kwargs
) -> LROPoller[ApplicationDefinition]:
"""Create or update an application definition."""
def list_by_resource_group(
self,
resource_group_name: str,
**kwargs
) -> Iterable[ApplicationDefinition]:
"""List application definitions in a resource group."""
def list_by_subscription(self, **kwargs) -> Iterable[ApplicationDefinition]:
"""List application definitions in the subscription."""
def get_by_id(
self,
application_definition_id: str,
**kwargs
) -> ApplicationDefinition:
"""Get application definition by ID."""
def begin_create_or_update_by_id(
self,
application_definition_id: str,
parameters: ApplicationDefinition,
**kwargs
) -> LROPoller[ApplicationDefinition]:
"""Create or update application definition by ID."""
def begin_delete_by_id(
self,
application_definition_id: str,
**kwargs
) -> LROPoller[None]:
"""Delete application definition by ID."""Manage data boundary policies and configurations for data residency and compliance requirements.
class DataBoundariesOperations:
def get_scope(self, scope: str, **kwargs) -> DataBoundaryDefinition:
"""
Get data boundary definition for a scope.
Args:
scope (str): Data boundary scope
Returns:
DataBoundaryDefinition: Data boundary definition
"""
def put_scope(
self,
scope: str,
data_boundary_definition: DataBoundaryDefinition,
**kwargs
) -> DataBoundaryDefinition:
"""
Create or update data boundary definition for a scope.
Args:
scope (str): Data boundary scope
data_boundary_definition (DataBoundaryDefinition): Data boundary properties
Returns:
DataBoundaryDefinition: Updated data boundary definition
"""class ManagementLockObject:
"""Management lock model."""
id: str
type: str
name: str
level: LockLevel
notes: str
owners: List[ManagementLockOwner]
class ManagementLockOwner:
"""Lock owner information."""
application_id: str
class ResourceLink:
"""Resource link model."""
id: str
name: str
type: str
properties: ResourceLinkProperties
class ResourceLinkProperties:
"""Resource link properties."""
source_id: str
target_id: str
notes: str
class Application:
"""Managed application model."""
id: str
name: str
type: str
location: str
tags: Dict[str, str]
managed_by: str
sku: Sku
identity: Identity
properties: ApplicationProperties
plan: Plan
kind: str
class ApplicationProperties:
"""Managed application properties."""
managed_resource_group_id: str
application_definition_id: str
parameters: Any
outputs: Any
provisioning_state: ProvisioningState
billing_details: ApplicationBillingDetailsDefinition
jit_access_policy: ApplicationJitAccessPolicy
publisher_tenant_id: str
authorizations: List[ApplicationAuthorization]
management_mode: ApplicationManagementMode
customer_support: ApplicationPackageContact
support_urls: ApplicationPackageSupportUrls
artifacts: List[ApplicationArtifact]
created_by: ApplicationClientDetails
updated_by: ApplicationClientDetails
class ApplicationDefinition:
"""Application definition model."""
id: str
name: str
type: str
location: str
tags: Dict[str, str]
managed_by: str
sku: Sku
identity: Identity
properties: ApplicationDefinitionProperties
class ApplicationDefinitionProperties:
"""Application definition properties."""
lock_level: ApplicationLockLevel
display_name: str
is_enabled: bool
authorizations: List[ApplicationProviderAuthorization]
artifacts: List[ApplicationDefinitionArtifact]
description: str
package_file_uri: str
main_template: Any
create_ui_definition: Any
notification_policy: ApplicationNotificationPolicy
locking_policy: ApplicationPackageLockingPolicyDefinition
deployment_policy: ApplicationDeploymentPolicy
management_policy: ApplicationManagementPolicy
policies: List[ApplicationPolicy]
class DataBoundaryDefinition:
"""Data boundary definition model."""
id: str
name: str
type: str
properties: DataBoundaryProperties
class DataBoundaryProperties:
"""Data boundary properties."""
data_boundary: DataBoundary
provisioning_state: str
class UpdateAccessDefinition:
"""Update access definition for managed applications."""
operation: str
updates: List[UpdateAccessDefinitionUpdate]class LockLevel(str, Enum):
"""Management lock levels."""
NOT_SPECIFIED = "NotSpecified"
CAN_NOT_DELETE = "CanNotDelete"
READ_ONLY = "ReadOnly"
class ApplicationLockLevel(str, Enum):
"""Application lock levels."""
CAN_NOT_DELETE = "CanNotDelete"
READ_ONLY = "ReadOnly"
NONE = "None"
class ApplicationManagementMode(str, Enum):
"""Application management modes."""
NOT_SPECIFIED = "NotSpecified"
UNMANAGED = "Unmanaged"
MANAGED = "Managed"
class DataBoundary(str, Enum):
"""Data boundary types."""
NOT_DEFINED = "NotDefined"
GLOBAL = "Global"
EU = "EU"Creating Resource Locks:
from azure.mgmt.resource.locks.models import ManagementLockObject, LockLevel
# Create a deletion lock on a resource group
lock_params = ManagementLockObject(
level=LockLevel.CAN_NOT_DELETE,
notes="Prevent accidental deletion of critical resources"
)
lock = lock_client.management_locks.create_or_update_at_resource_group_level(
resource_group_name="production-rg",
lock_name="deletion-protection",
parameters=lock_params
)
# List all locks in the subscription
for lock in lock_client.management_locks.list_at_subscription_level():
print(f"Lock: {lock.name}, Level: {lock.level}, Notes: {lock.notes}")Managing Resource Links:
from azure.mgmt.resource.links.models import ResourceLink, ResourceLinkProperties
# Create a link between two resources
link_props = ResourceLinkProperties(
source_id="/subscriptions/{sub}/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/storage1",
target_id="/subscriptions/{sub}/resourceGroups/rg2/providers/Microsoft.Web/sites/webapp1",
notes="Storage account used by web application"
)
link = ResourceLink(properties=link_props)
created_link = link_client.resource_links.create_or_update(
link_id="/subscriptions/{sub}/resourceGroups/rg1/providers/Microsoft.Resources/links/storage-webapp-link",
parameters=link
)
# List all resource links
for link in link_client.resource_links.list_at_subscription():
print(f"Link: {link.name}")
print(f" Source: {link.properties.source_id}")
print(f" Target: {link.properties.target_id}")Working with Managed Applications:
from azure.mgmt.resource.managedapplications.models import (
Application,
ApplicationProperties,
ApplicationLockLevel
)
# Get managed application details
app = app_client.applications.get("my-rg", "my-managed-app")
print(f"Application: {app.name}")
print(f"Managed RG: {app.properties.managed_resource_group_id}")
print(f"Definition: {app.properties.application_definition_id}")
# List all managed applications
for app in app_client.applications.list_by_subscription():
print(f"App: {app.name} in {app.location}")Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-resource