diff --git a/sdk/core/azure-mgmt-core/CHANGELOG.md b/sdk/core/azure-mgmt-core/CHANGELOG.md index c5ae2fbe9c09..c748a72f89c9 100644 --- a/sdk/core/azure-mgmt-core/CHANGELOG.md +++ b/sdk/core/azure-mgmt-core/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.6.1 (Unreleased) + +### Bugs Fixed + +- `ARMPolling` now includes the `azure-asyncoperation` header in the continuation token to ensure proper LRO rehydration. + ## 1.6.0 (2025-07-02) ### Other Changes diff --git a/sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py b/sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py index f83b79240838..63b396f7f785 100644 --- a/sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py +++ b/sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py @@ -9,4 +9,4 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "1.6.0" +VERSION = "1.6.1" diff --git a/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/arm_polling.py b/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/arm_polling.py index a17844612a04..24c3027e95e4 100644 --- a/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/arm_polling.py +++ b/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/arm_polling.py @@ -24,7 +24,7 @@ # # -------------------------------------------------------------------------- from enum import Enum -from typing import Optional, Union, TypeVar, Dict, Any, Sequence +from typing import Optional, Union, TypeVar, Dict, Any, Sequence, Mapping from azure.core import CaseInsensitiveEnumMeta from azure.core.polling.base_polling import ( @@ -47,6 +47,24 @@ ) from azure.core.rest import HttpRequest, HttpResponse, AsyncHttpResponse +# ARM-specific LRO headers - azure-asyncoperation is ARM-specific +_ARM_LRO_HEADERS = frozenset(["azure-asyncoperation"]) + + +def _add_arm_headers(filtered: Dict[str, str], headers: Mapping[str, str]) -> Dict[str, str]: + """Add ARM-specific headers to the filtered headers dict. + + :param filtered: The base filtered headers from parent class. + :type filtered: dict[str, str] + :param headers: The original response headers. + :type headers: Mapping[str, str] + :return: Updated filtered dictionary with ARM headers included. + :rtype: dict[str, str] + """ + filtered.update({k: v for k, v in headers.items() if k.lower() in _ARM_LRO_HEADERS}) + return filtered + + ResponseType = Union[HttpResponse, AsyncHttpResponse] PipelineResponseType = PipelineResponse[HttpRequest, ResponseType] HttpRequestType = Union[LegacyHttpRequest, HttpRequest] @@ -208,6 +226,18 @@ def __init__( **operation_config ) + def _filter_headers_for_continuation_token(self, headers: Mapping[str, str]) -> Dict[str, str]: + """Filter headers to include in the continuation token. + + ARM-specific override that includes the azure-asyncoperation header. + + :param headers: The response headers to filter. + :type headers: Mapping[str, str] + :return: A filtered dictionary of headers to include in the continuation token. + :rtype: dict[str, str] + """ + return _add_arm_headers(super()._filter_headers_for_continuation_token(headers), headers) + __all__ = [ "AzureAsyncOperationPolling", diff --git a/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/async_arm_polling.py b/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/async_arm_polling.py index 38c123871807..a8b3a5a657c0 100644 --- a/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/async_arm_polling.py +++ b/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/async_arm_polling.py @@ -23,12 +23,18 @@ # IN THE SOFTWARE. # # -------------------------------------------------------------------------- -from typing import Optional, Dict, Any, Sequence +from typing import Optional, Dict, Any, Sequence, Mapping from azure.core.polling.base_polling import LocationPolling, StatusCheckPolling, LongRunningOperation from azure.core.polling.async_base_polling import AsyncLROBasePolling -from .arm_polling import AzureAsyncOperationPolling, BodyContentPolling, HttpRequestTypeVar, AllHttpResponseTypeVar +from .arm_polling import ( + AzureAsyncOperationPolling, + BodyContentPolling, + HttpRequestTypeVar, + AllHttpResponseTypeVar, + _add_arm_headers, +) class AsyncARMPolling(AsyncLROBasePolling): @@ -54,5 +60,17 @@ def __init__( **operation_config ) + def _filter_headers_for_continuation_token(self, headers: Mapping[str, str]) -> Dict[str, str]: + """Filter headers to include in the continuation token. + + ARM-specific override that includes the azure-asyncoperation header. + + :param headers: The response headers to filter. + :type headers: Mapping[str, str] + :return: A filtered dictionary of headers to include in the continuation token. + :rtype: dict[str, str] + """ + return _add_arm_headers(super()._filter_headers_for_continuation_token(headers), headers) + __all__ = ["AsyncARMPolling"] diff --git a/sdk/core/azure-mgmt-core/setup.py b/sdk/core/azure-mgmt-core/setup.py index 98ebd33128e2..2d738fb2299a 100644 --- a/sdk/core/azure-mgmt-core/setup.py +++ b/sdk/core/azure-mgmt-core/setup.py @@ -69,7 +69,7 @@ "pytyped": ["py.typed"], }, install_requires=[ - "azure-core>=1.32.0", + "azure-core>=1.38.0", ], python_requires=">=3.9", )