1

I've reviewed the information at:

As far as I can tell I am complying becuase I am posting the SAS in the URL.

Here is my simple test script:

#!/bin/bash

DATE_NOW=$(date -Ru | sed 's/\+0000/GMT/')
AZ_VERSION="2018-03-28"
AZ_BLOB_URL="https://XXXXXXXX.blob.core.windows.net"
AZ_BLOB_CONTAINER="XXXXXX"
AZ_BLOB_TARGET="${AZ_BLOB_URL}/${AZ_BLOB_CONTAINER}/"
AZ_SAS_TOKEN="?sv=2017-11-09&ss=b&srt=o&sp=rwlac&se=2021-11-06T01:05:33Z&st=2018-11-09T17:05:33Z&sip=192.0.2.0-192.0.2.254&spr=https&sig=XXXXXXXXXX"

curl -v -X PUT -H "Content-Type: application/octet-stream" -H "x-ms-date: ${DATE_NOW}" -H "x-ms-version: ${AZ_VERSION}" --data-binary "@/home/test/test" "${AZ_BLOB_TARGET}test${AZ_SAS_TOKEN}"

Running that yields:

> PUT /XXXX/XXXXX?sv=2017-11-09&ss=b&srt=o&sp=rwlac&se=2021-11-06T01:05:33Z&st=2018-11-09T17:05:33Z&sip=192.0.2.0-192.0.2.254&spr=https&sig=XXXXXXXXXX" HTTP/1.1
> Host: XXXXX.blob.core.windows.net
> User-Agent: curl/7.60.0
> Accept: */*
> Content-Type: application/octet-stream
> x-ms-date: Sat, 10 Nov 2018 17:48:06 GMT
> x-ms-version: 2018-03-28
> Content-Length: 14
> 
* upload completely sent off: 14 out of 14 bytes
< HTTP/1.1 400 An HTTP header that's mandatory for this request is not specified.
< Content-Length: 295
< Content-Type: application/xml
< Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
< x-ms-request-id: 69b144ec-b01e-0112-651d-791ccd000000
< x-ms-version: 2018-03-28
< x-ms-error-code: MissingRequiredHeader
< Date: Sat, 10 Nov 2018 17:48:06 GMT
< 
<?xml version="1.0" encoding="utf-8"?><Error><Code>MissingRequiredHeader</Code><Message>An HTTP header that's mandatory for this request is not specified.
RequestId:69b144ec-b01e-0112-651d-791ccd000000
3

The simple answer to your question is, you are missing -H "x-ms-blob-type: BlockBlob".

But you SAS Token might also be invalid after you fix the header, you are trying to upload a file using a SAS token that doe not have Container access and might have IP restrictions.

Image 1 Image 1

Image 2 Image 2

#!/bin/bash

DATE_NOW=$(date -Ru | sed 's/\+0000/GMT/')
AZ_VERSION="2018-03-28"
AZ_BLOB_URL="https://xxxxxx.blob.core.windows.net"
AZ_BLOB_CONTAINER="test"
AZ_BLOB_TARGET="${AZ_BLOB_URL}/${AZ_BLOB_CONTAINER}/"
AZ_SAS_TOKEN="?sv=2017-11-09&ss=b&srt=sco&sp=rwlac&se=2018-11-11T05:03:03Z&st=2018-11-10T21:03:03Z&spr=https&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%3D"

curl -v -X PUT -H "Content-Type: application/octet-stream" -H "x-ms-date: ${DATE_NOW}" -H "x-ms-version: ${AZ_VERSION}" -H "x-ms-blob-type: BlockBlob" --data-binary "/temp/test.log" "${AZ_BLOB_TARGET}test.log${AZ_SAS_TOKEN}"

Hope this helps.

  • 1
    Indeed it was the missing -H "x-ms-blob-type: BlockBlob" Thank you ! – Little Code Nov 11 '18 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.