Skip to content

Session private drop with env#49471

Draft
browndav-msft wants to merge 5 commits into
Azure:feature/storage/bifrostfrom
browndav-msft:session-private-drop-with-env
Draft

Session private drop with env#49471
browndav-msft wants to merge 5 commits into
Azure:feature/storage/bifrostfrom
browndav-msft:session-private-drop-with-env

Conversation

@browndav-msft

Copy link
Copy Markdown
Member

Enables configuring the blob storage session (SessionMode and session container name) through environment variables / Configuration, so callers can opt into a session without changing builder code.

Two new keys are introduced in BuilderHelper: - AZURE_STORAGE_SESSION_MODE — names a SessionMode (NONE, AUTO, SINGLE_SPECIFIED_CONTAINER), matched case-insensitively. Only applied when the builder is still on the default SessionMode.AUTO.

AZURE_STORAGE_SESSION_CONTAINER_NAME — supplies the container name to scope the session to. Only applied when the builder has no container name set.
A new helper, BuilderHelper.applyEnvironmentSessionDefaults(SessionOptions, Configuration, ClientLogger), performs the fallback resolution and is invoked from:

BlobClientBuilder (both pipeline construction paths)
BlobContainerClientBuilder (both pipeline construction paths)
BlobServiceClientBuilder#constructPipeline
Explicit programmatic configuration on the builder always wins; the env vars are only consulted to fill in unset values. An invalid AZURE_STORAGE_SESSION_MODE value throws IllegalArgumentException via the client logger.

@browndav-msft browndav-msft changed the base branch from main to feature/storage/bifrost June 11, 2026 16:25
@github-actions github-actions Bot added the Storage Storage Service (Queues, Blobs, Files) label Jun 11, 2026
@ibrandes ibrandes requested a review from Copilot June 11, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables turning on Storage Blob “session” authentication via environment variables / Configuration without requiring code changes to explicitly set SessionOptions. It also corrects session signing to normalize Content-Length: 0 consistently with Shared Key and server canonicalization, with updated regression tests.

Changes:

  • Added BuilderHelper.applyEnvironmentSessionDefaults(SessionOptions, Configuration, ClientLogger) and new configuration keys AZURE_STORAGE_SESSION_MODE and AZURE_STORAGE_SESSION_CONTAINER_NAME.
  • Wired env/config fallback into BlobClientBuilder, BlobContainerClientBuilder, and BlobServiceClientBuilder pipeline construction.
  • Updated session signing and tests to normalize Content-Length: "0" to "", and added/updated tests around env-based activation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java Adds env/config-driven defaults for SessionOptions (new keys + parsing/validation).
sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobServiceClientBuilder.java Applies env/config session defaults before building the pipeline.
sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobContainerClientBuilder.java Applies env/config session defaults prior to session validation and pipeline construction.
sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobClientBuilder.java Applies env/config session defaults in both sync/async build paths.
sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/StorageSessionCredential.java Normalizes Content-Length: 0 to empty for session string-to-sign (align with Shared Key/server).
sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BuilderHelperTests.java Adds unit tests for env/config-driven session activation and precedence rules.
sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerApiTests.java Adds disabled live end-to-end test for env-var activation (sync).
sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAsyncApiTests.java Adds disabled live end-to-end test for env-var activation (async).
sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/implementation/util/SessionTokenCredentialPolicyTest.java Updates regression test to assert Content-Length: 0 normalization behavior.
sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/implementation/util/StorageSessionCredentialTest.java Updates test commentary to reflect the corrected Content-Length behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storage Storage Service (Queues, Blobs, Files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants