I am attempting to write a PowerShell script for uploading files to an Azure File Share (SMB) and due to ISP issue's I'm required to use the REST API instead of the SMB protocol. I have working code for creating folders, directories, and empty files. However when I attempt to use the Put Range service (https://learn.microsoft.com/en-us/rest/api/storageservices/put-range) I run into issues with the server rejecting my signed authorization.
The auth string I'm signing looks like this:
$stringToSign = "PUT
The response from the server is this:
Invoke-RestMethod : AuthenticationFailedServer failed to authenticate the request. Make sure the value of
Authorization header is formed correctly including the signature.
Time:2023-01-04T00:16:22.9268980ZThe MAC signature found in the HTTP request
'pwRgIfKnp0ss/XP77syYEHm40vmLx6oxrYSh59ER55k=' is not the same as any computed signature. Server used following
string to sign: 'PUT
x-ms-date:Wed, 04 Jan 2023 00:16:16 GMT
And the headers sent with the request are:
x-ms-date: Wed, 04 Jan 2023 00:16:16 GMT
Authorization: SharedKey storageaccount:pwRgIfKnp0ss/XP77syYEHm40vmLx6oxrYSh59ER55k=
I've noticed that the Content-Length header (even though provided to sign) doesn't show up in the server's response. I also tried using '0' in the Content-Length signing string location and used the x-ms-content-length header instead, which results in the same error returned from the server.
Is there anyone who might be able to offer insight into where I might be going wrong?