Session private drop with env#49471
Draft
browndav-msft wants to merge 5 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
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 keysAZURE_STORAGE_SESSION_MODEandAZURE_STORAGE_SESSION_CONTAINER_NAME. - Wired env/config fallback into
BlobClientBuilder,BlobContainerClientBuilder, andBlobServiceClientBuilderpipeline 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. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.