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
Core Azure resource lifecycle management including deployments, resource groups, providers, and resource operations. The ResourceManagementClient is the primary client for most Azure resource management tasks, providing comprehensive CRUD operations and deployment capabilities.
Manage Azure resource groups - logical containers that hold related resources for an Azure solution.
from typing import Union, Optional, List, Dict, Any
from typing_extensions import Literal
from azure.core.polling import LROPoller
from azure.core.paging import ItemPaged
from io import IOBase
class ResourceGroupsOperations:
def create_or_update(
self,
resource_group_name: str,
parameters: Union[ResourceGroup, IO[bytes]],
**kwargs
) -> ResourceGroup:
"""
Create or update a resource group.
Args:
resource_group_name (str): The name of the resource group
parameters (ResourceGroup): Resource group properties
Returns:
ResourceGroup: The created or updated resource group
"""
def get(self, resource_group_name: str, **kwargs) -> ResourceGroup:
"""
Get a resource group.
Args:
resource_group_name (str): The name of the resource group
Returns:
ResourceGroup: The resource group details
"""
def begin_delete(
self,
resource_group_name: str,
force_deletion_types: Optional[str] = None,
**kwargs
) -> LROPoller[None]:
"""
Delete a resource group.
Args:
resource_group_name (str): The name of the resource group to delete
force_deletion_types (str, optional): Comma-separated resource types to force delete
Returns:
LROPoller[None]: Long-running operation poller
"""
def list(
self,
filter: Optional[str] = None,
top: Optional[int] = None,
**kwargs
) -> ItemPaged[ResourceGroup]:
"""
List all resource groups in a subscription.
Args:
filter (str, optional): OData filter expression
top (int, optional): Maximum number of results to return
Returns:
ItemPaged[ResourceGroup]: Paginated list of resource groups
"""
def update(
self,
resource_group_name: str,
parameters: Union[ResourceGroupPatchable, IO[bytes]],
**kwargs
) -> ResourceGroup:
"""
Update a resource group (tags only).
Args:
resource_group_name (str): The name of the resource group
parameters (ResourceGroupPatchable): Updated properties
Returns:
ResourceGroup: The updated resource group
"""
def check_existence(self, resource_group_name: str, **kwargs) -> bool:
"""
Check if a resource group exists.
Args:
resource_group_name (str): The name of the resource group
Returns:
bool: True if resource group exists, False otherwise
"""Usage Example:
from azure.mgmt.resource.resources.models import ResourceGroup
# Create a resource group
rg_params = ResourceGroup(
location="East US",
tags={"environment": "dev", "project": "myapp"}
)
resource_group = client.resource_groups.create_or_update(
resource_group_name="my-resource-group",
parameters=rg_params
)
# List all resource groups
for rg in client.resource_groups.list():
print(f"{rg.name}: {rg.location}")Manage individual Azure resources across all resource types and providers.
class ResourcesOperations:
def begin_create_or_update(
self,
resource_group_name: str,
resource_provider_namespace: str,
parent_resource_path: str,
resource_type: str,
resource_name: str,
api_version: str,
parameters: Union[GenericResource, IO[bytes]],
**kwargs
) -> LROPoller[GenericResource]:
"""
Create or update a resource.
Args:
resource_group_name (str): Resource group name
resource_provider_namespace (str): Resource provider namespace
parent_resource_path (str): Parent resource path
resource_type (str): Resource type
resource_name (str): Resource name
api_version (str): API version to use for the resource provider
parameters (GenericResource): Resource properties
Returns:
LROPoller[GenericResource]: Long-running operation poller
"""
def get(
self,
resource_group_name: str,
resource_provider_namespace: str,
parent_resource_path: str,
resource_type: str,
resource_name: str,
api_version: str,
**kwargs
) -> GenericResource:
"""
Get a resource.
Args:
resource_group_name (str): Resource group name
resource_provider_namespace (str): Resource provider namespace
parent_resource_path (str): Parent resource path
resource_type (str): Resource type
resource_name (str): Resource name
api_version (str): API version to use for the resource provider
Returns:
GenericResource: The resource details
"""
def begin_delete(
self,
resource_group_name: str,
resource_provider_namespace: str,
parent_resource_path: str,
resource_type: str,
resource_name: str,
api_version: str,
**kwargs
) -> LROPoller[None]:
"""
Delete a resource.
Args:
resource_group_name (str): Resource group name
resource_provider_namespace (str): Resource provider namespace
parent_resource_path (str): Parent resource path
resource_type (str): Resource type
resource_name (str): Resource name
api_version (str): API version to use for the resource provider
Returns:
LROPoller[None]: Long-running operation poller
"""
def list(self, **kwargs) -> Iterable[GenericResource]:
"""
List all resources in a subscription.
Returns:
Iterable[GenericResource]: Iterator of resources
"""
def list_by_resource_group(
self,
resource_group_name: str,
filter: Optional[str] = None,
expand: Optional[str] = None,
top: Optional[int] = None,
**kwargs
) -> ItemPaged[GenericResourceExpanded]:
"""
List resources in a resource group.
Args:
resource_group_name (str): Resource group name
filter (str, optional): OData filter expression
expand (str, optional): Comma-separated list of additional properties
top (int, optional): Maximum number of results to return
Returns:
ItemPaged[GenericResourceExpanded]: Paginated list of resources
"""Manage Azure Resource Manager (ARM) template deployments for infrastructure as code.
class DeploymentsOperations:
def begin_create_or_update(
self,
resource_group_name: str,
deployment_name: str,
parameters: Deployment,
**kwargs
) -> LROPoller[DeploymentExtended]:
"""
Deploy ARM template to resource group.
Args:
resource_group_name (str): Resource group name
deployment_name (str): Deployment name
parameters (Deployment): Deployment parameters
Returns:
LROPoller[DeploymentExtended]: Long-running operation poller
"""
def get(
self,
resource_group_name: str,
deployment_name: str,
**kwargs
) -> DeploymentExtended:
"""
Get deployment details.
Returns:
DeploymentExtended: Deployment information
"""
def begin_delete(
self,
resource_group_name: str,
deployment_name: str,
**kwargs
) -> LROPoller[None]:
"""Delete a deployment."""
def list_by_resource_group(
self,
resource_group_name: str,
**kwargs
) -> Iterable[DeploymentExtended]:
"""
List deployments in a resource group.
Returns:
Iterable[DeploymentExtended]: Iterator of deployments
"""
def begin_validate(
self,
resource_group_name: str,
deployment_name: str,
parameters: Union[Deployment, IO[bytes]],
**kwargs
) -> LROPoller[DeploymentValidateResult]:
"""
Validate deployment template and parameters.
Args:
resource_group_name (str): Resource group name
deployment_name (str): Deployment name
parameters (Deployment): Deployment parameters to validate
Returns:
LROPoller[DeploymentValidateResult]: Long-running validation operation
"""
def begin_what_if(
self,
resource_group_name: str,
deployment_name: str,
parameters: DeploymentWhatIf,
**kwargs
) -> LROPoller[WhatIfOperationResult]:
"""
Preview changes that would be made by deployment.
Returns:
LROPoller[WhatIfOperationResult]: What-if operation results
"""Discover and manage Azure resource providers and their capabilities.
class ProvidersOperations:
def get(self, resource_provider_namespace: str, **kwargs) -> Provider:
"""
Get resource provider information.
Args:
resource_provider_namespace (str): Provider namespace
Returns:
Provider: Provider details
"""
def list(self, **kwargs) -> Iterable[Provider]:
"""
List all resource providers.
Returns:
Iterable[Provider]: Iterator of providers
"""
def register(self, resource_provider_namespace: str, **kwargs) -> Provider:
"""
Register a resource provider.
Args:
resource_provider_namespace (str): Provider namespace
Returns:
Provider: Registered provider details
"""
def unregister(self, resource_provider_namespace: str, **kwargs) -> Provider:
"""Unregister a resource provider."""Manage resource tags for organization and cost management.
class TagsOperations:
def create_or_update(self, tag_name: str, **kwargs) -> TagDetails:
"""
Create or update a tag.
Args:
tag_name (str): Tag name
Returns:
TagDetails: Tag information
"""
def delete(self, tag_name: str, **kwargs) -> None:
"""Delete a tag."""
def list(self, **kwargs) -> Iterable[TagDetails]:
"""
List all tags.
Returns:
Iterable[TagDetails]: Iterator of tags
"""
def create_or_update_value(
self,
tag_name: str,
tag_value: str,
**kwargs
) -> TagValue:
"""
Create or update a tag value.
Returns:
TagValue: Tag value information
"""
def create_or_update_at_scope(
self,
scope: str,
parameters: TagsResource,
**kwargs
) -> TagsResource:
"""
Create or update tags at a specific scope.
Args:
scope (str): Resource scope
parameters (TagsResource): Tag parameters
Returns:
TagsResource: Updated tags
"""class ResourceGroup:
"""Resource group model."""
id: str
name: str
type: str
location: str
properties: ResourceGroupProperties
tags: Dict[str, str]
managed_by: str
class GenericResource:
"""Generic resource model."""
id: str
name: str
type: str
location: str
tags: Dict[str, str]
plan: Plan
properties: Any
kind: str
managed_by: str
sku: Sku
identity: Identity
class Deployment:
"""Deployment model."""
properties: DeploymentProperties
class DeploymentProperties:
"""Deployment properties."""
template: Any
template_link: TemplateLink
parameters: Any
parameters_link: ParametersLink
mode: DeploymentMode
debug_setting: DebugSetting
class DeploymentExtended:
"""Extended deployment information."""
id: str
name: str
type: str
location: str
properties: DeploymentPropertiesExtended
class Provider:
"""Resource provider model."""
id: str
namespace: str
registration_state: str
resource_types: List[ProviderResourceType]
class TagDetails:
"""Tag details model."""
id: str
tag_name: str
values: List[TagValue]
count: TagCount
class GenericResourceExpanded(GenericResource):
"""Extended generic resource with additional properties."""
created_time: str
changed_time: str
class ResourceGroupProperties:
"""Resource group properties."""
provisioning_state: str
class ResourceGroupPatchable:
"""Resource group patchable properties."""
name: str
tags: Dict[str, str]
managed_by: str
class Plan:
"""Resource plan."""
name: str
publisher: str
product: str
promotion_code: str
version: str
class Sku:
"""Resource SKU."""
name: str
tier: str
size: str
family: str
capacity: int
class Identity:
"""Resource identity."""
principal_id: str
tenant_id: str
type: str
user_assigned_identities: Dict[str, Any]
class DeploymentPropertiesExtended:
"""Extended deployment properties."""
provisioning_state: ProvisioningState
correlation_id: str
timestamp: str
duration: str
outputs: Any
providers: List[Provider]
dependencies: List[Dependency]
class DeploymentValidateResult:
"""Deployment validation result."""
error: ErrorResponse
properties: DeploymentPropertiesExtended
class WhatIfOperationResult:
"""What-if operation result."""
status: str
error: ErrorResponse
properties: WhatIfOperationProperties
class DeploymentWhatIf:
"""Deployment what-if parameters."""
location: str
properties: DeploymentWhatIfProperties
class TemplateLink:
"""Template link."""
uri: str
content_version: str
class ParametersLink:
"""Parameters link."""
uri: str
content_version: str
class DebugSetting:
"""Debug setting."""
detail_level: str
class ProviderResourceType:
"""Provider resource type."""
resource_type: str
locations: List[str]
api_versions: List[str]
capabilities: str
class TagValue:
"""Tag value."""
id: str
tag_value: str
count: TagCount
class TagCount:
"""Tag count."""
type: str
value: int
class TagsResource:
"""Tags resource."""
properties: TagsResourceProperties
class TagsResourceProperties:
"""Tags resource properties."""
tags: Dict[str, str]
class ErrorResponse:
"""Error response."""
code: str
message: str
target: str
details: List[ErrorDetail]
class ErrorDetail:
"""Error detail."""
code: str
message: str
target: str
class Dependency:
"""Deployment dependency."""
depends_on: List[BasicDependency]
id: str
resource_type: str
resource_name: str
class BasicDependency:
"""Basic dependency."""
id: str
resource_type: str
resource_name: str
class WhatIfOperationProperties:
"""What-if operation properties."""
changes: List[WhatIfChange]
class WhatIfChange:
"""What-if change."""
resource_id: str
change_type: str
before: Any
after: Any
class DeploymentWhatIfProperties:
"""Deployment what-if properties."""
template: Any
template_link: TemplateLink
parameters: Any
parameters_link: ParametersLink
mode: DeploymentModeclass DeploymentMode(str, Enum):
"""Deployment modes."""
INCREMENTAL = "Incremental"
COMPLETE = "Complete"
class ProvisioningState(str, Enum):
"""Resource provisioning states."""
SUCCEEDED = "Succeeded"
FAILED = "Failed"
CANCELED = "Canceled"
ACCEPTED = "Accepted"
CREATING = "Creating"
CREATED = "Created"
UPDATING = "Updating"
UPDATED = "Updated"
DELETING = "Deleting"
DELETED = "Deleted"
RUNNING = "Running"Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-resource