Archive Request to Azure Storage
In this example shows how you can archive the body of incoming requests to Azure Blob Storage. This can be useful for auditing, logging, or archival scenarios. Additionally, you could use this policy to save the body of a request and then enqueue some async work that uses this body.
Configuration#
{
"name": "my-archive-request-azure-storage-inbound-policy",
"policyType": "archive-request-azure-storage-inbound",
"handler": {
"export": "default",
"module": "$import(./modules/YOUR_MODULE)",
"options": {
"blobCreateSas": "$env(BLOB_CREATE_SAS)",
"blobContainerPath": "$env(BLOB_CONTAINER_PATH)"
}
}
}
Options#
name
the name of your policy instance. This is used as a reference in your routes.policyType
the identifier of the policy. This is used by the Zuplo UI. Value should bearchive-request-azure-storage-inbound
.handler/export
The name of the exported type. Value should bedefault
.handler/module
the module containing the policy. Value should be$import(./modules/YOUR_MODULE)
.handler/options
The options for this policy:blobCreateSas
The Azure shared access token with permission to write to the bucket
blobContainerPath
The path to the Azure blob container
Using the Policy
In order to use this policy, you'll need to setup Azure storage. You'll find instructions on how to do that below.
Setup Azure
First, let's set up Azure. You'll need a container in Azure storage
(docs).
Once you have your container you'll need the URL - you can get it on the
properties
tab of your container as shown below.
Note - this sample is available as a Zup It on GitHub - just click ZupIt! to deploy to your Zuplo account: https://github.com/zuplo/samples-req-archive-filestorage
This URL will be the blobPath
in our policy options.
Next, we'll need a SAS (Shared Access Secret) to authenticate with Azure. You
can generate one of these on the Shared access tokens
tab.
Note, you should minimize the permissions - and select only the Create
permission. Choose a sensible start and expiration time for your token. Note, we
do not recommend restricting IP addresses because Zuplo runs at the edge in over
200 data-centers world-wide.
Then generate your SAS token - copy the token (not the URL) to the clipboard and
enter it into a new environment variable in your zup called BLOB_CREATE_SAS
.
You'll need another environment variable called BLOB_CONTAINER_PATH
.