How to Consume Azure Blob REST services using REST Connect Sender

Microsoft Azure Blob storage  provides REST endpoints that makes it possible to perform Blob operations in Microsoft Azure Blob storage. Using this API you can perform operations such as putting a new blob to storage, getting a stored blob, deleting a blob etc. To perform these operations you need a valid MS Azure subscription and a Azure Storage account. Using the REST sender you have to define a REST routing address to your storage account. The REST address has to be of form https://{storage}.blob.core.windows.net/{container} Where {storage1} is the place holder to specify your storage account name. Depending on what operations you want to perform {container} is the rest of the URL. The routing address has to select Azure Shared Key as the authentication method and supply the storage key you have obtained for your storage account in the input field. Microsoft documentation has detailed descriptions of the API usage. An sample PL/SQL code to access Blob storage is given below. Note that correctly setting the "Content-Type" header is crucial to get the correct authentication key which is required to authenticate with the service:


create or replace package body AzureBlob_create_call is

procedure create_storage 
is

url_params_ PLSQLAP_RECORD_API.type_record_;
blob_ CLOB;

begin
url_params_ := PLSQLAP_RECORD_API.New_Record('URL_Parameters');
PLSQLAP_Record_API.Set_Value(url_params_,'storage', 'prralkstorage1',caseSensitive_ => TRUE);
PLSQLAP_Record_API.Set_Value(url_params_,'container', 'prralkcontainer1/prralk991',caseSensitive_ => TRUE);
blob_ := '<?xml version="1.0"?><DATA><![CDATA[{this is a blob a new blob}]]></DATA>';



plsql_rest_sender_API.Call_Rest_EndPoint(
rest_service_ => 'AZUREBLOB_PUT',
xml_ => blob_,
url_params_ => url_params_ ,
callback_func_ => 'P_L_S_Q_L_Rest_Test_API.REST_callback_Test',
http_method_ => 'PUT',
http_req_headers_ =>'x-ms-blob-type: BlockBlob,Content-Type: text/xml; charset=utf-8');


end create_storage; 
end AzureBlob_create_call;

The above sample application is to put a new blob to the blob storage. Note the relevant HTTP headers that are set x-ms-blob-type and Content-Type headers.