0

I've been trying this for some time now. Here's my Powershell:

$storSas = "sas-generated-with-windows-storage-explorer"
$StorageAccountName = "storageacc"
$containerName = "some-cont-name"
$clientContext = New-AzureStorageContext -SasToken $storSAS -StorageAccountName $StorageAccountName

# upload a file
Set-AzureStorageBlobContent -File "F:\somefile" `
  -Container $containerName `
  -Blob "somefile" `
  -Context $ClientContext 

And every time I get:

The remote server returned an error: (403) Forbidden. HTTP Status Code: 403 - HTTP Error Message: This re quest is not authorized to perform this operation using this permission.

My policy has Write and List permissions, why do I get this error?

0

1 Answer 1

1

There are 2 issues:

  1. Please use the latest Azure Powershell from https://github.com/Azure/azure-powershell/releases (currently is 6.9.0)

  2. If you need upload blob with SAS without Read permission, need add -Forceto Set-AzureStorageBlobContent cmdlets. This is because by default we will check if the dest blob exist (need read permission), and remind user weather to overwrite if dest blob exist.

The following script works for me: $sas = New-AzureStorageBlobSASToken -container $containerName -Blob $blobname -Permission w -Context $ctxkey $ctxsas = New-AzureStorageContext -StorageAccountName $StorageAccountName -SasToken $sas $a = Set-AzureStorageBlobContent -File $localSrcFile -Container $containerName -Blob $blobname -Force -Context $ctxsas

Besides that, if you use the latest version of Azure Powershell, Get-AzureStorageContainer also works with SAS. (Anyway, container ACL can't be get since need key permission)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.