bindings/azure/blobstorage: Adds presign#4299
Conversation
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>
There was a problem hiding this comment.
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
presignbinding operation that returns a SAS URL based onblobName+signTTL. - Extend
createto optionally returnpresignURLwhensignTTLmetadata 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.
| 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) | ||
| } |
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Is it ok to mutate the request object?
| }, nil | ||
| } | ||
|
|
||
| func (a *AzureBlobStorage) presign(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) { |
There was a problem hiding this comment.
Since this is non exposed and ctx is not used, I think we should drop it.
| func (a *AzureBlobStorage) presign(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) { | |
| func (a *AzureBlobStorage) presign(req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) { |
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