Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleStringToSign Format
collapsetrue
StringToSign = VERB + "\n" +  
               Content-Encoding + "\n" +  
               Content-Language + "\n" +  
               Content-Length + "\n" +  
               Content-MD5 + "\n" +  
               Content-Type + "\n" +  
               Date + "\n" +  
               If-Modified-Since + "\n" +  
               If-Match + "\n" +  
               If-None-Match + "\n" +  
               If-Unmodified-Since + "\n" +  
               Range + "\n" +  
               CanonicalizedHeaders +   
               CanonicalizedResource;  

...

Code Block
titleAuthorization header format
collapsetrue
Authorization="SharedKey <AccountName>:<Signature>"

...

  1. LIST BLOB:

    In the LIST BLOB operation lists the blobs in the container. The StringToSign for LIST BLOB will be:
     

    Code Block
    titleStringToSign for LIST BLOB operation
    collapsetrue
    $stringToSign  =     "GET" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + (($ContentLength -gt -1) ? $ContentLength : '') + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "x-ms-blob-type:BlockBlob" + "`n" `
                         + "x-ms-date:$(Get-Date (Get-Date $Now).ToUniversalTime() -Format 'R')" + "`n" `
                         + "x-ms-version:$Version" + "`n" `
                         + "/$Account/$Container" + "`n" `
                         + "comp:list" + "`n" `
                         + "restype:container"

    where $Account is the account by which request is generated. $Container is the name of the container.

  2. GET BLOB:

    The GTE BLOB operation displays the content of the blob. So, for the get operation it is required to pass the blob name whose content is to be read/get. So, the StringToSign for GET BLOB will be:

    Code Block
    titleStringToSign for GET BLOB operation
    collapsetrue
    $stringToSign  =     'GET' `
    					 + "`n" `
                         + "`n" `
                         + "`n" `
                         + (($ContentLength -gt -1) ? $ContentLength : '') + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "x-ms-blob-type:BlockBlob" + "`n" `
                         + "x-ms-date:$(Get-Date (Get-Date $Now).ToUniversalTime() -Format 'R')" + "`n" `
                         + "x-ms-version:$Version" + "`n" `
                         + "/$Account/$Container/$Blob"

    where $Account is the account by which request is generated. $Container is the name of the container. $Blob is the name of the blob whose content is to be Get.

  3. PUT BLOB

    The PUT BLOB operation creates a new block or updates an existing block blob. The PUT BLOB creates a BLOB of a length of content in a file so it is required to pass the length of the blob so that it can allocate a that much memory in the Container and can write the file content to the blob. The StringToSign for the PUT BLOB will be:

    Code Block
    titleStringToSign for PUT BLOB operation
    collapsetrue
    $stringToSign  = 	 'PUT' `
    				     + "`n" `
                         + "`n" `
                         + "`n" `
                         + (($ContentLength -gt -1) ? $ContentLength : '') + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "`n" `
                         + "x-ms-blob-type:BlockBlob" + "`n" `
                         + "x-ms-date:$(Get-Date (Get-Date $Now).ToUniversalTime() -Format 'R')" + "`n" `
                         + "x-ms-version:$Version" + "`n" `
                         + "/$Account/$Container/$Blob"

    where $Account is the account by which request is generated. $Container is the name of the container. $Blob is the name of the blob which is to be created. The $ContentLength for the LIST BLOB and GET BLOB operation will be empty but for the PUT BLOB it required to pass the Content Length for the file to be created.

...

Code Block
titleEncoded StringToSign
collapsetrue
$hmac = New-Object System.Security.Cryptography.HMACSHA256
$hmac.key = [Convert]::FromBase64String( $AccessKey )
 
$signature = $hmac.ComputeHash( [Text.Encoding]::UTF8.GetBytes( $stringToSign ) )
$signature = [Convert]::ToBase64String( $signature )

...