Connecting to Azure Blob Storage
  • 10 Apr 2023
  • 3 Minutes to read
  • Dark
    Light

Connecting to Azure Blob Storage

  • Dark
    Light

Article Summary

Overview

Azure Blob Storage is a cloud-based object storage service that allows developers to store and manage large amounts of unstructured data, such as text, images, and video. Developers can connect to Azure Blob storage through a REST API to automate processes, integrate with other services and applications, and perform more complex operations.

Before proceeding with the REST configuration, Decisions has an Azure Storage Module that contains 10 pre-built steps for Azure Storage Blob. If the module does not contain the methods the use case requires, below is an example configuration for a REST Service that can be used to interact with Azure Storage Blobs.

Prerequisites

  • Obtain an Azure storage account and create a container to store data.

Additional Resource

Blob Service REST API


Example Configuration

Configuring Azure Blob as an OAuth Provider and Token 

  1. Following Establishing an OAuth Provider, select OAuth2 for the OAuth Version. 
  2. Enter https://login.microsoftonline.com/REPLACEWITHYOURTENANTID/oauth2/v2.0/token for the Token Request URL and https://login.microsoftonline.com/REPLACEWITHYOURTENANTID/oauth2/v2.0/authorize for Authorize URL
  3. Provide the Callback URL, Default Consumer Key, and the Default Consumer Secret Key. Click SAVE.
    Field NameValue 
    Callback URLRedirect URI for the application: https://[BaseportalURL]/HandleTokenResponse
    Default Consumer KeyThe Application Client ID (under the Overview page for the application in Azure)
    Default Secret KeySecret Key (under the Certificates & Secrets page of the application in Azure)
  4. Save and close.

  5. Following Creating OAuth Tokens, under OAuth Flow, select Authorization Code. Provide the Scope for the Token by entering https://storage.azure.com/.default
    This example will use Authorization Code as the Token Authorization. Use the Token Authorization that fits how the Azure Blob is configured.
    1. This Scope will use any permissions that were established on the Azure Blob Application. 
  6. Click RequestToken and click OK.

Setting up REST Integration

  1. Following the REST Service Integration Overview, enter https://[myaccount].blob.core.windows.net the Service URL. Under the AUTHENTICATION category, select Use OAuth.
    This example configuration uses OAuth as the Authentication method. Please note that if the Azure Blob Container is set to allow public access, choose "No Authentication" as the Authentication type. 
  2. Select Show Advanced Options to set up Additional HTTP Headers; this configuration required a Date and x-ms-version for the REST service to connect. In the Add Additional HTTP Headers dialog, provide the Header Key, like "Date", then choose to provide a Constant variable or to allow the variable to be provided within a Flow. 
    1. Date: Specify the Coordinated Universal Time (UTC) for the request. 
    2. x-ms-version: Required for all authorized requests, optional for anonymous requests. Specifies the version of the operation to use for this request. 
  3. Choose Use Custom Tag for Auth Header and type Bearer in the Custom Tag for Auth Header textbox.
  4. Then, select Use Static Oauth Token to select the Token Value as the authorization header on the API call.

Setting up the REST Method

  1. From the newly created REST Service's Folder, select All > Add Method to Service. In the New REST Service Method window, under URL (Relative to Base), enter the desired endpoint with parameters. This example method uses the Get Blob Properties parameters: {mycontainer}/{myblob}. While creating methods, provide curly braces around variables to make them available as Flow Step inputs.
  2. This REST method returns a Blob File; ensure the HTTP Method is set to GET.
  3. Change the Step Output Type to Binary, and provide an Output Filename.
  4. Select OK to save and close.

Using Azure Blob Integration Steps

  1. In a Designer Project, create a new Flow.  
  2. The Azure Blob Methods require the Date in UTC as an HTTP Header. To get the proper UTC time and format add the Convert Server Time to UTC step to the workspace and set the Input as Current Date Time.
  3. The UTC time needs to be converted to the proper format that Azure is expecting, for example:  Fri, 07 Apr 2023 20:13:40 GMT. Add a Get Formatted Date step to the outcome path of the Convert Server Time to UTC step, and set the output from the previous step as the input to this step. Set the Format as"R". Learn more about Standard Date and Time Format Strings.
  4. Navigate to INTEGRATION > REST SERVICES > [REST SERVICE NAME], and attach the REST Service method step.
  5. Provide the Inputs with the required information, then connect both the Done and Error paths to the End step. This example uses a Form step solely to display the Blob that is being pulled from Azure to further show the connection is working. 

Debug

Select Debug in the Top Action Bar to test the Flow. Right-click the steps to view the Inputs and Outputs. 


For further information on Integrations, visit the Decisions Forum.

Was this article helpful?