Azure management core library defines extensions to Azure Core that are specific to ARM (Azure Resource Management) needed when you use client libraries
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
ARM-specific polling strategies for managing long-running operations (LROs). These polling implementations handle Azure's asynchronous operation patterns including Azure-AsyncOperation headers, location headers, and body content polling.
Note: The polling classes must be imported directly from their module files rather than from the azure.mgmt.core.polling package due to current package structure limitations.
Synchronous ARM-specific long-running operation polling that combines multiple polling strategies to handle different ARM LRO patterns.
class ARMPolling(LROBasePolling):
"""ARM-specific synchronous LRO polling."""
def __init__(
self,
timeout: float = 30,
lro_algorithms: Optional[Sequence[LongRunningOperation[HttpRequestTypeVar, AllHttpResponseTypeVar]]] = None,
lro_options: Optional[Dict[str, Any]] = None,
path_format_arguments: Optional[Dict[str, str]] = None,
**operation_config: Any
) -> None: ...ARMPolling uses these algorithms in order:
Azure-AsyncOperation headersLocation headersfrom azure.mgmt.core.polling.arm_polling import ARMPolling
from azure.core.polling import LROPoller
# Create ARM-specific polling
polling = ARMPolling(timeout=60)
# Use with LROPoller
poller = LROPoller(
client=client,
initial_response=initial_response,
deserialization_callback=deserialize_func,
polling_method=polling
)
# Wait for completion
result = poller.result()Asynchronous ARM-specific long-running operation polling with the same polling strategies as ARMPolling but using async/await patterns.
class AsyncARMPolling(AsyncLROBasePolling):
"""ARM-specific asynchronous LRO polling."""
def __init__(
self,
timeout: float = 30,
lro_algorithms: Optional[Sequence[LongRunningOperation[HttpRequestTypeVar, AllHttpResponseTypeVar]]] = None,
lro_options: Optional[Dict[str, Any]] = None,
path_format_arguments: Optional[Dict[str, str]] = None,
**operation_config: Any
) -> None: ...import asyncio
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from azure.core.polling import AsyncLROPoller
async def main():
# Create async ARM-specific polling
polling = AsyncARMPolling(timeout=60)
# Use with AsyncLROPoller
poller = AsyncLROPoller(
client=client,
initial_response=initial_response,
deserialization_callback=deserialize_func,
polling_method=polling
)
# Wait for completion
result = await poller.result()
asyncio.run(main())Specialized polling for operations that return Azure-AsyncOperation headers. Handles Azure's asynchronous operation pattern with support for final-state-via options.
class AzureAsyncOperationPolling(OperationResourcePolling[HttpRequestTypeVar, AllHttpResponseTypeVar]):
"""Implements a operation resource polling, typically from Azure-AsyncOperation."""
def __init__(self, lro_options: Optional[Dict[str, Any]] = None) -> None: ...
def get_final_get_url(self, pipeline_response: PipelineResponse[HttpRequestTypeVar, AllHttpResponseTypeVar]) -> Optional[str]: ...Supports Swagger LRO options:
final-state-via: azure-async-operation - Uses operation URL for final statefinal-state-via: location - Uses location header for final statefrom azure.mgmt.core.polling.arm_polling import AzureAsyncOperationPolling
# Configure with LRO options
lro_options = {"final-state-via": "azure-async-operation"}
polling = AzureAsyncOperationPolling(lro_options=lro_options)Polling strategy that monitors the response body for provisioning state changes. Used for ARM resources that indicate their status through properties.provisioningState.
class BodyContentPolling(LongRunningOperation[HttpRequestTypeVar, AllHttpResponseTypeVar]):
"""Poll based on the body content.
Implement a ARM resource poller (using provisioning state).
"""
def can_poll(self, pipeline_response: PipelineResponse[HttpRequestTypeVar, AllHttpResponseTypeVar]) -> bool: ...
def get_polling_url(self) -> str: ...
def set_initial_status(self, pipeline_response: PipelineResponse[HttpRequestTypeVar, AllHttpResponseTypeVar]) -> str: ...
def get_status(self, pipeline_response: PipelineResponse[HttpRequestTypeVar, AllHttpResponseTypeVar]) -> str: ...Only polls for requests using:
PUT operationsPATCH operationsfrom azure.mgmt.core.polling.arm_polling import BodyContentPolling
# Usually used as part of ARMPolling, but can be used standalone
polling = BodyContentPolling()
# Check if this polling method can handle the response
if polling.can_poll(pipeline_response):
status = polling.get_status(pipeline_response)class _LroOption(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Known LRO options from Swagger."""
FINAL_STATE_VIA = "final-state-via"class _FinalStateViaOption(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Possible final-state-via options."""
AZURE_ASYNC_OPERATION_FINAL_STATE = "azure-async-operation"
LOCATION_FINAL_STATE = "location"ARM polling tries multiple strategies in sequence:
Body content polling extracts provisioning state from:
{
"properties": {
"provisioningState": "Succeeded|Failed|InProgress|..."
}
}All polling methods support:
OperationFailed for invalid initial status codesBadResponse for empty response bodies when content is expectedResponseType = Union[HttpResponse, AsyncHttpResponse]
PipelineResponseType = PipelineResponse[HttpRequest, ResponseType]
HttpRequestType = Union[LegacyHttpRequest, HttpRequest]
AllHttpResponseType = Union[LegacyHttpResponse, HttpResponse, LegacyAsyncHttpResponse, AsyncHttpResponse]
HttpRequestTypeVar = TypeVar("HttpRequestTypeVar", bound=HttpRequestType)
AllHttpResponseTypeVar = TypeVar("AllHttpResponseTypeVar", bound=AllHttpResponseType)Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-core