azureblob: fix "409 Public access is not permitted on this storage account"

This error was caused by rclone supplying an empty
`x-ms-blob-public-access:` header when creating a container for
private access, rather than omitting it completely.

This is a valid way of specifying containers should be private, but if
the storage account has the flag "Blob public access" unset then it
gives "409 Public access is not permitted on this storage account".

This patch fixes the problem by only supplying the header if the
access is set.

Fixes #6645
This commit is contained in:
Nick Craig-Wood 2022-12-22 14:19:38 +00:00
parent d049cbb59e
commit 54c0f17f2a
1 changed files with 4 additions and 3 deletions

View File

@ -1363,15 +1363,16 @@ func (f *Fs) makeContainer(ctx context.Context, container string) error {
return nil
}
opt := service.CreateContainerOptions{
// Specifies whether data in the container may be accessed publicly and the level of access
Access: &f.publicAccess,
// Optional. Specifies a user-defined name-value pair associated with the blob.
//Metadata map[string]string
// Optional. Specifies the encryption scope settings to set on the container.
//CpkScopeInfo *CpkScopeInfo
}
if f.publicAccess != "" {
// Specifies whether data in the container may be accessed publicly and the level of access
opt.Access = &f.publicAccess
}
// now try to create the container
return f.pacer.Call(func() (bool, error) {
_, err := f.svc.CreateContainer(ctx, container, &opt)