Access Azure Blob storage account from azure data factory

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Access Azure Blob storage account from azure data factory



I have a folder with list of files in my storage account and having been trying to delete one of the files using pipeline. In-order to get that done I have used "Web" in pipeline, copied the blob storage url and access keys.



Tired using the access keys directly under Headers|Authorization. Also tried the concept of Shared Keys at https://docs.microsoft.com/en-us/azure/storage/common/storage-rest-api-auth#creating-the-authorization-header



Even tried getting this work with curl, but it returned an Authentication Error every time I tried to run


# List the blobs in an Azure storage container.

echo "usage: $0##*/ <storage-account-name> <container-name> <access-key>"

storage_account="$1"
container_name="$2"
access_key="$3"

blob_store_url="blob.core.windows.net"
authorization="SharedKey"

request_method="DELETE"
request_date=$(TZ=GMT LC_ALL=en_US.utf8 date "+%a, %d %h %Y %H:%M:%S %Z")
#request_date="Mon, 18 Apr 2016 05:16:09 GMT"
storage_service_version="2018-03-28"

# HTTP Request headers
x_ms_date_h="x-ms-date:$request_date"
x_ms_version_h="x-ms-version:$storage_service_version"

# Build the signature string
canonicalized_headers="$x_ms_date_hn$x_ms_version_h"
canonicalized_resource="/$storage_account/$container_name"

string_to_sign="$request_methodnnnnnnnnnnnn$canonicalized_headersn$canonicalized_resourcencomp:listnrestype:container"


# Decode the Base64 encoded access key, convert to Hex.
decoded_hex_key="$(echo -n $access_key | base64 -d -w0 | xxd -p -c256)"


# Create the HMAC signature for the Authorization header
signature=$(printf "$string_to_sign" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$decoded_hex_key" -binary | base64 -w0)

authorization_header="Authorization: $authorization $storage_account:$signature"

curl
-H "$x_ms_date_h"
-H "$x_ms_version_h"
-H "$authorization_header"
-H "Content-Length: 0"
-X DELETE "https://$storage_account.$blob_store_url/$container_name/myfile.csv_123"



The curl command returns an error:



<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:XX
Time:2018-08-09T10:09:41.3394688Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'xxx' is not the same as any computed signature. Server used following string to sign: 'DELETE


<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:XX
Time:2018-08-09T10:09:41.3394688Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'xxx' is not the same as any computed signature. Server used following string to sign: 'DELETE





Please be Specific to your Question on what you really want and what issue you are facing?
– Jayendran
Aug 8 at 12:55




1 Answer
1



You cannot authorize directly from the Data Factory to the storage account API. I suggest that you use an Logic App. The Logic App has built in support for Blob store:
https://docs.microsoft.com/en-us/azure/connectors/connectors-create-api-azureblobstorage



You can call the Logic App from the Data Factory Web Activity. Using the body of the Data Factory request you can pass variables to the Logic app like the blob path.





but can I get the curl working ?
– Sithara Suresh
Aug 9 at 11:21





Possibly, but that is another question. I cannot help you with that and I don't see how that would help you deleting blobs from a data factory pipeline.
– Simon Zeinstra
Aug 10 at 12:09






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS