Skip to content

bindings/azure/blobstorage: Adds presign#4299

Open
JoshVanL wants to merge 2 commits intodapr:mainfrom
JoshVanL:bindings-azure-blobstorage-sas
Open

bindings/azure/blobstorage: Adds presign#4299
JoshVanL wants to merge 2 commits intodapr:mainfrom
JoshVanL:bindings-azure-blobstorage-sas

Conversation

@JoshVanL
Copy link
Contributor

Add SAS URL generation support to the Azure Blob Storage binding, enabling users to generate temporary read-only access URLs for blobs without downloading the blob content.

Add new "presign" operation requiring "blobName" and "signTTL" metadata. Optionally return a presigned SAS URL during "create" when "signTTL" is provided in request metadata.

Fixes #3817

Add SAS URL generation support to the Azure Blob Storage binding,
enabling users to generate temporary read-only access URLs for blobs
without downloading the blob content.

Add new "presign" operation requiring "blobName" and "signTTL" metadata.
Optionally return a presigned SAS URL during "create" when "signTTL" is
provided in request metadata.

Fixes dapr#3817

Signed-off-by: joshvanl <me@joshvanl.dev>
Copilot AI review requested due to automatic review settings March 19, 2026 12:29
@JoshVanL JoshVanL requested review from a team as code owners March 19, 2026 12:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds SAS (presigned) URL generation support to the Azure Blob Storage binding, enabling callers to obtain temporary read-only access URLs without downloading blob contents, including an explicit presign operation and optional SAS URL return on create.

Changes:

  • Add presign binding operation that returns a SAS URL based on blobName + signTTL.
  • Extend create to optionally return presignURL when signTTL metadata is provided.
  • Add unit + certification coverage for presign and create-with-presign behaviors, and document the new operation in component metadata.

Reviewed changes

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

File Description
bindings/azure/blobstorage/blobstorage.go Implements presign, SAS URL generation helper, and optional presignURL return in create.
bindings/azure/blobstorage/blobstorage_test.go Adds unit tests for metadata validation, SAS URL generation, and invoke routing for presign.
bindings/azure/blobstorage/metadata.yaml Documents the new presign operation and its requirements/limitations.
tests/certification/bindings/azure/blobstorage/blobstorage_test.go Adds certification steps validating presign URL usability and error cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +180 to +184
if ttl, ok := req.Metadata[metadataKeySignTTL]; ok && ttl != "" {
presignURL, presignErr := a.generateSASURL(blockBlobClient, ttl)
if presignErr != nil {
return nil, fmt.Errorf("error generating SAS URL: %w", presignErr)
}
BlobURL string `json:"blobURL"`
BlobName string `json:"blobName"`
BlobURL string `json:"blobURL"`
BlobName string `json:"blobName"`
d, err := time.ParseDuration(ttl)
if err != nil {
return "", fmt.Errorf("cannot parse signTTL duration %q: %w", ttl, err)
}
JoshVanL added a commit to JoshVanL/dapr-docs that referenced this pull request Mar 19, 2026
Implemented in dapr/components-contrib#4299

Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
}

if signTTL != "" {
presignURL, presignErr := a.generateSASURL(blockBlobClient, signTTL)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't do this before the UploadBuffer?

return nil, fmt.Errorf("cannot parse signTTL duration %q: %w", ttl, err)
}
signTTL = ttl
delete(req.Metadata, metadataKeySignTTL)
Copy link
Member

Choose a reason for hiding this comment

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

Is it ok to mutate the request object?

}, nil
}

func (a *AzureBlobStorage) presign(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Since this is non exposed and ctx is not used, I think we should drop it.

Suggested change
func (a *AzureBlobStorage) presign(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
func (a *AzureBlobStorage) presign(req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trouble Generating SAS Token for Blob Storage

3 participants