Azure / Azure/azure-powershell

[Az.Storage] Move-AzDataLakeGen2Item fails with 401 (Server failed to authenticate the request.) while using SAS token

Open
#14,875 5 comments 0 reactions 1 assignee Claimed by @blueww View on GitHub
act-codegen-extensibility-squad Data Lake Storage Gen2 Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

## Description
Move-AzDataLakeGen2Item fails with 403 while using SAS token.
This is because we also need input SAS token for dest item, but SDK don't provide API to input the dest SAS token.

## Steps to reproduce

```powershell
# Prepare: Create SAS from account key
$ctx = New-AzStorageContext -StorageAccountName $accountName -StorageAccountKey $key
$sas = New-AzStorageContainerSASToken -Name $filesystemName -Permission rwdl -Context $ctx
$sasctx = New-AzStorageContext -StorageAccountName $ctx.StorageAccountName -SasToken $sas

$dir3 = Move-AzDataLakeGen2Item -Context $sasctx -FileSystem $filesystemName -Path $dirname1 -DestFileSystem $filesystemName -DestPath $dirname3
```

## Environment data

```
$PSVersionTable won't impact
```

## Module versions

```powershell
Az.Storage 3.6.0
```

## Debug output

```
The error output has enough information
```

## Error output

```
$dir3 = Move-AzDataLakeGen2Item -Context $sasctx -FileSystem $filesystemName -Path $dirname1 -DestFileSystem $filesystemName -DestPath $dir3
Move-AzDataLakeGen2Item : Server failed to authenticate the request. Please refer to the information in the www-authenticate header.
RequestId:756e9c33-d01f-0077-1e68-3d9834000000
Time:2021-04-30T02:25:46.8840310Z
Status: 401 (Server failed to authenticate the request. Please refer to the information in the www-authenticate header.)
ErrorCode: NoAuthenticationInformation
Headers:
x-ms-error-code: NoAuthenticationInformation
x-ms-request-id: 756e9c33-d01f-0077-1e68-3d9834000000
x-ms-version: 2020-04-08
x-ms-client-request-id: a4dbb40b-0338-45e4-851d-17e5b72bfb40
Content-Length: 250
Content-Type: application/json;charset=utf-8
Date: Fri, 30 Apr 2021 02:25:46 GMT
Server: Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0
WWW-Authenticate: REDACTED
At line:2 char:17
+ ... $dir3 = Move-AzDataLakeGen2Item -Context $sasctx -FileSystem $fil ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Move-AzDataLakeGen2Item], RequestFailedException
+ FullyQualifiedErrorId : RequestFailedException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.MoveAzDataLakeGen2ItemCommand
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.