- Added native OpenTelemetry tracing to Azure Core which enables users to use OpenTelemetry to trace Azure SDK operations without needing to install a plugin. #39563
- To enable native OpenTelemetry tracing, users need to:
- Have
opentelemetry-api
installed. - Ensure that
settings.tracing_implementation
is not set. - Ensure that
settings.tracing_enabled
is set toTrue
.
- Have
- If
setting.tracing_implementation
is set, the tracing plugin will be used instead of the native tracing. - If
settings.tracing_enabled
is set toFalse
, tracing will be disabled. - The
OpenTelemetryTracer
class was added to theazure.core.tracing.opentelemetry
module. This is a wrapper around the OpenTelemetry tracer that is used to create spans for Azure SDK operations. - Added a
get_tracer
method to the newazure.core.instrumentation
module. This method returns an instance of theOpenTelemetryTracer
class if OpenTelemetry is available. - A
TracingOptions
TypedDict class was added to define the options that SDK users can use to configure tracing per-operation. These options include the ability to enable or disable tracing and set additional attributes on spans.- Example usage:
client.method(tracing_options={"enabled": True, "attributes": {"foo": "bar"}})
- Example usage:
- The
DistributedTracingPolicy
anddistributed_trace
/distributed_trace_async
decorators now uses the OpenTelemetry tracer if it is available and native tracing is enabled.- SDK clients can define an
_instrumentation_config
class variable to configure the OpenTelemetry tracer used in method span creation. Possible configuration options arelibrary_name
,library_version
,schema_url
, andattributes
. DistributedTracingPolicy
now accepts ainstrumentation_config
keyword argument to configure the OpenTelemetry tracer used in HTTP span creation.
- SDK clients can define an
- To enable native OpenTelemetry tracing, users need to:
- Removed automatic tracing enablement for the OpenTelemetry plugin if
opentelemetry
was imported. To enable tracing with the plugin, please importazure.core.settings.settings
and setsettings.tracing_implementation
to"opentelemetry"
. #39563 - In
DistributedTracingPolicy
, the default span name is now just the HTTP method (e.g., "GET", "POST") and no longer includes the URL path. This change was made to converge with the OpenTelemetry HTTP semantic conventions. The full URL is still included in the span attributes. - Renamed span attributes in
DistributedTracingPolicy
:- "x-ms-client-request-id" is now "az.client_request_id"
- "x-ms-request-id" is now "az.service_request_id"
- Fixed an issue where the
traceparent
header was not being set correctly in theDistributedTracingPolicy
. Thetraceparent
header will now set based on the context of the HTTP client span. #40074
- Added
opentelemetry-api
as an optional dependency for tracing. This can be installed withpip install azure-core[tracing]
. #39563
- Added a default implementation to handle token challenges in
BearerTokenCredentialPolicy
andAsyncBearerTokenCredentialPolicy
.
- Fixed an issue where the
tracing_attributes
keyword argument wasn't being handled at the request/method level. #38164
- Log "x-vss-e2eid" and "x-msedge-ref" headers in
HttpLoggingPolicy
.
- Added azure.core.AzureClouds enum to represent the different Azure clouds.
- Added two new credential protocol classes,
SupportsTokenInfo
andAsyncSupportsTokenInfo
, to offer more extensibility in supporting various token acquisition scenarios. #36565- Each new protocol class defines a
get_token_info
method that returns anAccessTokenInfo
object.
- Each new protocol class defines a
- Added a new
TokenRequestOptions
class, which is aTypedDict
with optional parameters, that can be used to define options for token requests through theget_token_info
method. #36565 - Added a new
AccessTokenInfo
class, which is returned byget_token_info
implementations. This class contains the token, its expiration time, and optional additional information like when a token should be refreshed. #36565 BearerTokenCredentialPolicy
andAsyncBearerTokenCredentialPolicy
now first check if a credential has theget_token_info
method defined. If so, theget_token_info
method is used to acquire a token. Otherwise, theget_token
method is used. #36565- These policies now also check the
refresh_on
attribute when determining if a new token request should be made.
- These policies now also check the
- The Azure Core OpenTelemetry tracing plugin will now be the preferred tracing plugin over the OpenCensus plugin. If both plugins are installed and
opentelemetry
is imported, then OpenTelemetry will be used to trace Azure SDK operations. #35050
- Tracing:
DistributedTracingPolicy
will now set an attribute,http.request.resend_count
, on HTTP spans for resent requests to indicate the resend attempt number. #35069
- Raise correct exception if transport is used while already closed #35559
- HTTP tracing spans will now include an
error.type
attribute if an error status code is returned. #34619 - Minimum required Python version is now 3.8
- Accept float for
retry_after
header. #34203
- Support tuple input for file values to
azure.core.rest.HttpRequest
#33948 - Support tuple input to
files
with duplicate field namesazure.core.rest.HttpRequest
#34021
- Removed dependency on
anyio
. #33282
- Adjusted
AsyncBearerTokenCredentialPolicy
to work properly withtrio
concurrency mechanisms. (#33307)
- Added dependency on
anyio
>=3.0,<5.0 - Bumped minimum dependency on
requests
to 2.21.0.
- Fixed an issue with
multipart/form-data
in the async transport wheredata
was not getting encoded into the request body. #32473
- Use ssl context from aiohttp by default.
- Fixed the issue that some urls trigger an infinite loop. #31346
- Fixed issue where IndexError was raised if multipart responses did not match the number of requests. #31471
- Fixed issue unbound variable exception if dict is invalid in CloudEvent.from_dict. #31835
- Fixed issue asyncBearerTokenCredentialPolicy is not backward compatible with SansIOHTTPPolicy. #31836
- Fixed issue mypy complains with new version of azure-core. #31564
- Typing fix:
message
cannot beNone
inAzureError
. #31564
- Added a default implementation for
AsyncTokenCredential.__aexit__()
#31573
- Bumped
typing-extensions
version to 4.6.0.
- Not pass
enabled_cae
unless it is explicitly enabled.
- A keyword argument
enable_cae
was added to theget_token
method of theTokenCredential
protocol. #31012 BearerTokenCredentialPolicy
andAsyncBearerTokenCredentialPolicy
now acceptenable_cae
keyword arguments in their constructors. This is used in determining if Continuous Access Evaluation (CAE) should be enabled for eachget_token
request. #31012
- Added header name parameter to
RequestIdPolicy
. #30772 - Added
SensitiveHeaderCleanupPolicy
that cleans up sensitive headers if a redirect happens and the new destination is in another domain. #28349
- Catch aiohttp errors and translate them into azure-core errors.
- Fix url building for some complex query parameters scenarios #30707
- Added support to use sync credentials in
AsyncBearerTokenCredentialPolicy
. #30381 - Added "prefix" parameter to AzureKeyCredentialPolicy #29901
- Improve error message when providing the wrong credential type for AzureKeyCredential #30380
- Updated settings to include OpenTelemetry as a tracer provider. #29095
- Improved typing
- Fixed deflate decompression for aiohttp #28483
- Fix 'ClientSession' object has no attribute 'auto_decompress' (thanks to @mghextreme for the contribution)
- Add "x-ms-error-code" as secure header to log
- Rename "DEFAULT_HEADERS_WHITELIST" to "DEFAULT_HEADERS_ALLOWLIST". Added a backward compatible alias.
- Added example of RequestsTransport with custom session. (thanks to @inirudebwoy for the contribution) #26768
- Added Python 3.11 support.
- LRO polling will not wait anymore before doing the first status check #26376
- Added extra dependency for [aio]. pip install azure-core[aio] installs aiohttp too.
- Added @runtime_checkable to
TokenCredential
protocol definitions #25187
Azure-core is supported on Python 3.7 or later. For more details, please read our page on Azure SDK for Python version support policy.
- Added
CaseInsensitiveDict
implementation inazure.core.utils
removing dependency onrequests
andaiohttp
- Fixed the bug that azure-core could not be imported under Python 3.11.0b3 #24928
ContentDecodePolicy
can now correctly deserialize more JSON bodies with different mime types #22410
- Declare method level span as INTERNAL by default #24492
- Fixed type hints for
azure.core.paging.ItemPaged
#24548
- Add
SerializationError
andDeserializationError
inazure.core.exceptions
for errors raised during serialization / deserialization #24312
- Allow stream inputs to the
content
kwarg ofazure.core.rest.HttpRequest
from objects with aread
method #23578
-
Improve intellisense type hinting for service client methods. #22891
-
Add a case insensitive dict
case_insensitive_dict
inazure.core.utils
. #23206
- Use "\n" rather than "/n" for new line in log. #23261
- Log "WWW-Authenticate" header in
HttpLoggingPolicy
#22990 - Added dependency on
typing-extensions
>= 4.0.1
- Limiting
final-state-via
scope to POST until consuming SDKs has been fixed to use this option properly on PUT. #22989
[This version is deprecated.]
- Add support for
final-state-via
LRO option in core. #22713
- Add response body to string representation of
HttpResponseError
if we're not able to parse out information #22302 - Raise
AttributeError
when calling azure.core.pipeline.transport.__bases__ #22469
- Python 2.7 is no longer supported. Please use Python version 3.6 or later.
- Revert change in str method #22023
- Sync stream downloading now raises
azure.core.exceptions.DecodeError
rather thanrequests.exceptions.ContentDecodingError
- Add response body to string representation of
HttpResponseError
if we're not able to parse out information #21800
- Correctly set response's content to decompressed body when users are using aiohttp transport with decompression headers #21620
- GA
send_request
onto theazure.core.PipelineClient
andazure.core.AsyncPipelineClient
. This method takes in requests and sends them through our pipelines. - GA
azure.core.rest
.azure.core.rest
is our new public simple HTTP library inazure.core
that users will use to create requests, and consume responses. - GA errors
StreamConsumedError
,StreamClosedError
, andResponseNotReadError
toazure.core.exceptions
. These errors are thrown if you mishandle streamed responses from theazure.core.rest
module - add kwargs to the methods for
iter_raw
anditer_bytes
#21529 - no longer raise JSON errors if users pass in file descriptors of JSON to the
json
kwarg inHttpRequest
#21504 - Added new error type
IncompleteReadError
which is raised if peer closes the connection before we have received the complete message body.
- SansIOHTTPPolicy.on_exception returns None instead of bool.
- The
Content-Length
header in a http response is strictly checked against the actual number of bytes in the body, rather than silently truncating data in case the underlying tcp connection is closed prematurely. (thanks to @jochen-ott-by for the contribution) #20412 - UnboundLocalError when SansIOHTTPPolicy handles an exception #15222
- Add default content type header of
text/plain
and content length header for users who pass unicode strings to thecontent
kwarg ofHttpRequest
in 2.7 #21550
- respect text encoding specified in argument (thanks to @ryohji for the contribution) #20796
- Fix "coroutine x.read() was never awaited" warning from
ContentDecodePolicy
#21318 - fix type check for
data
input toazure.core.rest
for python 2.7 users #21341 - use
charset_normalizer
ifchardet
is not installed to migrate aiohttp 3.8.0 changes.
- Refactor AzureJSONEncoder (thanks to @Codejune for the contribution) #21028
-
azure.core.rest.HttpResponse
andazure.core.rest.AsyncHttpResponse
are now abstract base classes. They should not be initialized directly, instead your transport responses should inherit from them and implement them. -
The properties of the
azure.core.rest
responses are now all read-only -
HttpLoggingPolicy integrates logs into one record #19925
azure.core.serialization.AzureJSONEncoder
(introduced in 1.17.0) serializesdatetime.datetime
objects in ISO 8601 format, conforming to RFC 3339's specification. #20190- We now use
azure.core.serialization.AzureJSONEncoder
to serializejson
input toazure.core.rest.HttpRequest
.
- The
text
property onazure.core.rest.HttpResponse
andazure.core.rest.AsyncHttpResponse
has changed to a method, which also takes anencoding
parameter. - Removed
iter_text
anditer_lines
fromazure.core.rest.HttpResponse
andazure.core.rest.AsyncHttpResponse
- The behaviour of the headers returned in
azure.core.rest
responses now aligns across sync and async. Items can now be checked case-insensitively and without raising an error for format.
- Cut hard dependency on requests library
- Added a
from_json
method which now accepts storage QueueMessage, eventhub's EventData or ServiceBusMessage or simply json bytes to return aCloudEvent
- Not override "x-ms-client-request-id" if it already exists in the header. #17757
azure.core.rest
will not try to guess thecharset
anymore if it was impossible to extract it fromHttpResponse
analysis. This removes our dependency oncharset
.
- Add new provisional methods
send_request
onto theazure.core.PipelineClient
andazure.core.AsyncPipelineClient
. This method takes in requests and sends them through our pipelines. - Add new provisional module
azure.core.rest
.azure.core.rest
is our new public simple HTTP library inazure.core
that users will use to create requests, and consume responses. - Add new provisional errors
StreamConsumedError
,StreamClosedError
, andResponseNotReadError
toazure.core.exceptions
. These errors are thrown if you mishandle streamed responses from the provisionalazure.core.rest
module
- Improved error message in the
from_dict
method ofCloudEvent
when a wrong schema is sent.
- Added
BearerTokenCredentialPolicy.on_challenge
and.authorize_request
to allow subclasses to optionally handle authentication challenges
- Retry policies don't sleep after operations time out
- The
from_dict
methhod in theCloudEvent
can now convert a datetime string to datetime object when microsecond exceeds the python limitation
- Added
azure.core.credentials.AzureNamedKeyCredential
credential #17548. - Added
decompress
parameter forstream_download
method. If it is set toFalse
, will not do decompression upon the stream. #17920
Azure core requires Python 2.7 or Python 3.6+ since this release.
- Added
azure.core.utils.parse_connection_string
function to parse connection strings across SDKs, with common validation and support for case insensitive keys. - Supported adding custom policies #16519
- Added
~azure.core.tracing.Link
that should be used while passingLinks
toAbstractSpan
. AbstractSpan
constructor can now take in additional keyword only args.
- Make NetworkTraceLoggingPolicy show the auth token in plain text. #14191
- Fixed RetryPolicy overriding default connection timeout with an extreme value #17481
This version will be the last version to officially support Python 3.5, future versions will require Python 2.7 or Python 3.6+.
- Added
azure.core.messaging.CloudEvent
model that follows the cloud event spec. - Added
azure.core.serialization.NULL
sentinel value - Improve
repr
s forHttpRequest
andHttpResponse
s #16972
- Disable retry in stream downloading. (thanks to @jochen-ott-by @hoffmann for the contribution) #16723
- Added
CaseInsensitiveEnumMeta
class for case-insensitive enums. #16316 - Add
raise_for_status
method ontoHttpResponse
. Callingresponse.raise_for_status()
on a response with an error code will raise anHttpResponseError
. Calling it on a good response will do nothing #16399
- Update conn.conn_kw rather than overriding it when setting block size. (thanks for @jiasli for the contribution) #16587
- Added
AzureSasCredential
and its respective policy. #15946
- Add a
continuation_token
attribute to the baseAzureError
exception, and set this value for errors raised during paged or long-running operations.
- Set retry_interval to 1 second instead of 1000 seconds (thanks vbarbaresi for contributing) #14357
- Fixed bug to allow polling in the case of parameterized endpoints with relative polling urls #14097
- SAS credential replicated "/" fix #13159
- Support params as list for exploding parameters #12410
AzureKeyCredentialPolicy
will now accept (and ignore) passed in kwargs #11963- Better error messages if passed endpoint is incorrect #12106
- Do not JSON encore a string if content type is "text" #12137
- Added
http_logging_policy
property on theConfiguration
object, allowing users to individually set the http logging policy of the config #12218
- Fixed deadlocks in AsyncBearerTokenCredentialPolicy #11543
- Fix AttributeException in StreamDownloadGenerator #11462
- Added support for changesets as part of multipart message support #10485
- Add AsyncLROPoller in azure.core.polling #10801
- Add get_continuation_token/from_continuation_token/polling_method methods in pollers (sync and async) #10801
- HttpResponse and PipelineContext objects are now pickable #10801
- Support "x-ms-retry-after-ms" in response header #10743
link
andlink_from_headers
now accepts attributes #10765
- Not retry if the status code is less than 400 #10778
- "x-ms-request-id" is not considered safe header for logging #10967
- Support a default error type in map_error #9773
- Added
AzureKeyCredential
and its respective policy. #10509 - Added
azure.core.polling.base_polling
module with a "Microsoft One API" polling implementation #10090 Also contains the async version inazure.core.polling.async_base_polling
- Support kwarg
enforce_https
to disable HTTPS check on authentication #9821 - Support additional kwargs in
HttpRequest.set_multipart_mixed
that will be passed into pipeline context.
- Appended RequestIdPolicy to the default pipeline #9841
- Rewind the body position in async_retry #10117
- Add raw_request_hook support in custom_hook_policy #9958
- Add timeout support in retry_policy #10011
- Add OdataV4 error format auto-parsing in all exceptions ('error' attribute) #9738
- Fixed a bug that sends None as request_id #9545
- Enable mypy for customers #9572
- Handle TypeError in deep copy #9620
- Fix text/plain content-type in decoder #9589
- Fixed a regression in 1.2.0 that was incompatible with azure-keyvault-* 4.0.0 #9462
- Add user_agent & sdk_moniker kwargs in UserAgentPolicy init #9355
- Support OPTIONS HTTP verb #9322
- Add tracing_attributes to tracing decorator #9297
- Support auto_request_id in RequestIdPolicy #9163
- Support fixed retry #6419
- Support "retry-after-ms" in response header #9240
- Removed
__enter__
and__exit__
from async context managers #9313
- Bearer token authorization requires HTTPS
- Rewind the body position in retry #8307
- New RequestIdPolicy #8437
- Enable logging policy in default pipeline #8053
- Normalize transport timeout. #8000
Now we have:
- 'connection_timeout' - a single float in seconds for the connection timeout. Default 5min
- 'read_timeout' - a single float in seconds for the read timeout. Default 5min
- RequestHistory: deepcopy fails if request contains a stream #7732
- Retry: retry raises error if response does not have http_response #8629
- Client kwargs are now passed to DistributedTracingPolicy correctly #8051
- NetworkLoggingPolicy now logs correctly all requests in case of retry #8262
- Tracing: DistributedTracingPolicy now accepts kwargs network_span_namer to change network span name #7773
- Tracing: Implementation of AbstractSpan can now use the mixin HttpSpanMixin to get HTTP span update automatically #7773
- Tracing: AbstractSpan contract "change_context" introduced #7773
- Introduce new policy HttpLoggingPolicy #7988
- Fix AsyncioRequestsTransport if input stream is an async generator #7743
- Fix form-data with aiohttp transport #7749
- Tracing: AbstractSpan.set_current_span is longer supported. Use change_context instead. #7773
- azure.core.pipeline.policies.ContentDecodePolicy.deserialize_from_text changed
-
Tracing: network span context is available with the TRACING_CONTEXT in pipeline response #7252
-
Tracing: Span contract now has
kind
,traceparent
and is a context manager #7252 -
SansIOHTTPPolicy methods can now be coroutines #7497
-
Add multipart/mixed support #7083:
- HttpRequest now has a "set_multipart_mixed" method to set the parts of this request
- HttpRequest now has a "prepare_multipart_body" method to build final body.
- HttpResponse now has a "parts" method to return an iterator of parts
- AsyncHttpResponse now has a "parts" methods to return an async iterator of parts
- Note that multipart/mixed is a Python 3.x only feature
- Tracing: policy cannot fail the pipeline, even in the worst condition #7252
- Tracing: policy pass correctly status message if exception #7252
- Tracing: incorrect span if exception raised from decorated function #7133
- Fixed urllib3 ConnectTimeoutError being raised by Requests during a socket timeout. Now this exception is caught and wrapped as a
ServiceRequestError
#7542
-
Tracing:
azure.core.tracing.context
removed -
Tracing:
azure.core.tracing.context.tracing_context.with_current_context
renamed toazure.core.tracing.common.with_current_context
#7252 -
Tracing:
link
renamedlink_from_headers
andlink
takes now a string -
Tracing: opencensus implementation has been moved to the package
azure-core-tracing-opencensus
-
Some modules and classes that were importables from several different places have been removed:
azure.core.HttpResponseError
is now onlyazure.core.exceptions.HttpResponseError
azure.core.Configuration
is now onlyazure.core.configuration.Configuration
azure.core.HttpRequest
is now onlyazure.core.pipeline.transport.HttpRequest
azure.core.version
module has been removed. Useazure.core.__version__
to get version number.azure.core.pipeline_client
has been removed. Import fromazure.core
instead.azure.core.pipeline_client_async
has been removed. Import fromazure.core
instead.azure.core.pipeline.base
has been removed. Import fromazure.core.pipeline
instead.azure.core.pipeline.base_async
has been removed. Import fromazure.core.pipeline
instead.azure.core.pipeline.policies.base
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.base_async
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.authentication
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.authentication_async
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.custom_hook
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.redirect
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.redirect_async
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.retry
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.retry_async
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.distributed_tracing
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.pipeline.policies.universal
has been removed. Import fromazure.core.pipeline.policies
instead.azure.core.tracing.abstract_span
has been removed. Import fromazure.core.tracing
instead.azure.core.pipeline.transport.base
has been removed. Import fromazure.core.pipeline.transport
instead.azure.core.pipeline.transport.base_async
has been removed. Import fromazure.core.pipeline.transport
instead.azure.core.pipeline.transport.requests_basic
has been removed. Import fromazure.core.pipeline.transport
instead.azure.core.pipeline.transport.requests_asyncio
has been removed. Import fromazure.core.pipeline.transport
instead.azure.core.pipeline.transport.requests_trio
has been removed. Import fromazure.core.pipeline.transport
instead.azure.core.pipeline.transport.aiohttp
has been removed. Import fromazure.core.pipeline.transport
instead.azure.core.polling.poller
has been removed. Import fromazure.core.polling
instead.azure.core.polling.async_poller
has been removed. Import fromazure.core.polling
instead.
- Fix aiohttp auto-headers #6992
- Add tracing to policies module init #6951
- Transport classes don't take
config
parameter anymore (use kwargs instead) #6372 azure.core.paging
has been completely refactored #6420- HttpResponse.content_type attribute is now a string (was a list) #6490
- For
StreamDownloadGenerator
subclasses,response
is now anHttpResponse
, and not a transport response likeaiohttp.ClientResponse
orrequests.Response
. The transport response is available ininternal_response
attribute #6490
- aiohttp is not required to import async pipelines classes #6496
AsyncioRequestsTransport.sleep
is now a coroutine as expected #6490RequestsTransport
is not tight toProxyPolicy
implementation details anymore #6372AiohttpTransport
does not raise on unexpected kwargs #6355
- New paging base classes that support
continuation_token
andby_page()
#6420 - Proxy support for
AiohttpTransport
#6372
- Preview 1 release