ContainerSessionProvider Class

Creates, caches, and invalidates per-container sessions backed by a TokenCredential.

A single provider may be shared across multiple clients to persist the session cache beyond the lifetime of any one of them. When no provider is supplied, each client creates one scoped to itself.

Constructor

ContainerSessionProvider(service_url: str, credential: TokenCredential, **kwargs: Any)

Parameters

Name Description
service_url
Required
str

The blob service endpoint. Container and blob path segments and all query parameters are stripped.

credential
Required

The credential used to authorize CreateSession calls.

Keyword-Only Parameters

Name Description
api_version
str

The Storage API version to use for CreateSession.

Methods

get_session

Return a session, creating one on a miss.

invalidate_session

Drop the cached session if it still matches the rejected one.

is_request_eligible

Checks whether the request can be signed with a session token.

get_session

Return a session, creating one on a miss.

get_session(request: PipelineRequest) -> Session | None

Parameters

Name Description
request
Required

The outgoing request.

Returns

Type Description

A session, or None if the caller should use bearer auth.

invalidate_session

Drop the cached session if it still matches the rejected one.

invalidate_session(request: PipelineRequest, current: Session) -> None

Parameters

Name Description
request
Required

The rejected request.

current
Required

The session that was rejected.

is_request_eligible

Checks whether the request can be signed with a session token.

is_request_eligible(request: PipelineRequest) -> bool

Parameters

Name Description
request
Required

The outgoing request.

Returns

Type Description

True if the request is valid.