Skip to content

Commit

Permalink
blob/azureblob: add storage_account query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ekini committed Aug 12, 2022
1 parent 58fd166 commit 03704ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion blob/azureblob/azureblob.go
Expand Up @@ -28,7 +28,9 @@
// credentials and a service URL; see
// https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
// for a more complete descriptions of each approach.
// - AZURE_STORAGE_ACCOUNT: The service account name. Required.
// - AZURE_STORAGE_ACCOUNT: The service account name. Required if used along with AZURE_STORAGE KEY, because it defines
// authentication mechanism to be azblob.NewSharedKeyCredential, which creates immutable shared key credentials.
// Otherwise, "storage_account" in the URL query string parameter can be used.
// - AZURE_STORAGE_KEY: To use a shared key credential. The service account
// name and key are passed to NewSharedKeyCredential and then the
// resulting credential is passed to NewServiceClientWithSharedKey.
Expand Down Expand Up @@ -216,6 +218,8 @@ func (o *ServiceURLOptions) withOverrides(urlValues url.Values) (*ServiceURLOpti
return nil, err
}
retval.IsLocalEmulator = isLocalEmulator
case "storage_account":
retval.AccountName = value
default:
return nil, fmt.Errorf("unknown query parameter %q", param)
}
Expand Down
2 changes: 2 additions & 0 deletions blob/azureblob/azureblob_test.go
Expand Up @@ -624,6 +624,8 @@ func TestOpenBucketFromURL(t *testing.T) {
{"azblob://mybucket?protocol=http", false},
// With invalid protocol.
{"azblob://mybucket?protocol=ftp", true},
// With Account.
{"azblob://mybucket?storage_account=test", false},
// With CDN.
{"azblob://mybucket?cdn=true", false},
// With invalid CDN.
Expand Down

0 comments on commit 03704ec

Please sign in to comment.